Excel : insert row before existing template data
I want to insert data before existing row in my template, is that possible ?
As you can see in the playground, my excel sheet is broken...
Thanks a lot for the help,
The trouble is that you have same indexed rows and cells in the final XML.
This is in your existing xlsx template
<row r="1" spans="1:5" ht="42.75" customHeight="1" x14ac:dyDescent="0.25"> <c r="A1" s="1" t="s"> <v>0</v> </c> ...
And you add
<row r="1"> <c r="D1" t="inlineStr"><is><t>TOTAL:</t></is></c> <c r="E1" t="str"><f>45</f></c> </row>
So in the end, there is row 1 duplicated.
You could delete the row and add it after you add a new row.
Thanks a lot for your quick reply. Your code works for simple case.
On our side, we want to create a template with 4 or 5 tables containing a header, but no data.
The script should insert dynamically data in the tables.
Prerequired : we do not know how many rows each table will have before the generation.
My question is more on how we could insert row (as we can do in Excel), and not add row.
I hope to be clear enough.
we could insert row (as we can do in Excel), and not add row.
Unfortunately, I don't understand this. Please try to elaborate more.
Sorry for my english.
Let's say that we have data in row 1 to 3 (r1old, r2old, r3old).
We want to create a new first row r1new and move the old rows like this :
r1 -> r1new
r2 -> r1old
r3 -> r2old
r4 -> r3old
Is that possible ?
Hopefully, this is understandable.
I see. As I mentioned, there is trouble with naming rows and cells as excel does. You need to update the row/cells numbers in the input template. Check this example, how it could work. It isn't final and you need to shape it to your needs, but I believe you get the idea