Excel found unreadable content - error message

We are receiving the below error when downloading the xlsx file that was generated using Aspose. The xlsx has data validation rules implemented using aspose api.

The complete error message is "Excel found unreadable content in "file name.xlsx’. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes.

When we click Yes, the excel file opens fine. When we click on Enable Editing on the Excel file, we receive the message “Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.” message.

If we comment out the code that adds the data validation, this issue does not occur. we are using the 7.5.0.0 version of Aspose dll.

Here’s the code sample that adds the data validation:

Aspose.Cells.ValidationCollection validations =
optionSheetTemplate.Validations;

Aspose.Cells.Range range =oWB.Worksheets[2].Cells.CreateRange(2,2,2,1);

range.Name = "myValidation";

Aspose.Cells.ValidationCollection vCollection = oNewWorksheet.Validations;

Aspose.Cells.Validation objValidation = vCollection[vCollection.Add()];

objValidation.Type = ValidationType.List;

objValidation.Operator = OperatorType.None;

objValidation.InCellDropDown = true;

objValidation.Formula1 = "=myValidation";

objValidation.ShowError = true;

objValidation.AlertStyle = ValidationAlertType.Stop;

objValidation.ErrorTitle = "Error";

objValidation.ErrorMessage = "Please select an option from the drop down.";

CellArea area;

area.StartRow = optionRowCount+1;

area.EndRow = oNewWorksheet.Cells.Rows.Count - 1;

area.StartColumn = 3;

area.EndColumn = 3;

objValidation.AreaList.Add(area);

area.StartRow = optionRowCount + 1;

area.EndRow = oNewWorksheet.Cells.Rows.Count - 1;

area.StartColumn = 4;

area.EndColumn = 4;

objValidation.AreaList.Add(area);

int startColumncount = 7;

for (int iCounter = 0; iCounter <= 40; iCounter++)

{

area.StartRow = optionRowCount + 1;

area.EndRow = oNewWorksheet.Cells.Rows.Count - 1;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount++;

area.StartRow = optionRowCount + 1;

area.EndRow = oNewWorksheet.Cells.Rows.Count - 1;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount++;

area.StartRow = optionRowCount + 1;

area.EndRow = oNewWorksheet.Cells.Rows.Count - 1;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount = startColumncount + 3;

}

Thank you.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please download and try the latest version: Aspose.Cells
for .NET v7.5.0.4
and see if it works fine.

If your problem still occurs, then please provide us your runnable sample project along with source files replicating this issue with the latest version. We will look into your project and update you asap.

Thank you for the response, we tried to download and include the new files in our project but taht did not help.

Attached is a sample project that has this issue. Please review and let us know what the fix should be.

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to observe this issue. After running your project, corrupt xlsx file is generated. We have logged this issue in our database. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41811.

Hi,

We have checked your issue a bit, this issue is caused by the start row is less than end row of the cell area.

Please change your codes to set correct end row.

See following codes:

Sample code:

Aspose.Cells.ValidationCollection vCollection = oNewWorksheet.Validations;

Aspose.Cells.Validation objValidation = vCollection[vCollection.Add()];

objValidation.Type = Aspose.Cells.ValidationType.List;

objValidation.Operator = OperatorType.None;

objValidation.InCellDropDown = true;

objValidation.Formula1 = "=myValidation";

objValidation.ShowError = true;

objValidation.AlertStyle = Aspose.Cells.ValidationAlertType.Stop;

objValidation.ErrorTitle = "Error";

objValidation.ErrorMessage = "Please select an option from the drop down.";

Aspose.Cells.CellArea area;

area.StartRow = optionRowCount + 1;

area.EndRow = 65535;

area.StartColumn = 3;

area.EndColumn = 3;

objValidation.AreaList.Add(area);

area.StartRow = optionRowCount + 1;

area.EndRow = 65535;

area.StartColumn = 4;

area.EndColumn = 4;

objValidation.AreaList.Add(area);

int startColumncount = 7;

for (int iCounter = 0; iCounter <= 40; iCounter++)

{

area.StartRow = optionRowCount + 1;

area.EndRow = 65535;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount++;

area.StartRow = optionRowCount + 1;

area.EndRow = 65535;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount++;

area.StartRow = optionRowCount + 1;

area.EndRow = 65535;

area.StartColumn = startColumncount;

area.EndColumn = startColumncount;

objValidation.AreaList.Add(area);

startColumncount = startColumncount + 3;

}

Thank you.