- Home
- Forum
- ASP.NET Core - EJ 2
- Excel Workbook displays content error message when opening
Excel Workbook displays content error message when opening
Using ASP.net core and Angular
Attachment: ExcelContentError_ffd0d971.zip
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
SIGN IN To post a reply.
3 Replies
AV
Abirami Varadharajan
Syncfusion Team
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
GF
Greg Frazer
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
AV
Abirami Varadharajan
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
GF Greg Frazer
- Jul 2, 2019 04:34 AM UTC
- Jul 4, 2019 11:54 AM UTC