前面我们介绍了如何使用spire.xls ,该文将主要介绍如何使用spire.xls插入或删除隐藏excel工作表中的行与列。
首先,请查看示例文档:
添加excel工作表中的行与列
spire.xls提供了 insertrow(int rowindex) 和 insertcolumn(int columnindex) 方法来添加行与列。
c#
workbook workbook = new workbook();
workbook.loadfromfile("sample.xlsx");
worksheet sheet = workbook.worksheets[0];
sheet.insertrow(3);
sheet.insertcolumn(3);
workbook.savetofile("result2.xlsx", excelversion.version2010);
vb.net
dim workbook as new workbook()
workbook.loadfromfile("sample.xlsx")
dim sheet as worksheet = workbook.worksheets(0)
sheet.insertrow(3)
sheet.insertcolumn(3)
workbook.savetofile("result2.xlsx", excelversion.version2010)
删除excel工作表中的行与列
spire.xls提供了 deleterow(int rowindex) 和 deletecolumn(int columnindex) 方法来添加行与列。
c#
workbook workbook = new workbook();
workbook.loadfromfile("sample.xlsx");
worksheet sheet = workbook.worksheets[0];
sheet.deleterow(12);
sheet.deletecolumn(3);
workbook.savetofile("result.xlsx", excelversion.version2010);
vb.net
dim workbook as new workbook()
workbook.loadfromfile("sample.xlsx")
dim sheet as worksheet = workbook.worksheets(0)
sheet.deleterow(12)
sheet.deletecolumn(3)
workbook.savetofile("result.xlsx", excelversion.version2010)