Aspose.Cells version 7.7.1.1 exception

I have a very simple function to same a worksheet to csv format.

After I have written data to the file and saved to .xlsx, I call a function

and it is throwing an exception.

System.ArgumentOutOfRangeException was unhandled
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source=mscorlib
ParamName=index
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at Aspose.Cells.Row.–Š(Int32 , Int32 , Int32 )
at ”.‰.‡Š(Int32 )
at ”.‰.˜(€ )
at ”.‰.Read(€ )
at ”.‡.—( , String )
at ”.‡.‰( , String )
at ”.‡.ƒ()
at ”.‡.Read()
at ”.†.(Workbook , LoadOptions )
at Aspose.Cells.Workbook.Ÿ(Stream , LoadOptions , Boolean )
at Aspose.Cells.Workbook.Ÿ(String , LoadOptions )
at Aspose.Cells.Workbook..ctor(String file)
at innalabs.windows.gu_acq.GUAcquisition.create_raw_text_csv(String file, String se_file_csv) .........

It is a large file, approx. 8MB and there are about 60,000 rows in the worksheet I want to save.

This was working fine with an older version, I updated today this started happening.

Any help in resolving this issues appreciated.

Hi Lewis,

Thank you for using Aspose products.

It is hard to say what could have caused the said exception unless you provide us your sample spreadsheet/CSV along with the source code snippet. Once we have reproduced the said problem on our end, we can quickly move forward to fix it for you. It is requested that please zip your sample before uploading it to the forum thread. In case you are concerned about the privacy of you sample, we can make this thread private or you can send us an email using the contact button on the post window.

Looking forward to your kind response.

Here is what I have.

I open an existing file and update one of sheets.

Aspose.Cells.Workbook worbook = new Aspose.Cells.Workbook(se_file_parsed);
// Clear some of the existing contents
worbook.Worksheets["Raw_Data"].Cells.ClearContents(0, 1, 11, 2);
worbook.Worksheets["Raw_Data"].Cells.ClearContents(16, 0, 50000, 12);

//5. Write all the header information..
worbook.Worksheets["Raw_Data"].Cells["B1"].PutValue(current_time_string);
.......
........
// Write a lot of data to ["Raw_Data"].
// Save the file
worbook.Save(se_file_parsed);
Aspose.Cells.Workbook worbook = new Aspose.Cells.Workbook(se_file_parsed);
// Clear some of the existing contents
worbook.Worksheets["Raw_Data"].Cells.ClearContents(0, 1, 11, 2);
worbook.Worksheets["Raw_Data"].Cells.ClearContents(16, 0, 50000, 12);

//5. Write all the header information..
worbook.Worksheets["Raw_Data"].Cells["B1"].PutValue(current_time_string);
.......
........
// Write a lot of data to ["Raw_Data"].
// Save the file
worbook.Save(se_file_parsed);

worbook.Worksheets["Raw_Data"].IsVisible = false;
worbook.Worksheets["Processing"].IsVisible = false;
worbook.Worksheets["DataBase"].IsVisible = true;
worbook.Worksheets["Passeport_1_5"].IsVisible = false;
worbook.Worksheets["Passeport_2_5"].IsVisible = false;
worbook.Worksheets["Passeport_3_5"].IsVisible = false;
worbook.Worksheets["Passeport_4_5"].IsVisible = false;
worbook.Worksheets["Passeport_5_5"].IsVisible = false;
worbook.Save(db_file_csv, SaveFormat.CSV);

I now want to save some of the sheets to CSV. The problem is using the 'wobook.Save(..) to save the file it is not getting the updated values, original values before made changes. The workbook is full of embedded links and values in cells are equal to math values I just updated.

I try the following and I get the exception:

Workbook workbook2 = new Aspose.Cells.Workbook(se_file_parsed);

worbook2.Worksheets["Raw_Data"].IsVisible = false;
worbook2.Worksheets["Processing"].IsVisible = false;
worbook2.Worksheets["DataBase"].IsVisible = true;
worbook2.Worksheets["Passeport_1_5"].IsVisible = false;
worbook2.Worksheets["Passeport_2_5"].IsVisible = false;
worbook2.Worksheets["Passeport_3_5"].IsVisible = false;
worbook2.Worksheets["Passeport_4_5"].IsVisible = false;
worbook2.Worksheets["Passeport_5_5"].IsVisible = false;
worbook2.Save(db_file_csv, SaveFormat.CSV);

