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?