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.

Thu Sep 20, 2018 7:29 pm

Running Spire.XLS 8.9.3

I have the following code which pulls Excel files from a list of Workbooks:

Code: Select all
 
                    workbook = new Workbook();
                    workbook.LoadFromStream(workbooks[0]); // load first document

                    // load all other documents into the original
                    for (int i = 1; i < workbooks.Count; i++)
                    {
                        Workbook b = new Workbook();
                        b.LoadFromStream(workbooks[i]);

                        workbook.Worksheets.AddCopy(b.Worksheets);
                    }


This gives me the following exception:
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at spr⋥.ᜁ(String A_0, String A_1)
at Spire.Xls.Core.Spreadsheet.Collections.XlsFontsCollection.ᜀ(XlsFont A_0)
at Spire.Xls.Core.Spreadsheet.Collections.XlsFontsCollection.AddRange(XlsFontsCollection fonts)
at sprᡌ.ᜀ(IList`1 A_0, Dictionary`2& A_1)
at Spire.Xls.Core.Spreadsheet.Collections.XlsStylesCollection.ᜀ(IWorkbook A_0, StyleMergeType A_1, Dictionary`2& A_2, Dictionary`2& A_3)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.AddCopy(IWorksheets worksheets, WorksheetCopyType flags)
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.AddCopy(IWorksheets worksheets)
at Spire.Xls.Collections.WorksheetsCollection.AddCopy(WorksheetsCollection sheets)


This was working at some point, but now I am at a loss as to what the problem is.

I tried the following but it did not help.
Code: Select all
workbook.Worksheets.AddCopy(b.Worksheets, false);


Please advise.

dylanvdmerwe
 
Posts: 4
Joined: Mon May 15, 2017 11:13 am

Fri Sep 21, 2018 3:40 am

Hello,

Thanks for your inquiry.
After an initial test, I didn't reproduce the issue you mentioned. To help us further investigate your issue, please provide the Excel files you used. You could send them to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS