Excel Unreadable content error

Hi,
I’m trying to fix a bu where our export file say’s it has a problem with the content, and prompts for a repair. the message is "We found a problem with some content "
then
"Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded."

the data is all there when the repair is completed, so I don’t know what it is fixing.
I’ve gotten this error with both version 7.0.4 and the 8.2 evaluation version, Office 2013
can you please help me figure out what I’m doing wrong?

we are calling in like so:

// call export method to generate the fill stream for export
MemoryStream stream = Hiperos.EvaluationExport.ExporterUtilities.ReturnStreamFromDataTable(dbKey, dt, exportString);

//return the memory stream bytes application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
return this.Doc(stream.GetBuffer(), “Alerts.xlsx”, “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”);


public static MemoryStream ReturnStreamFromDataTable(DatabaseKey dbKey, DataTable dataTable, string description, bool fullDateTime = false)
{
//Set up the license…
//License license = new License();
//license.SetLicense(“Aspose.Cells.lic”);

//Create a new 2003 workbook
Workbook workbook = new Workbook();

//Get the first worksheet in the workbook
Worksheet sheet = workbook.Worksheets[0];

//Get the cells collection in the worksheet
Cells cells = sheet.Cells;

//Get Style Object
Aspose.Cells.Style style = cells[“A1”].GetStyle();

//the font text is set to bold
style.Font.IsBold = true;

//Apply style to the cell
cells[“A1”].SetStyle(style);

sheet.Cells[“A1”].PutValue(description);
//Import the datacolumn in the datatable to the sheet cells
sheet.Cells.ImportDataTable(dataTable, true, 1, 0);
// Set the datetime format based on the users culture
Style dateTimeFormat = workbook.CreateStyle();
if (fullDateTime)
{
dateTimeFormat.Custom = new CultureInfo(dbKey.Culture).DateTimeFormat.FullDateTimePattern;
}
else
{
dateTimeFormat.Custom = new CultureInfo(dbKey.Culture).DateTimeFormat.ShortDatePattern;
}

StyleFlag flag = new StyleFlag {All = true};

foreach(DataColumn column in dataTable.Columns)
{
if(column.DataType == typeof(DateTime))
{
// first row = 1 because A1 has the description
// first column is the index of the column
// total rows is the number of rows - 1 (because of the description)
sheet.Cells.CreateRange(1, column.Ordinal, sheet.Cells.Rows.Count - 1, 1).ApplyStyle(dateTimeFormat, flag);
}
}

//Autofit all the columns in the sheet
sheet.AutoFitColumns();

MemoryStream stream = new MemoryStream();
//take the results to a memory stream
workbook.Save(stream, new OoxmlSaveOptions(SaveFormat.Xlsx));

return stream;
}

Hi Debbie,


Thank you for contacting Aspose support.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for .NET 8.2.0.3, and by creating a DataTable on the fly. Unfortunately, we are unable to replicate the said problem on our end. We would request you to please give the latest version of Aspose.Cells for .NET a try with your original application. In case the problem persists, please create a sample standalone application replicating the problem, and share here for further investigation.

I’ve attached a sample project, I get the error every time.
my environment visual studio 2010, MVC3, .net 4.0. aspose.cells v 8.2.0
office 2013 (365).
thank you

Hi Debbie,


Thank you for providing your sample application.

We are currently evaluating your presented scenario, and we will shortly get back to you with updates in this regard.

Hi again,


Thank you for your patience.

We have able to replicate the said problem while using your provided sample application and latest version of Aspose.Cells for .NET 8.2.0.3. The problem has been logged in out bug tracking system under the ticket CELLSNET-43008 for further investigation & correction purposes. Please spare us little time to properly analyze the problem cause, and to provide a fix for this behavior. In the meanwhile, we will keep you posted with updates in this regard.

We are sorry for the inconvenience caused to you.

Hi,

Please change the line of codes, i.e.,
return this.Doc(stream.GetBuffer(), "Alerts.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
with:
return this.Doc(stream.ToArray(), "Alerts.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
it would work fine.

Thank you.

That worked, thank you :slight_smile:

Hi,


Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.