Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

Wed Nov 07, 2012 4:24 pm

Hello i am using spire.XLS 6.9 and I was hoping that someone could help point me in the right direction while trying to add new columns and rows to a new worksheet. Currently I am trying the workbook.worksheets[0].InsertColumn(1) and workbook.worksheets[0].InsertRows(1) methods but they do not seem to add anything at all. I ran into a similar problem while trying to add a column to the end of an existing worksheet (workbook.worksheets[0].InsertColumn(5)). Any help is appreciated.

ClickPointSoftware
 
Posts: 1
Joined: Thu Oct 18, 2012 2:56 am

Thu Nov 08, 2012 3:16 am

Hi ClickPointSoftware,

Thanks for your inquiry.
We have done some tests, but we don't reproduce your problems. We use code1 to add a new row and a new column to a worksheet of a xlsx file, and use code2 to add a new column to the end of a worksheet of a xlsx file. We attach some sreenshots of original xlsx file and the result xlsx files. If we miss something, please tell us.
code1:
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("original.xlsx");
            Worksheet worksheet=workbook.Worksheets[0];
            worksheet.InsertRow(1);
            worksheet.InsertColumn(1);
            workbook.SaveToFile("addNewRowAndNewColumn.xlsx", ExcelVersion.Version2007);


code2:
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("original.xlsx");
            Worksheet worksheet=workbook.Worksheets[0];
            worksheet.InsertColumn(5);
            workbook.SaveToFile("addNewColumnToTheEnd.xlsx", ExcelVersion.Version2007);


Best regards,
Amy
E-iceblue support
Attachments
addNewColumnToTheEnd.PNG
addNewColumnToTheEnd.PNG (4.02 KiB) Viewed 2804 times
addNewRowAndNewColumn.PNG
addNewRowAndNewColumn.PNG (4.09 KiB) Viewed 2804 times
original.PNG
original.PNG (3.89 KiB) Viewed 2804 times
User avatar

amy.zhao
 
Posts: 2328
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS