Cells Not Reading Data Correctly

We have been using the aspose.cells product for many years - we have recently run into a strange case where an XLSX file is presented and that is returned by the Cell.Value function has no resemblance to the data that is in the cell.


We can re-save the file as an XLS as it does not correct the issue but if we copy the contents and paste it into a new document - it works fine.

Code is as follows:

for (counter = 0; counter < 50; counter++)
{
headerCell = workSheet.Cells[startingRow - 1, counter];
String headerName = “” + headerCell.Value;
bla bla…
}

Cell A3 has the value PAYER but when we print out the headerCell we see:

Aspose.Cells.Cell [ A3; ValueType : IsNumeric; Value : 24 ]

This is repeated for all cells across that row (these should just be Strings). Excel reads it ok though.

We have updated to the latest version that was available for Aspose.Cells (7.3.1) and get the same error. Anyone else that has run into this issue?

Hi,


I have checked your template file and found that the first two worksheets (indexed on 0 and 1) are set to VeryHidden option, you may use “Alt + F11” to see those hidden worksheets. So, you have to change your line of code probably i.e…,
Worksheet worksheet = workbook.Worksheets[0]; --> Do not use index for obtaining the worksheet, this will refer to the first VeryHidden worksheet.
to:
Worksheet worksheet = workbook.Worksheets[“Sheet1”];

I have checked using the following code and it works fine.
I have also pasted the output here.

Sample code:
Workbook workbook = new Workbook(“e:\test2\aspose-reading-bug.xls”);
Worksheet worksheet = workbook.Worksheets[“Sheet1”];

for (int counter = 0; counter < 50; counter++)
{
Aspose.Cells.Cell headerCell = worksheet.Cells[2, counter];
String headerName = “” + headerCell.Value;
Debug.WriteLine(headerName);
}

Output:

Payer
Street Name
P.O. Box
Location
Region
Postal Code
Telephone 1
Total
Current Month
1 Month Prior
2 Months Prior
3 Months Prior
4 Months Prior
>= 5 Months Prior