Free Support Forum - aspose.com

Index was outside the bounds of the array when opening/saving an excel file with a listbox control

when opening and saving an excel document that has a listbox control on it, Aspose.Cells (4.4.0.21) returns the following error.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Aspose.Cells.Record.?.?(Int32 ?, Byte[] ?, Int32 ?, Int32 ?, Boolean ?, Byte ?, Int32 ?, ArrayList ?)
at Aspose.Cells.Record.?.?(ListBox ?)
at Aspose.Cells.Record.?.?(Shape ?)
at Aspose.Cells.MsoDrawing.?.?(Shape ?, Boolean ?)
at Aspose.Cells.MsoDrawing.?.?()
at Aspose.Cells.Worksheet.?(? ?)
at Aspose.Cells.Worksheets.?(? ?)
at Aspose.Cells.Worksheets.?(FileFormatType ?)
at Aspose.Cells.Worksheets.?(Stream ?, FileFormatType ?)
at Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName)
at WindowsApplication2.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\jrozier\My Documents\Visual Studio 2005\Projects\WindowsApplication2\WindowsApplication2\Form1.vb:line 15

I've attached a sample problem document and this is my code.

Dim x As New Aspose.Cells.Workbook

x.Open("C:\test\m1131.xls")

x.Save("C:\test\m1132.xls")

Hi,

Thanks for the template file.

We found the problem, we will figure it out soon.

Thank you.

Hi,

Please try this fix. We have fixed this bug of saving List box.

In this fix,we use Cell.GetStyle and SetStyle method replace the property of Cell.Style. The two methods will save more memory usage than cell.Style property.

If you want to set style of the cell, please change your codes as :

//Getting the style of the cell.

Style style = cell.GetStyle();

//Setting the property of the style.

.......

//Setting the style of the cell

cell.SetStyle(style);