├── .github
└── workflows
│ └── gitleaks.yaml
├── Apply-built-in-table-style
├── Console-App-.NET-Core
│ ├── Apply-built-in-table-style.sln
│ └── Apply-built-in-table-style
│ │ ├── Apply-built-in-table-style.csproj
│ │ ├── Program.cs
│ │ └── Suppliers.xml
└── Images
│ └── Built-in-table-style.png
├── Copy-table-styles
├── Console-App-.NET-Core
│ ├── Copy-table-styles.sln
│ └── Copy-table-styles
│ │ ├── Copy-table-styles.csproj
│ │ ├── Program.cs
│ │ ├── Table.docx
│ │ └── TableStyles.docx
└── Images
│ └── Table-style-copied-from-another-document.png
├── Create-new-custom-table-style
├── Console-App-.NET-Core
│ ├── Create-new-custom-table-style.sln
│ └── Create-new-custom-table-style
│ │ ├── Create-new-custom-table-style.csproj
│ │ ├── Program.cs
│ │ └── Table.docx
└── Images
│ └── Custom-table-style.png
├── Modify-existing-table-style
├── Console-App-.NET-Core
│ ├── Modify-existing-table-style.sln
│ └── Modify-existing-table-style
│ │ ├── Modify-existing-table-style.csproj
│ │ ├── Program.cs
│ │ └── Table.docx
└── Images
│ └── Modified-table-style.png
└── README.md
/.github/workflows/gitleaks.yaml:
--------------------------------------------------------------------------------
1 | name: Secret Value found!!
2 | on:
3 | push:
4 | public:
5 | jobs:
6 | scan:
7 | name: gitleaks
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v3
12 | - name: Install the gitleaks
13 | run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz
14 | shell: pwsh
15 | - name: Extract the tar file
16 | run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz
17 | - name: Generate the report
18 | id: gitleaks
19 | run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json
20 | shell: bash
21 | continue-on-error: true
22 | - name: Setup NuGet.exe
23 | if: steps.gitleaks.outcome != 'success'
24 | uses: nuget/setup-nuget@v1
25 | with:
26 | nuget-version: latest
27 | - name: Install the dotnet
28 | if: steps.gitleaks.outcome != 'success'
29 | uses: actions/setup-dotnet@v3
30 | with:
31 | dotnet-version: '3.1.x'
32 | - name: Install the report tool packages
33 | if: steps.gitleaks.outcome != 'success'
34 | run: |
35 | nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion
36 | dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1
37 | dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }}
38 | exit 1
--------------------------------------------------------------------------------
/Apply-built-in-table-style/Console-App-.NET-Core/Apply-built-in-table-style.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2000
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apply-built-in-table-style", "Apply-built-in-table-style\Apply-built-in-table-style.csproj", "{00A8C7B3-5E88-48DB-9BD3-A3DDAE35FD19}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {00A8C7B3-5E88-48DB-9BD3-A3DDAE35FD19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {00A8C7B3-5E88-48DB-9BD3-A3DDAE35FD19}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {00A8C7B3-5E88-48DB-9BD3-A3DDAE35FD19}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {00A8C7B3-5E88-48DB-9BD3-A3DDAE35FD19}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DC6E785D-AD9C-428F-814C-47B2B5063F04}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Apply-built-in-table-style/Console-App-.NET-Core/Apply-built-in-table-style/Apply-built-in-table-style.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Apply-built-in-table-style/Console-App-.NET-Core/Apply-built-in-table-style/Program.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.DocIO;
2 | using Syncfusion.DocIO.DLS;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Xml;
7 |
8 | namespace Apply_built_in_table_style
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | //Creates new Word document instance for Word processing
15 | using (WordDocument document = new WordDocument())
16 | {
17 | //Adds a section to the Word document
18 | IWSection section = document.AddSection();
19 | //Sets the page margin
20 | section.PageSetup.Margins.All = 72;
21 | //Adds a paragrah to the section
22 | IWParagraph paragraph = section.AddParagraph();
23 | paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
24 | paragraph.ParagraphFormat.AfterSpacing = 20;
25 | IWTextRange textRange = paragraph.AppendText("Suppliers");
26 | textRange.CharacterFormat.FontSize = 14;
27 | textRange.CharacterFormat.Bold = true;
28 | textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(255, 50, 62, 79);
29 | //Modifies the font size as 10 for default paragraph style
30 | WParagraphStyle style = document.Styles.FindByName("Normal") as WParagraphStyle;
31 | style.CharacterFormat.FontSize = 10;
32 | //Adds a table to the section
33 | WTable table = section.AddTable() as WTable;
34 | table.ResetCells(1, 6);
35 | table[0, 0].Width = 52f;
36 | table[0, 0].AddParagraph().AppendText("Supplier ID");
37 | table[0, 1].Width = 128f;
38 | table[0, 1].AddParagraph().AppendText("Company Name");
39 | table[0, 2].Width = 70f;
40 | table[0, 2].AddParagraph().AppendText("Contact Name");
41 | table[0, 3].Width = 92f;
42 | table[0, 3].AddParagraph().AppendText("Address");
43 | table[0, 4].Width = 66.5f;
44 | table[0, 4].AddParagraph().AppendText("City");
45 | table[0, 5].Width = 56f;
46 | table[0, 5].AddParagraph().AppendText("Country");
47 | //Imports data to the table.
48 | ImportDataToTable(table);
49 | //Applies the built-in table style (Medium Shading 1 Accent 1) to the table
50 | table.ApplyStyle(BuiltinTableStyle.MediumShading1Accent1);
51 | //Saves the file in the given path
52 | Stream docStream = File.Create(Path.GetFullPath(@"Result.docx"));
53 | document.Save(docStream, FormatType.Docx);
54 | docStream.Dispose();
55 | }
56 | }
57 |
58 | ///
59 | /// Imports the data from XML file to the table.
60 | ///
61 | ///
62 | /// reader
63 | /// Unexpected xml tag + reader.LocalName
64 | private static void ImportDataToTable(WTable table)
65 | {
66 | FileStream fs = new FileStream(@"../../../Suppliers.xml", FileMode.Open, FileAccess.Read);
67 | XmlReader reader = XmlReader.Create(fs);
68 | if (reader == null)
69 | throw new Exception("reader");
70 | while (reader.NodeType != XmlNodeType.Element)
71 | reader.Read();
72 | if (reader.LocalName != "SuppliersList")
73 | throw new XmlException("Unexpected xml tag " + reader.LocalName);
74 | reader.Read();
75 | while (reader.NodeType == XmlNodeType.Whitespace)
76 | reader.Read();
77 | while (reader.LocalName != "SuppliersList")
78 | {
79 | if (reader.NodeType == XmlNodeType.Element)
80 | {
81 | switch (reader.LocalName)
82 | {
83 | case "Suppliers":
84 | //Adds new row to the table for importing data from next record.
85 | WTableRow tableRow = table.AddRow(true);
86 | ImportDataToRow(reader, tableRow);
87 | break;
88 | }
89 | }
90 | else
91 | {
92 | reader.Read();
93 | if ((reader.LocalName == "SuppliersList") && reader.NodeType == XmlNodeType.EndElement)
94 | break;
95 | }
96 | }
97 | reader.Dispose();
98 | fs.Dispose();
99 | }
100 | ///
101 | /// Imports the data to the table row.
102 | ///
103 | /// The reader.
104 | ///
105 | /// reader
106 | /// Unexpected xml tag + reader.LocalName
107 | private static void ImportDataToRow(XmlReader reader, WTableRow tableRow)
108 | {
109 | if (reader == null)
110 | throw new Exception("reader");
111 | while (reader.NodeType != XmlNodeType.Element)
112 | reader.Read();
113 | if (reader.LocalName != "Suppliers")
114 | throw new XmlException("Unexpected xml tag " + reader.LocalName);
115 | reader.Read();
116 | while (reader.NodeType == XmlNodeType.Whitespace)
117 | reader.Read();
118 | while (reader.LocalName != "Suppliers")
119 | {
120 | if (reader.NodeType == XmlNodeType.Element)
121 | {
122 | switch (reader.LocalName)
123 | {
124 | case "SupplierID":
125 | tableRow.Cells[0].AddParagraph().AppendText(reader.ReadElementContentAsString());
126 | break;
127 | case "CompanyName":
128 | tableRow.Cells[1].AddParagraph().AppendText(reader.ReadElementContentAsString());
129 | break;
130 | case "ContactName":
131 | tableRow.Cells[2].AddParagraph().AppendText(reader.ReadElementContentAsString());
132 | break;
133 | case "Address":
134 | tableRow.Cells[3].AddParagraph().AppendText(reader.ReadElementContentAsString());
135 | break;
136 | case "City":
137 | tableRow.Cells[4].AddParagraph().AppendText(reader.ReadElementContentAsString());
138 | break;
139 | case "Country":
140 | tableRow.Cells[5].AddParagraph().AppendText(reader.ReadElementContentAsString());
141 | break;
142 | default:
143 | reader.Skip();
144 | break;
145 | }
146 | }
147 | else
148 | {
149 | reader.Read();
150 | if ((reader.LocalName == "Suppliers") && reader.NodeType == XmlNodeType.EndElement)
151 | break;
152 | }
153 | }
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/Apply-built-in-table-style/Console-App-.NET-Core/Apply-built-in-table-style/Suppliers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | Exotic Liquids
6 | Charlotte Cooper
7 | Purchasing Manager
8 | 49 Gilbert St.
9 | London
10 | EC1 4SD
11 | UK
12 | (171) 555-2222
13 |
14 |
15 | 2
16 | New Orleans Cajun Delights
17 | Shelley Burke
18 | Order Administrator
19 | P.O. Box 78934
20 | New Orleans
21 | LA
22 | 70117
23 | USA
24 | (100) 555-4822
25 | #CAJUN.HTM#
26 |
27 |
28 | 3
29 | Grandma Kelly's Homestead
30 | Regina Murphy
31 | Sales Representative
32 | 707 Oxford Rd.
33 | Ann Arbor
34 | MI
35 | 48104
36 | USA
37 | (313) 555-5735
38 | (313) 555-3349
39 |
40 |
41 | 4
42 | Tokyo Traders
43 | Yoshi Nagase
44 | Marketing Manager
45 | 9-8 Sekimai
46 | Musashino-shi
47 | Tokyo
48 | 100
49 | Japan
50 | (03) 3555-5011
51 |
52 |
53 | 5
54 | Cooperativa de Quesos 'Las Cabras'
55 | Antonio del Valle Saavedra
56 | Export Administrator
57 | Calle del Rosal 4
58 | Oviedo
59 | Asturias
60 | 33007
61 | Spain
62 | (98) 598 76 54
63 |
64 |
65 | 6
66 | Mayumi's
67 | Mayumi Ohno
68 | Marketing Representative
69 | 92 Setsuko
70 | Chuo-ku
71 | Osaka
72 | 545
73 | Japan
74 | (06) 431-7877
75 | Mayumi's (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/mayumi.htm#
76 |
77 |
78 | 7
79 | Pavlova, Ltd.
80 | Ian Devling
81 | Marketing Manager
82 | 74 Rose St.
83 | Moonie Ponds
84 | Melbourne
85 | Victoria
86 | 3058
87 | Australia
88 | (03) 444-2343
89 | (03) 444-6588
90 |
91 |
92 | 8
93 | Specialty Biscuits, Ltd.
94 | Peter Wilson
95 | Sales Representative
96 | 29 King's Way
97 | Manchester
98 | M14 GSD
99 | UK
100 | (161) 555-4448
101 |
102 |
103 | 9
104 | PB Knäckebröd AB
105 | Lars Peterson
106 | Sales Agent
107 | Kaloadagatan 13
108 | Göteborg
109 | S-345 67
110 | Sweden
111 | 031-987 65 43
112 | 031-987 65 91
113 |
114 |
115 | 10
116 | Refrescos Americanas LTDA
117 | Carlos Diaz
118 | Marketing Manager
119 | Av. das Americanas 12.890
120 | São Paulo
121 | 5442
122 | Brazil
123 | (11) 555 4640
124 |
125 |
126 | 11
127 | Heli Süßwaren GmbH & Co. KG
128 | Petra Winkler
129 | Sales Manager
130 | Tiergartenstraße 5
131 | Berlin
132 | 10785
133 | Germany
134 | (010) 9984510
135 |
136 |
137 | 12
138 | Plutzer Lebensmittelgroßmärkte AG
139 | Martin Bein
140 | International Marketing Mgr.
141 | Bogenallee 51
142 | Frankfurt
143 | 60439
144 | Germany
145 | (069) 992755
146 | Plutzer (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/plutzer.htm#
147 |
148 |
149 | 13
150 | Nord-Ost-Fisch Handelsgesellschaft mbH
151 | Sven Petersen
152 | Coordinator Foreign Markets
153 | Frahmredder 112a
154 | Cuxhaven
155 | 27478
156 | Germany
157 | (04721) 8713
158 | (04721) 8714
159 |
160 |
161 | 14
162 | Formaggi Fortini s.r.l.
163 | Elio Rossi
164 | Sales Representative
165 | Viale Dante, 75
166 | Ravenna
167 | 48100
168 | Italy
169 | (0544) 60323
170 | (0544) 60603
171 | #FORMAGGI.HTM#
172 |
173 |
174 | 15
175 | Norske Meierier
176 | Beate Vileid
177 | Marketing Manager
178 | Hatlevegen 5
179 | Sandvika
180 | 1320
181 | Norway
182 | (0)2-953010
183 |
184 |
185 | 16
186 | Bigfoot Breweries
187 | Cheryl Saylor
188 | Regional Account Rep.
189 | 3400 - 8th Avenue
190 | Suite 210
191 | Bend
192 | OR
193 | 97101
194 | USA
195 | (503) 555-9931
196 |
197 |
198 | 17
199 | Svensk Sjöföda AB
200 | Michael Björn
201 | Sales Representative
202 | Brovallavägen 231
203 | Stockholm
204 | S-123 45
205 | Sweden
206 | 08-123 45 67
207 |
208 |
209 | 18
210 | Aux joyeux ecclésiastiques
211 | Guylène Nodier
212 | Sales Manager
213 | 203, Rue des Francs-Bourgeois
214 | Paris
215 | 75004
216 | France
217 | (1) 03.83.00.68
218 | (1) 03.83.00.62
219 |
220 |
221 | 19
222 | New England Seafood Cannery
223 | Robb Merchant
224 | Wholesale Account Agent
225 | Order Processing Dept.
226 | 2100 Paul Revere Blvd.
227 | Boston
228 | MA
229 | 02134
230 | USA
231 | (617) 555-3267
232 | (617) 555-3389
233 |
234 |
235 | 20
236 | Leka Trading
237 | Chandra Leka
238 | Owner
239 | 471 Serangoon Loop, Suite #402
240 | Singapore
241 | 0512
242 | Singapore
243 | 555-8787
244 |
245 |
246 | 21
247 | Lyngbysild
248 | Niels Petersen
249 | Sales Manager
250 | Lyngbysild
251 | Fiskebakken 10
252 | Lyngby
253 | 2800
254 | Denmark
255 | 43844108
256 | 43844115
257 |
258 |
259 | 22
260 | Zaanse Snoepfabriek
261 | Dirk Luchte
262 | Accounting Manager
263 | Verkoop
264 | Rijnweg 22
265 | Zaandam
266 | 9999 ZZ
267 | Netherlands
268 | (12345) 1212
269 | (12345) 1210
270 |
271 |
272 | 23
273 | Karkki Oy
274 | Anne Heikkonen
275 | Product Manager
276 | Valtakatu 12
277 | Lappeenranta
278 | 53120
279 | Finland
280 | (953) 10956
281 |
282 |
283 | 24
284 | G'day, Mate
285 | Wendy Mackenzie
286 | Sales Representative
287 | 170 Prince Edward Parade
288 | Hunter's Hill
289 | Sydney
290 | NSW
291 | 2042
292 | Australia
293 | (02) 555-5914
294 | (02) 555-4873
295 | G'day Mate (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/gdaymate.htm#
296 |
297 |
298 | 25
299 | Ma Maison
300 | Jean-Guy Lauzon
301 | Marketing Manager
302 | 2960 Rue St. Laurent
303 | Montréal
304 | Québec
305 | H1J 1C3
306 | Canada
307 | (514) 555-9022
308 |
309 |
310 | 26
311 | Pasta Buttini s.r.l.
312 | Giovanni Giudici
313 | Order Administrator
314 | Via dei Gelsomini, 153
315 | Salerno
316 | 84100
317 | Italy
318 | (089) 6547665
319 | (089) 6547667
320 |
321 |
322 | 27
323 | Escargots Nouveaux
324 | Marie Delamare
325 | Sales Manager
326 | 22, rue H. Voiron
327 | Montceau
328 | 71300
329 | France
330 | 85.57.00.07
331 |
332 |
333 | 28
334 | Gai pâturage
335 | Eliane Noz
336 | Sales Representative
337 | Bat. B
338 | 3, rue des Alpes
339 | Annecy
340 | 74000
341 | France
342 | 38.76.98.06
343 | 38.76.98.58
344 |
345 |
346 | 29
347 | Forêts d'érables
348 | Chantal Goulet
349 | Accounting Manager
350 | 148 rue Chasseur
351 | Ste-Hyacinthe
352 | Québec
353 | J2S 7S8
354 | Canada
355 | (514) 555-2955
356 | (514) 555-2921
357 |
358 |
--------------------------------------------------------------------------------
/Apply-built-in-table-style/Images/Built-in-table-style.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Apply-built-in-table-style/Images/Built-in-table-style.png
--------------------------------------------------------------------------------
/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2000
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Copy-table-styles", "Copy-table-styles\Copy-table-styles.csproj", "{26C4739F-5F5D-4D33-958C-45D78B1A29BB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {26C4739F-5F5D-4D33-958C-45D78B1A29BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {26C4739F-5F5D-4D33-958C-45D78B1A29BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {26C4739F-5F5D-4D33-958C-45D78B1A29BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {26C4739F-5F5D-4D33-958C-45D78B1A29BB}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {003C2733-664E-42D2-8455-4FBEE42EF0FF}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/Copy-table-styles.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/Program.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.DocIO;
2 | using Syncfusion.DocIO.DLS;
3 | using System;
4 | using System.IO;
5 |
6 | namespace Copy_table_styles
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | //Creates new Word document instance for Word processing
13 | using (WordDocument document = new WordDocument())
14 | {
15 | //Opens the input Word document
16 | Stream docStream = File.OpenRead(Path.GetFullPath(@"../../../Table.docx"));
17 | document.Open(docStream, FormatType.Docx);
18 | docStream.Dispose();
19 | //Opens the source Word document containing table style definition
20 | WordDocument srcDocument = new WordDocument();
21 | docStream = File.OpenRead(Path.GetFullPath(@"../../../TableStyles.docx"));
22 | srcDocument.Open(docStream, FormatType.Docx);
23 | docStream.Dispose();
24 | //Gets the table style (CustomStyle) from the styles collection
25 | WTableStyle srcTableStyle = srcDocument.Styles.FindByName("CustomStyle", StyleType.TableStyle) as WTableStyle;
26 | //Creates a cloned copy of table style
27 | WTableStyle clonedTableStyle = srcTableStyle.Clone() as WTableStyle;
28 | //Adds the cloned copy of source table style to the destination document
29 | document.Styles.Add(clonedTableStyle);
30 | //Releases the resources of source Word document instance
31 | srcDocument.Dispose();
32 | //Gets table to apply style
33 | WTable table = (WTable)document.LastSection.Tables[0];
34 | //Applies the custom table style to the table
35 | table.ApplyStyle("CustomStyle");
36 | //Saves the file in the given path
37 | docStream = File.Create(Path.GetFullPath(@"Result.docx"));
38 | document.Save(docStream, FormatType.Docx);
39 | docStream.Dispose();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/Table.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/Table.docx
--------------------------------------------------------------------------------
/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/TableStyles.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Copy-table-styles/Console-App-.NET-Core/Copy-table-styles/TableStyles.docx
--------------------------------------------------------------------------------
/Copy-table-styles/Images/Table-style-copied-from-another-document.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Copy-table-styles/Images/Table-style-copied-from-another-document.png
--------------------------------------------------------------------------------
/Create-new-custom-table-style/Console-App-.NET-Core/Create-new-custom-table-style.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2000
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-new-custom-table-style", "Create-new-custom-table-style\Create-new-custom-table-style.csproj", "{2B717C33-8B3F-4365-89A3-0FF9C1C58250}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2B717C33-8B3F-4365-89A3-0FF9C1C58250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2B717C33-8B3F-4365-89A3-0FF9C1C58250}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2B717C33-8B3F-4365-89A3-0FF9C1C58250}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2B717C33-8B3F-4365-89A3-0FF9C1C58250}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {3F5E03CC-9286-4C05-B184-D55EEB20ECD5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Create-new-custom-table-style/Console-App-.NET-Core/Create-new-custom-table-style/Create-new-custom-table-style.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Create-new-custom-table-style/Console-App-.NET-Core/Create-new-custom-table-style/Program.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.DocIO;
2 | using Syncfusion.DocIO.DLS;
3 | using System;
4 | using System.IO;
5 |
6 | namespace Create_new_custom_table_style
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | //Creates new Word document instance for Word processing
13 | WordDocument document = new WordDocument();
14 | //Opens the input Word document
15 | Stream docStream = File.OpenRead(Path.GetFullPath(@"../../../Table.docx"));
16 | document.Open(docStream, FormatType.Docx);
17 | docStream.Dispose();
18 | //Adds a new custom table style
19 | WTableStyle tableStyle = document.AddTableStyle("CustomStyle") as WTableStyle;
20 | //Applies formatting for whole table
21 | tableStyle.TableProperties.RowStripe = 1;
22 | tableStyle.TableProperties.ColumnStripe = 1;
23 | tableStyle.TableProperties.Paddings.Top = 0;
24 | tableStyle.TableProperties.Paddings.Bottom = 0;
25 | tableStyle.TableProperties.Paddings.Left = 5.4f;
26 | tableStyle.TableProperties.Paddings.Right = 5.4f;
27 | //Applies conditional formatting for first row
28 | ConditionalFormattingStyle firstRowStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow);
29 | firstRowStyle.CharacterFormat.Bold = true;
30 | firstRowStyle.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(255, 255, 255, 255);
31 | firstRowStyle.CellProperties.BackColor = Syncfusion.Drawing.Color.Blue;
32 | //Applies conditional formatting for first column
33 | ConditionalFormattingStyle firstColumnStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn);
34 | firstColumnStyle.CharacterFormat.Bold = true;
35 | //Applies conditional formatting for odd row
36 | ConditionalFormattingStyle oddRowBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding);
37 | oddRowBandingStyle.CellProperties.BackColor = Syncfusion.Drawing.Color.WhiteSmoke;
38 | //Gets table to apply style
39 | WTable table = (WTable)document.LastSection.Tables[0];
40 | //Applies the custom table style to the table
41 | table.ApplyStyle("CustomStyle");
42 | //Saves the file in the given path
43 | docStream = File.Create(Path.GetFullPath(@"Result.docx"));
44 | document.Save(docStream, FormatType.Docx);
45 | docStream.Dispose();
46 | //Releases the resources of Word document instance
47 | document.Dispose();
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Create-new-custom-table-style/Console-App-.NET-Core/Create-new-custom-table-style/Table.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Create-new-custom-table-style/Console-App-.NET-Core/Create-new-custom-table-style/Table.docx
--------------------------------------------------------------------------------
/Create-new-custom-table-style/Images/Custom-table-style.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Create-new-custom-table-style/Images/Custom-table-style.png
--------------------------------------------------------------------------------
/Modify-existing-table-style/Console-App-.NET-Core/Modify-existing-table-style.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2000
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modify-existing-table-style", "Modify-existing-table-style\Modify-existing-table-style.csproj", "{9F554FBC-64E5-4EF7-9E47-727D9F2B5B96}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9F554FBC-64E5-4EF7-9E47-727D9F2B5B96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9F554FBC-64E5-4EF7-9E47-727D9F2B5B96}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9F554FBC-64E5-4EF7-9E47-727D9F2B5B96}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9F554FBC-64E5-4EF7-9E47-727D9F2B5B96}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {17A927C5-45A0-4CA1-B5E4-44594F1AB4F2}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Modify-existing-table-style/Console-App-.NET-Core/Modify-existing-table-style/Modify-existing-table-style.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Modify-existing-table-style/Console-App-.NET-Core/Modify-existing-table-style/Program.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.DocIO;
2 | using Syncfusion.DocIO.DLS;
3 | using System;
4 | using System.IO;
5 |
6 | namespace Modify_existing_table_style
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | //Creates new Word document instance for Word processing
13 | using (WordDocument document = new WordDocument())
14 | {
15 | //Opens the input Word document
16 | Stream docStream = File.OpenRead(Path.GetFullPath(@"../../../Table.docx"));
17 | document.Open(docStream, FormatType.Docx);
18 | docStream.Dispose();
19 | //Gets the table style (Medium Shading 1 Accent 1) from the styles collection
20 | WTableStyle tableStyle = document.Styles.FindByName("Medium Shading 1 Accent 1", StyleType.TableStyle) as WTableStyle;
21 | //Gets the conditional formatting style of the first row (table headers) from the table style
22 | ConditionalFormattingStyle firstRowStyle = tableStyle.ConditionalFormattingStyles[ConditionalFormattingType.FirstRow];
23 | if (firstRowStyle != null)
24 | {
25 | //Modifies the background color for first row (table headers)
26 | firstRowStyle.CellProperties.BackColor = Syncfusion.Drawing.Color.FromArgb(255, 31, 56, 100);
27 | }
28 | //Saves the file in the given path
29 | docStream = File.Create(Path.GetFullPath(@"Result.docx"));
30 | document.Save(docStream, FormatType.Docx);
31 | docStream.Dispose();
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Modify-existing-table-style/Console-App-.NET-Core/Modify-existing-table-style/Table.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Modify-existing-table-style/Console-App-.NET-Core/Modify-existing-table-style/Table.docx
--------------------------------------------------------------------------------
/Modify-existing-table-style/Images/Modified-table-style.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyncfusionExamples/Word-Table-Examples/906a7fdc85a2f3b21c2d56461b27b4326ab70b4f/Modify-existing-table-style/Images/Modified-table-style.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Word table examples
2 |
3 | This repository contains examples that illustrates how to create, edit, format, and delete tables in Word documents programmatically in C# and VB.NET using Syncfusion® [.NET Word library](https://www.syncfusion.com/document-processing/word-framework/net/word-library?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) (Essential® DocIO) without Microsoft Word or Office interop dependencies.
4 |
5 | # Tables in Word documents
6 |
7 | You can create, edit, and format simple and nested tables in a Word document. Polish the appearance of tables by applying table styles and conditional formats.
8 |
9 | The Syncfusion® [Word library](https://www.syncfusion.com/document-processing/word-framework/net/word-library?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) (Essential® DocIO) provides comprehensive APIs to create, edit, format, and delete both simple and nested tables in Word documents programmatically in C# and VB.NET. It allows you to customize look of the tables by merging cells, adding or deleting columns or rows, or applying borders, enabling or disabling header rows to repeat on each page or row to break across pages. It generates professional reports with tabular data faster in a batch process without Microsoft Word or Office interop dependencies. The generated reports can be saved as a Word document, PDF, image, HTML, and more.
10 |
11 | # Key Features
12 |
13 | - [Apply built-in table style in C#](Apply-built-in-table-style/) - Apply built-in table style to a table in Word document.
14 | - [Modify an existing table style in C#](Modify-existing-table-style/) - Access an existing table style from a Word document and modify its properties.
15 | - [Create new custom table style in C#](Create-new-custom-table-style/) - Create new custom table style and apply to a table in Word document.
16 | - [Copy table styles in C#](Copy-table-styles/) - Copy table styles from one Word document to another.
17 |
18 | # Screenshots
19 |
20 | **Built-in table style**
21 |
22 |
23 |
24 |
25 |
26 | **Custom table style**
27 |
28 |
29 |
30 |
31 |
32 | ## Syncfusion® .NET Word Library
33 | The Syncfusion® DocIO is a [.NET Word library](https://www.syncfusion.com/document-processing/word-framework/net/word-library?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) allows you to add advanced Word document processing functionalities to any .NET application and does not require Microsoft Word application to be installed in the machine. It is a non-UI component that provides a full-fledged document instance model similar to the Microsoft Office COM libraries to iterate with the document elements explicitly and perform necessary manipulation.
34 |
35 | Take a moment to peruse the [documentation](https://help.syncfusion.com/file-formats/docio/getting-started?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), where you can find basic Word document processing options along with the features like [mail merge](https://help.syncfusion.com/file-formats/docio/working-with-mail-merge?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [merge](https://help.syncfusion.com/file-formats/docio/word-document/merging-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [split](https://help.syncfusion.com/file-formats/docio/word-document/split-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) and [compare documents](https://help.syncfusion.com/file-formats/docio/word-document/compare-word-documents?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [find and replace](https://help.syncfusion.com/file-formats/docio/working-with-find-and-replace?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) text in the Word document, [protect](https://help.syncfusion.com/file-formats/docio/working-with-security?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) the Word documents, and most importantly, the [PDF](https://help.syncfusion.com/file-formats/docio/word-to-pdf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) and [Image](https://help.syncfusion.com/file-formats/docio/word-to-image?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) conversions with code examples.
36 |
37 | Compatible Microsoft Word Versions
38 | ----------------------------------
39 |
40 | * Microsoft Word 97-2003
41 | * Microsoft Word 2007
42 | * Microsoft Word 2010
43 | * Microsoft Word 2013
44 | * Microsoft Word 2016
45 | * Microsoft Word 2019
46 | * Microsoft 365
47 |
48 | Supported File Formats
49 | ----------------------
50 |
51 | * Creates, reads, and edits popular text file formats like [DOC](https://help.syncfusion.com/file-formats/docio/word-file-formats?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples#doc-to-docx-and-docx-to-doc), DOT, [DOCM](https://help.syncfusion.com/file-formats/docio/word-file-formats?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples#macros), DOTM, [DOCX](https://help.syncfusion.com/file-formats/docio/word-file-formats?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples#doc-to-docx-and-docx-to-doc), [DOTX](https://help.syncfusion.com/file-formats/docio/word-file-formats?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples#templates), [HTML](https://help.syncfusion.com/file-formats/docio/html?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [RTF](https://help.syncfusion.com/file-formats/docio/rtf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [TXT](https://help.syncfusion.com/file-formats/docio/text?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [XML (WordML)](https://help.syncfusion.com/file-formats/docio/word-file-formats#word-processing-xml-xml?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples).
52 | * Converts Word documents also to [PDF](https://help.syncfusion.com/file-formats/docio/word-to-pdf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), [Image](https://help.syncfusion.com/file-formats/docio/word-to-image?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples), and [ODT](https://help.syncfusion.com/file-formats/docio/word-to-odt?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) files.
53 |
54 | ## How to run the examples
55 | - Download this project to a location in your disk.
56 | - Open the solution file using Visual Studio.
57 | - Rebuild the solution to install the required NuGet packages.
58 | - Run the application.
59 |
60 | ## Resources
61 |
62 | - **Product page:** [Syncfusion® Word Framework](https://www.syncfusion.com/document-processing/word-framework/net?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)
63 | - **Documentation:** [Tables in Word document using Syncfusion® Word library](https://help.syncfusion.com/file-formats/docio/working-with-tables?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)
64 | - **GitHub Examples:** [Syncfusion® Word library examples](https://github.com/SyncfusionExamples/DocIO-Examples?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)
65 | - **Online demo:** [Syncfusion® Word library - Online demos](https://ej2.syncfusion.com/aspnetcore/DocIO/SalesInvoice?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples)
66 |
67 | ## Support and feedback
68 | For any other queries, reach our [Syncfusion® support team](https://support.syncfusion.com/?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) or post the queries through the [community forums](https://www.syncfusion.com/forums?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples).
69 |
70 | Request new feature through [Syncfusion® feedback portal](https://www.syncfusion.com/feedback?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples).
71 |
72 | ## License
73 | This is a commercial product and requires a paid license for possession or use. Syncfusion's licensed software, including this component, is subject to the terms and conditions of [Syncfusion's EULA](https://www.syncfusion.com/license/studio/22.2.5/syncfusion_essential_studio_eula.pdf?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples). You can purchase a licnense [here](https://www.syncfusion.com/sales/products?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples) or start a free 30-day trial [here](https://www.syncfusion.com/account/manage-trials/start-trials?utm_source=github&utm_medium=listing&utm_campaign=github-docio-examples).
74 |
75 |
--------------------------------------------------------------------------------