Table lost when export the file.

1 Answer 7 Views
SpreadProcessing
Arjan
Top achievements
Rank 1
Arjan asked on 24 Apr 2024, 03:58 PM

When i import an XLSX file and save it, Excell table are gone.
I use this table name in some formules.

I want insert some dynamic header information and some rows to the table.

I cant find any documentation which other things will be lost when i export the file.

    private void OpenFile()
    {
        string fileName = @"Template.xlsx";
        _xlsxProvider = new XlsxFormatProvider();

        using (Stream stream = File.OpenRead(fileName))
        {
            try
            {
                _workbook = _xlsxProvider.Import(stream);
                _worksheet = _workbook.ActiveWorksheet;
                _workbook.History.IsEnabled = false;
            }
            catch (Exception)
            {
                Console.WriteLine("Could not open file.");
            }
        }
    }
 public Stream GetOutputStream()
 {
     Stream stream = new MemoryStream();
     _xlsxProvider.Export(_workbook, stream);
     stream.Position = 0;
     return stream;
 } 

var stream  = _excelService.GetOutputStream();
 //write stream to fole
 using (var fileStream = File.Create("Output.xlsx"))
 {
     await stream.CopyToAsync(fileStream);
 }

Is it possible to keep the table when exporting.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Apr 2024, 10:29 AM

Hi, Arjan,

We already have several request related to tables in RadSpreadProcessing:

SpreadProcessing: Add support for tables and table styles

SpreadProcessing: Add support for Pivot Tables

SpreadProcessing: Add support for structured references in tables

However, it is hard for us to investigate the precise case without actually having the problematic file. Please try and prepare a sample file without the sensitive information. If you decide you can also send us the original file via a private support ticket where you can be certain that it will be used only for investigation purposes of this case and your privacy will be respected.  

Looking forward to your reply. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Arjan
Top achievements
Rank 1
commented on 25 Apr 2024, 12:29 PM

Thanks for your response.
I've seen most of the links.

It would be great if there was support for tables so that you could add records to them. But that's separate from my problem.

I load the document and save it and then the table is lost.

I added a zip with an example. The Sample Template is an excel file with a table and the Output file is the file that I get when I import and export that file with the above code.

Dess | Tech Support Engineer, Principal
Telerik team
commented on 29 Apr 2024, 06:34 AM

Hi, Arjan,

Thank you for sharing both files. Indeed, the documents contain tables which are currently not supported in our SpreadProcessing library. I would encourage you to cast your vote for the item in order to increase its priority. The more votes an item gathers, the higher its priority becomes. You can also click the Follow button to get notified for any status changes.

More information about the functionality offered by MS Excel can be found here:

Create and format tables

Using structured references with Excel tables

I hope this information helps.

Tags
SpreadProcessing
Asked by
Arjan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or