Loading large csv file gives "Index was outside the bounds of the array" error

When I try to load a large csv file I get the following error:


System.IndexOutOfRangeException occurred
Message=Index was outside the bounds of the array.
Source=Aspose.Cells
StackTrace:
at —.–‹.˜()
at —.–‹.˜()
at —.–‹.˜()
at —.–‹.˜(Int32 , Int32 )
at —.–‹.ParseObject(String )
at ‰.‘.›ˆ(String , Int32 )
at ‰.‘.›(Row , Int32 , Int32 , StringBuilder )
at ‰.‘.ƒ(StreamReader , Int32 , Int32 )
at Aspose.Cells.Workbook.Ÿ(Stream , LoadOptions , Boolean )
at Aspose.Cells.Workbook…ctor(Stream stream, LoadOptions loadOptions)
at Item_Workshop_MVC.Models.TestBuildModel.ImportForm(HttpRequestBase request, Boolean update) in c:\Web Sites\Versions\Item Workshop\4.1\App_Code\Models\Test\TestBuild.cs:line 2784
InnerException:

I am including the file.

Here is my code:

LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
Workbook importData = new Workbook(file.InputStream, loadOptions);
Worksheet importSheet = importData.Worksheets[0];

file.InputStream is a file posted from the client side
I am using Aspose Cells version 7.2.1.0

Hi,

Thanks for using Aspose.Cells for .NET.

I was able to replicate this issue using your code with the latest version:
Aspose.Cells
for .NET v7.2.1.1


Please see the screenshot for your reference.

This issue has been logged as CELLSNET-40693.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\117+Items.csv”;


LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);

Workbook importData = new Workbook(filePath, loadOptions);

Worksheet importSheet = importData.Worksheets[0];



Screenshot:

Hi,

We will provide a fix for the error when reading this csv file. However, some values in template file will be converted as datetime value.

If you not want those values to be converted as datetime, using following option can give proper result and also you can avoid the error:

C#


TxtLoadOptions opt = new TxtLoadOptions();

opt.ConvertDateTimeData = false;

wb = new Workbook(pathCase, opt);

Hi,

Please download and try the latest fix: Aspose.Cells for .NET v7.2.1.3

We have fixed the issue of reading this CSV file.

This works. Thanks!

Hi,

Thanks for your feedback.

It’s good to know your issue is now resolved.

Let us know if you face any other issue, we will be glad to help you.