Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Thu Feb 20, 2014 3:08 pm
Probably a simple question, but what is the fastest way to copy a row, including formatting and contents in a table?
I have a table for which I want to duplicate the last row in code.
-
flexlogic
-
- Posts: 2
- Joined: Mon Jan 07, 2013 6:35 pm
Thu Feb 20, 2014 5:16 pm
A bit more testing gave me the following solution;
r is a TableRow containing the row to be copied;
insertPosition the position where the new row should end up;
t.Rows.Insert(insertPosition, r.Clone());
CurrentRow = t.Rows[insertPosition];
CurrentRow now holds the copied row, ready for processing.
Hans
-
flexlogic
-
- Posts: 2
- Joined: Mon Jan 07, 2013 6:35 pm
Fri Feb 21, 2014 2:20 am
Dear Hans,
Thanks for further research.
You could also try the following solution to do it.
- Code: Select all
TableRow lastRow= table.Rows[table.Rows.Count - 1];
TableRow newRow = lastRow.Clone();
Welcome to write to us again for further inquiry.
Best wishes,
Amy
E-iceblue support team
-
amy.zhao
-
- Posts: 2766
- Joined: Wed Jun 27, 2012 8:50 am