I have template.xlsx file which I must modify by adding a few copies of one row in specific index. When I try use clone method for this operation I add a row but each row modify each other. I need to create deep clone of opemxml row object but when I try this I have an error that openxml row object are not serialized. How can I deep clone row in .xlsx file using openXML with serialization or if there is another way to deep clone openxml row object?
You can deep clone using .CloneNode(true) on an OpenXmlElement
So if you want to duplicate a row inside a table it will look like
// suppose table an OpenXml Table and row the row you want to clone
table.Append(row.CloneNode(true));
edit : to insert it before a specific row
// suppose r is the row you want to insert it before
r.InsertBeforeSelf(row.CloneNode(true));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With