简体   繁体   中英

How to create a new column when editing an Excel file C# NPOI

I am trying to create a new column in the middle of an existing.xlsx sheet, but I can't find any way to do it.

XSSFWorkbook workbook;
await using (var file = new FileStream(@"File.xlsx", FileMode.Open, FileAccess.Read))
{
    workbook = new XSSFWorkbook(file);
    file.Close();
}
var editSheet = workbook.GetSheetAt(0);
await using (var file = new FileStream(@"File.xlsx", FileMode.Open, FileAccess.Write))
{
    workbook.Write(file);
    file.Close();
}

I am able to easily create a new row using editSheet.CreateRow(2) but I can't find anything similar for creating a column.

I think, that You can operate only just on rows and cells.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM