There are various options to build a word document in your C# code, I choose the lightweight docx nuget package. There are some really good examples on the Codeplex website of docx http://docx.codeplex.com/ if you look at the “Advanced Examples”
The thing is that Office products tend to localize variables such as table designs:
I am dutch, but I cannot translate it to a value of the enum `TableDesign`
If I would translate it, it would be something like listtable 7 colorful accent 6. It is still (even after this test file) not a valid entry of the table design enumeration.
using (DocX document = DocX.Create("C:/Temp/tables.docx")) { foreach (TableDesign td in (TableDesign[])Enum.GetValues(typeof(TableDesign))) { Table aTable = document.InsertTable(5, 5); // because office preview is also 5 x 5 aTable.Design = td; aTable.Rows[0].Cells[0].Paragraphs.First().Append(td.ToString()); } document.Save(); }
The “source” (all 6 lines of code, lol) is available on github https://github.com/jphellemons/DocxTables but perhaps more important is the output file. This might save you some time. https://github.com/jphellemons/DocxTables/raw/master/tables.docx
Good luck with this small, but awesome nuget package!