Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Feb 09, 2022 8:55 pm

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index" when loading an .xlsb file from stream

My function:
public Stream ConvertToXlsx(Stream fileStream)
{
//Spire
using (var wb=new Workbook())
{
wb.LoadFromStream(fileStream); // <== this throws the exception
var stream = new MemoryStream();
wb.SaveToStream(stream,FileFormat.Version2016);
stream.Position = 0;
return stream;
}

}

StackTrace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +12711433
sprṎ.ᜀ(Int32 A_0) +60
sprℰ.ᜃ(StringBuilder A_0, Byte[] A_1, Int32 A_2) +212
sprℰ.ᜀ(Int32 A_0, Int32 A_1, Byte[] A_2, Int32 A_3, Int32 A_4, Boolean A_5) +4398
sprṍ.ᜍ() +62
spr⊴.ᜂ() +353
spr⊴.ᜀ(spr⊟ A_0, spr᪴ A_1) +214
spr⊬.ᜃ() +486
sprṮ.ᜀ(Stream A_0, sprḌ A_1, Boolean A_2) +743
sprṮ..ctor(Stream A_0, sprḌ A_1) +306
Spire.Xls.Core.Spreadsheet.XlsWorkbook..ctor(Object A_0, Stream A_1) +125
Spire.Xls.Workbook.LoadFromStream(Stream stream) +71

File that causes the error is an perfeclty valid spreadsheet, included in attachments
Attachments
Sample.7z
file that causes exception
(474.02 KiB) Downloaded 129 times

sacalata
 
Posts: 1
Joined: Wed Feb 09, 2022 6:34 pm

Thu Feb 10, 2022 2:38 am

Hello,

Thanks for your inquiry.
I tested the file you provided and did reproduce the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREXLS-3680. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Fri Apr 15, 2022 9:50 am

Hello,

Thanks for your patience.
Glad to inform you that we just released Spire.XLS Pack(Hotfix) Version:12.4.1, which fixes the issue of SPIREXLS-3680. Please download the new version from the following links for testing.

Website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
NuGet link: https://www.nuget.org/packages/Spire.XLS/12.4.1

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS