#1
|
|||
|
|||
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); |
|
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 without Table functions? | dylansmith | Excel | 4 | 04-03-2017 10:53 AM |
how to apply table style WITHOUT setting it as a table? | dylansmith | Excel | 9 | 05-16-2014 07:25 PM |
Can I apply a style to an image? | humbleosity | Word | 1 | 01-14-2014 09:38 AM |