We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel Workbook displays content error message when opening

Thread ID:

Created:

Updated:

Platform:

Replies:

145637 Jul 2,2019 04:34 AM UTC Jul 4,2019 11:54 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: XlsIO
Greg Frazer
Asked On July 2, 2019 04:34 AM UTC

Using ASP.net core and Angular
Created a Excel workbook using Syncfusion.XlsIO.ExcelEngine
Downloaded the workbook as a Stream (file).
When I open it I get the message in the attached file(*.png)
Message: "We found a problem with some content in ''. Do you want us to try to recover as much as we ccan?..."
When Yes is clicked another dialog box appears.
The data in the opened spreadsheet is as expected ie what the DataTable held.

Here is a copy of the code used to create the workbook:
           DataTable dt = ConvertListToDatatable(headers, details);
            MemoryStream stream = new MemoryStream();
            stream.Position = 0;
            stream.SetLength(0);
            using (Syncfusion.XlsIO.ExcelEngine excelEngine = new Syncfusion.XlsIO.ExcelEngine())
            {
                Syncfusion.XlsIO.IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1);
                workbook.Version = Syncfusion.XlsIO.ExcelVersion.Excel2016;

                try
                {
                    Syncfusion.XlsIO.IWorksheet sheet = workbook.Worksheets[0];
                    sheet.ImportDataTable(dt, true, 1, 1);
                    sheet.Name = "Fred Schedule";
                    sheet.DisableSheetCalculations();
                    workbook.SaveAs(stream,Syncfusion.XlsIO.ExcelSaveType.SaveAsXLS);
                }
                finally
                {
                    dt.Dispose();
                    workbook.Close();
                }
            }


Attachment: ExcelContentError_ffd0d971.zip

Abirami Varadharajan [Syncfusion]
Replied On July 3, 2019 11:19 AM UTC

Hi Greg, 

Greetings from Syncfusion. 

We are unable to reproduce the issue with the shared information. We request you to share the issue reproducing sample along with the corrupted document which will be helpful for us to find the exact root cause of the issue and to provide prompt solution at the earliest. 

Regards, 
Abirami 


Greg Frazer
Replied On July 3, 2019 10:12 PM UTC

Solution has been found.
It was the way the document was been downloaded
It was not working with
/****************
return File(
                    filecontent    = stream.GetBuffer(),
                    ContentType = ""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                    fileName      = "Fredschedule.xlsx"
                    );
****************/
It works with
/******************
return new FileStreamResult(stream, "application/octet-stream")
            {
                FileDownloadName = "Fredschedule.xlsx"
            };
******************/
this issue can be closed

Abirami Varadharajan [Syncfusion]
Replied On July 4, 2019 11:54 AM UTC

Hi Greg, 

Thank you for updating us. 

We are glad that the issue is resolved at your end. Please let us know if you need further assistance. 

Regards, 
Abirami 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon