0

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.

d51
  • 316
  • 1
  • 6
  • 23
  • 1
    I could be mistaken as I am not that familiar with NPOI, however, after a minor search, it appears that NPOI does NOT support an “Insert Column” type feature. From what I could see the code that added a column had to loop through the rows and add a cell in the new columns place. Are you stuck with using NPOI? ... I know EPPLus does have a simple “Insert Column” feature. – JohnG Jan 20 '22 at 08:39
  • @JohnG Thank you for the suggestion! I have decided to use both NPOI and EPPlus together. – d51 Jan 20 '22 at 23:00

1 Answers1

-1

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

TheNa2rat
  • 1
  • 3
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 20 '22 at 12:12