This project has moved and is read-only. For the latest updates, please go here.

How to copy table design

Mar 17, 2014 at 11:05 AM
I would like to add a new table after an existing one and use the design of the replacing table.

Every table in the docx has TableDesign.Custom at the design property and when I copy it to a new table the property transforms to None.

Is there any way that I can copy the design from an existing to a new one?
Mar 18, 2014 at 9:13 AM
Can you tell me which method you used to copy table?
I use "docx.InsertTable(table0)",but the source table.Design ==null,it throw exception.
do you realize this?
Mar 18, 2014 at 10:14 AM
No, I don't copy table. I am creating a new under it using the method described in the http://cathalscorner.blogspot.gr/2009/08/docx-v1007-released.html post.

After creating the table I want to copy not the data but the design of the table.
Mar 18, 2014 at 10:21 AM
If you want to use old table design ,you can try to use table0.Design=table1.Design
Mar 18, 2014 at 10:32 AM
This is what I am describing at my initial post when I am writing that 'Every table in the docx has TableDesign.Custom at the the Design property'.
When you create a table at docx using ms-word it doesn't use a design variable from the enumeration, it just use a Custom variable that later on cannot be used to describe the table design. When I do table0.Design = table1.Design the table0.Design ends up with TableDesign.None.
Mar 18, 2014 at 10:41 AM
yeah,i debug the source code ,and find it .
if (design == TableDesign.Custom) {
                if (string.IsNullOrEmpty(_customTableDesignName)) {
                    design = TableDesign.None;
                    if (style != null)
                        style.Remove();

                } else {
                    val.Value = _customTableDesignName;
                }
            } 
Is it must exist a design?
I just want to copy table like this "docx.InsertTable(table0)",
but it throw exception