Excel Attachment does not compress very well. (8MB), Can't seem to add it.

Is a refresh available to update the workbook object from disk?

After I have the workbook object saved using:

worbook.Save(file_name.xls)

How can I dispose/release the handle from the file object?

Hi Lewis,

Thank you for providing your source code snippet. Unfortunately we still need your sample file to reproduce the said exception on our end. We tried using a sample of our own by clearing the contents from a few cells, hiding the worksheets and saving the results in CSV format (that is what you are mainly doing in the code), but we are unable to experience any exception during the process. In order to proceed further with this investigate, we would request you to please share your sample file. You can zip the file and attach it with your response. I believe you will not face any issue while uploading the sample of 8MB.

Regarding your other question, all objects of Aspose.Cells are .NET managed object therefore how and when the resources will be released depends on .NET framework completely. You don’t need to explicitly call Dispose method to release the resources. If you have stumbled upon a situation where resources are not getting freed properly then please share the sample as well as code snippet (if different from your recent post) so we could check it on our end to suggest a solution.

Thank you for your understanding and cooperation.

Aspose.Cells version 7.6.0.0 does not throw this exception…

Hi Lewis,

There are many versions between Aspose.Cells for .NET 7.6.0 and 7.7.1.1 with lots of enhancements and bug fixes. We can not figure out what could be causing the problem unless we review your sample file to reproduce the said exception on our end. Please note, it is essential to replicate the problem before moving forward to fix it for you.

We have published another build of Aspose.Cells for .NET 7.7.1.2. Please give the latest binaries a try on your end to see if you still can reproduce the problem. In case the problem persists, please share your sample with us.

I have updated the driver to 7.7.1.2

I am getting the following exception:

{“Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index”}

I have enclosed the excel file I am updating, I update the RAW_DATA worksheet and save the xlsx file to disk. I then call the following function:

FileStream fstream = new FileStream(excel_file, FileMode.Open);

// Here is where I get the exception:

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(fstream);


wb.Worksheets[“Raw_Data”].IsVisible = true;

wb.Worksheets[“Processing”].IsVisible = false;

wb.Worksheets[“DataBase”].IsVisible = false;

wb.Worksheets[“Passeport_1_5”].IsVisible = false;

wb.Worksheets[“Passeport_2_5”].IsVisible = false;

wb.Worksheets[“Passeport_3_5”].IsVisible = false;

wb.Worksheets[“Passeport_4_5”].IsVisible = false;

wb.Worksheets[“Passeport_5_5”].IsVisible = false;

wb.Save(raw_file_csv, SaveFormat.CSV);


fstream.Close();

As you will see the file has lot of links and updates based on the input of raw data. How can I get the current instance of workbook to update with having to try and open a new instance?







Hi again,

Thank you for providing your sample spreadsheet.

We have re-evaluated your presented keeping your previous messages in mind, and we are able to reproduce System.ArgumentOutOfRangeException “Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index” with latest version of Aspose.Cells for .NET 7.7.1.3. Please note, the problem occurred when we updated a few cells of your provided spreadsheet or/and cleared the contents of worksheet “Raw_Data”, saved it to disk and try loading again. Attached is the intermediate spreadsheet that enabled us to observe the exception whereas sample code to reproduce the problem is as follow.

C#


var worbook = new Aspose.Cells.Workbook(myDir + “Script_rev2_7.xlsx”);
// Clear some of the existing contents
worbook.Worksheets[“Raw_Data”].Cells.ClearContents(0, 1, 11, 2);
worbook.Worksheets[“Raw_Data”].Cells.ClearContents(16, 0, 50000, 12);
worbook.Worksheets[“Raw_Data”].Cells[“B1”].PutValue(System.DateTime.Now);
worbook.Save(myDir + “Script_rev2_7_out_1.xlsx”);

var book = new Aspose.Cells.Workbook(myDir + “Script_rev2_7_out_1.xlsx”);

We have logged this problem in our bug tracking system under ticket Id CELLSNET-42330. Please spare us little time to properly analyze the problem cause and to provide a fix at earliest. In the meanwhile, we will keep you posted with updates in this regard.

Please accept our apologies for your inconvenience.

Hi,

Thanks for using Aspose.Cells.

We have fixed this issue.

Please download and try this fix: Aspose.Cells
for .NET v7.7.1.4
and let us know your feedback.

The version 7.7.1.4 has fixes the exception.

Thank you.

Hi,


Good to know that your issue is resolved by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSNET-42330) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.