Bug: Worksheets.AddCopy() with resized column in designer


#1

I get a “Object must be of type Byte” error when executing the following code. Exception is thrown on the “Save” method.



string licenseFile = Server.MapPath(@"~\Licence\Aspose.Excel.lic");
Excel excel = new Excel(licenseFile, this);

// Load the template file.
string templateFile = Server.MapPath(@"~\Template.xls");
excel.Open(templateFile);

excel.Worksheets[0].Cells[0,0].PutValue(“Hello World”);
excel.Worksheets.AddCopy(0);

excel.Save(@“Test.xls”, SaveType.OpenInBrowser, FileFormatType.Default, this.Response);


Note that the code works if “Template.xls” is a brand new Excel document, but as soon as I manually adjust the width of column A (make it wider) in the template file I get the above error. The error does not appear unless I execute both PutValue("…") and AddCopy(0).

Aspose.Excel version 1.8.4.0. Excel 2002 SP-2.

The full error text follows:

_____________________________________________________________
[ArgumentException: Object must be of type Byte.]
System.Byte.CompareTo(Object value) +128
System.Collections.Comparer.Compare(Object a, Object b) +150
System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer) +261

[InvalidOperationException: Specified IComparer threw an exception.]
System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer) +322
System.Collections.SortedList.IndexOfKey(Object key) +29
System.Collections.SortedList.get_Item(Object key) +9
n.a(Int32 A_0)
Aspose.Excel.Cell.a(b4 A_0, FileFormatType A_1)
Aspose.Excel.Cells.d(b4 A_0, FileFormatType A_1)
Aspose.Excel.Worksheet.c(b4 A_0)
Aspose.Excel.Worksheets.d(b4 A_0)
Aspose.Excel.Worksheets.a(String A_0, SaveType A_1, FileFormatType A_2, HttpResponse A_3)




#2

Please download fix 1.8.5 and have a try.


#3

Laurence, thanks for the quick turnaround. It’s all working fine now.

– Josh