0

I have a table in an excel document (.xlsx), which serves as a report template. I'd like to create a specific number of new rows in that template, at a specific row index, and also copy the format/style of the row before the new rows.

I tried various combination of the ShiftRows() method:

sheet.ShiftRows(18, 20, 1); // this inserts one empty line, but doesn't copy the format of the line between 18 and 20. 

As I understand this function, the line 19, which is between 18 and 20, should be copied and moved 1x down, but the format of line 19 is not copied. However, if I execute the following snippet, it doesn't create three new rows:

sheet.ShiftRows(18, 20, 1);
sheet.ShiftRows(18, 20, 1);
sheet.ShiftRows(18, 20, 1);

The following snippet creates three new lines, but doesn't copy the format of the shifted row:

sheet.ShiftRows(18, 20, 3);

Would anybody know how this should be handled?

TheAptKid
  • 1,559
  • 3
  • 25
  • 47

1 Answers1

0

please check the link How to insert a row between two rows in an existing excel with HSSF (Apache POI) . Although code explained for is for POI library but all functionality of NPOI and POI are common for HSSF and XSSF.

kumar chandraketu
  • 2,232
  • 2
  • 20
  • 25