I am making a program that reads data and writes results in a workbook (.xlsx) made with XlsIO. I need that book with only a sheet. When I write these sentences:
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets.Create("NAME_OF_THE_SHEET");
The book is created, but one additional sheet appears before the sheet named
"NAME_OF_THE_SHEET".
How can I correct this issue? Thanks for your answer.
Hi,
//Here the first worksheet is created
IWorkbook workbook = application.Workbooks.Create(1);
//Here the second worksheet is created
IWorksheet worksheet = workbook.Worksheets.Create("NAME_OF_THE_SHEET");
Because of this, two worksheets have been created, we suggest to use the below mentioned code
for creating a single worksheet.
Code Snippet:
IWorkbook workbook = application.Workbooks.Create(1);
Regards,
Mugil M.
Thanks Mugil for your answer.
I understood that. But, how can I name a worksheet after it has been created? Is it possible?
Best regards,
CARLOS CASTILLO
I try to create a book with only one sheet using these instructions:
IWorkbook workbook = application.Workbooks.Create();
IWorksheet worksheet = workbook.Worksheets.Create("NAME_OF _THE_SHEET");
But, now XlsIO creates 3 empty sheets before sheet named "NAME_OF_THE_SHEET".
I need a book with one named sheet. How can I do that?
Thanks in advance
Hi Carlos,
You can use the IWorksheet.Name property to set the name for the worksheet.
//Access the first worksheet
IWorksheet worksheet = workbook.Worksheets[0];
//Get or set the name of the sheet
worksheet.Name = "NAME_OF_THE_SHEET";
Please refer to the UG for more information about working with excel worksheet.
Regards,
Mugil M.
Thanks Mugil for your answer, but it does not work.
Using the instructions, the sheet named "NAME_OF_THE_SHEET" is created, and 2 empty sheets after the sheet with the name are added.
The version of XlsIO that I am using is 25.1.41.
Thanks for your answer.
CARLOS CASTILLO
After some tests, the right instructions to make a book with a need sheet are as follows:
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "NAME_OF_THE_SHEET";
That's all. Thanks for your help.
CARLOS CASTILLO