Read Excel file content

Hi Laurence,

I used the following code to read the excel file and extract the content in each cell. But the data is not correct:


Excel excel = new Excel().Open(“c:\importform.xls”);
int currentRow = 0;
do
{
string str1 = excel.Worksheets[0].Cells[currentRow,1].StringValue.ToString().Trim();
string str2 = excel.Worksheets[0].Cells[currentRow,0].StringValue.ToString().Trim();
string str3 = excel.Worksheets[0].Cells[currentRow,2].StringValue.ToString().Trim();
string str4 = excel.Worksheets[0].Cells[currentRow,3].StringValue.ToString().Trim();
string str5 = excel.Worksheets[0].Cells[currentRow,4].StringValue.ToString().Trim();

Response.Write(str1 + “,” + str2 + “,” + str3 + “,” + str4 + “,” + str5 + “
”);
currentRow = currentRow + 1;
}
while(excel.Worksheets[0].Cells[currentRow,0].StringValue.ToString().Trim() != “”);

The result should be:
PP1,A01a,MO,1,200
PP1,A01a,MO,2,201
PP1,A01a,MO,3,202
PP1,A01a,MO,4,203
PP1,A01a,MO,5,204
PP1,A01a,MO,6,205
PP1,A01a,MO,7,206
PP1,A01a,MO,8,207
PP1,A01a,MO,9,208
PP1,A01a,MO,10,209
PP1,A01a,MO,11,210
PP1,A01a,MO,12,211

But the result that extracted by Aspose.Excel is:
PP1,A01a,MO,1,200
PP1,A01a,m95d4aowftfUsZ,2,201
PP1,A01a,MO,3,202
PP1,A01a,MO,4,203
PP1,A01a,MO,5,204
PP1,A01a,MO,6,205
PP1,A01a,MO,7,206
PP1,A01a,MO,8,207
PP1,A01a,MO,9,208
PP1,A01a,MO,10,209
PP1,A01a,MO,11,210
PP1,A01a,MO,12,211

Did you have such problem?

Thanks and Regards,

Johnson

Hi Johnson,

Please check Licensing. The random string is an evaluation limitation.

This seems to have been removed now.
Can anyone confirm?

Hi Hitesh,


Thank you for contacting us. You are right. It is quite an old link. Please refer to the license section of Aspose.Cells for .NET API: Apply License to Aspose.Cells for .NET API. It works with Microsoft Office Excel formats and allows to export them in various other file formats.