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 Feb 23, 2012 1:36 pm

I got an exception when I tried to add the fourth sheet to a Workbook, and the exception was saying that
"Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index"

Is it possible to create more than 3 sheets in a Workbook?

leep
 
Posts: 1
Joined: Tue Feb 21, 2012 6:22 am

Fri Feb 24, 2012 3:38 am

Hello leep,

Thanks for evaluating Spire.XLS.

With Spire.XLS, you can create the same amount of worksheets as MS Excel. When you create a workbook using spire.XLS, it includes 3 sheets automatically.But If you have not buy our products license, the workbook will be inserted a warning sheet named “Evaluation Warning". When you open the xls file which has been oprated by Spire.XLS, it always show the warning sheet when you open. Then you can use the code " workbook.CreateEmptySheet()" to add a sheet into workbook, in the parenthese, you can named the worksheet you added. You can also use this code "workbook.CreateEmptySheets(10)" to add multiple sheets one time. After adding a sheet, you can use this code "Worksheet sheet4 = workbook.Worksheets[3]" to get the fourth sheet.

If you still have this question,please feel free to contact us at any time.
Have a great day.

BR
Suvi
e-iceblue support
User avatar

Suvi.Wu
 
Posts: 154
Joined: Thu Oct 20, 2011 2:53 am

Return to Spire.XLS

cron