Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-02-2019, 01:25 AM
shahid.majeed shahid.majeed is offline Apply table style Windows 10 Apply table style Office 2013
Novice
Apply table style
 
Join Date: Sep 2019
Posts: 4
shahid.majeed is on a distinguished road
Default Apply table style


Hi,
I am new to openxml sdk did not have deep knowledge yet. However what i am trying to do is to create a table with 3 columns and want a special formating for the text inside the table.

I successfully create the table and text in the table cell coming from my database.

However i dont know how to apply style to the table. Write know table follow the default font name, size and colour.

I want table font name should "Arial" size should be 11 and colour should be in RGB 20,50,55.

Can some body help with my code

Code:
                    var res = from bm in wordDoc.MainDocumentPart.Document.Body.Descendants<BookmarkStart>() where bm.Name == "SchedulerTable" select bm;
                    var bookmark = res.First();
                    var parent = bookmark.Parent;
                    DocumentFormat.OpenXml.Wordprocessing.Table table = new DocumentFormat.OpenXml.Wordprocessing.Table();
                    DocumentFormat.OpenXml.Wordprocessing.TableRow tr;
                    DocumentFormat.OpenXml.Wordprocessing.TableCell EventText;
                    DocumentFormat.OpenXml.Wordprocessing.TableCell EventTime;
                    DocumentFormat.OpenXml.Wordprocessing.TableCell EventFreeText;

                    foreach (DataRow row in activeRows)
                    {
                        tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
                        EventText = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                        EventTime = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                        EventFreeText = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                        EventText.Append(new Paragraph(new Run(new Text(row.ItemArray[1].ToString()))));
                        EventTime.Append(new Paragraph(new Run(new Text(row.ItemArray[2].ToString()))));
                        EventFreeText.Append(new Paragraph(new Run(new Text(row.ItemArray[3].ToString()))));
                        tr.Append(EventText);
                        tr.Append(EventTime);
                        tr.Append(EventFreeText);
                        table.Append(tr);
                    }
                    parent.InsertAfterSelf(table);
Thanks in advance
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to apply a style between quotations WVA Word VBA 6 07-30-2019 11:13 AM
My style keeps changing, can't get saved style to apply Meenie50 Word 7 07-20-2017 03:47 PM
Apply table style Apply Table Style without Table functions? dylansmith Excel 4 04-03-2017 10:53 AM
Apply table style how to apply table style WITHOUT setting it as a table? dylansmith Excel 9 05-16-2014 07:25 PM
Apply table style Can I apply a style to an image? humbleosity Word 1 01-14-2014 09:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft