Excel found unreadable content in 'temp.xls'.Do you want to recover the contents of this workbook?

I am trying to underline some characters in text I put into a cell. My code looks basically like here:



cells(currentRow, 5).PutValue(comment)

cells(currentRow, 5).Characters(0, 10).Font.Underline = FontUnderlineType.Single



or to bold some characters:

cells(currentRow, 5).PutValue(comment)

cells(currentRow, 5).Characters(0, 10).Font.IsBold = True



but both options return error message

“Excel found unreadable content in ‘temp.xls’.Do you want to recover the contents of this workbook?” when trying to open the workbook. The error disappears when I comment the line with formatting out. Thanks for help.

Hi,

Thank you for considering Aspose.

Well, we have tested your scenario and it works abs fine with the latest version of Aspose.Cells. Please try the attached latest version, if you still face any problem, please create a sample project and post it here, so we can figure out the issue soon.

Thank You & Best Regards,

The new version did not help but I figured out the issue: if you try to do

cells(currentRow, 5).Characters(0, 10).Font.IsBold = True

or

cells(currentRow, 5).Characters(0, 10).Font.Underline = FontUnderlineType.Single

on an empty cell it damages the excel workbook and it cannot be opened.

Thanks for help.

Hi,

Thanks for providing more details.

Ok, we will look into the issue to figure it out soon.

BTW, why are you applying the rich text formattings to those so called empty cells, I think you may try to apply some checks before applying rich formattings, e.g.,

If cells(i, j).StringValue.Trim() <> "" Then

cells(i, j).Characters(0, 10).Font.IsBold = True

End If

Thank you.

Thanks. The problem was I could not identify the cause of the error…