Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Thu Jan 02, 2020 3:50 am
I want to apply a style to a table ,with it's cells and rows,my style Name is "myCustomStyle",how to apply this style to my table?
-
standheo
-
- Posts: 24
- Joined: Mon Oct 08, 2018 11:13 am
Thu Jan 02, 2020 6:41 am
Hi,
Thanks for your inquiry.
What is your custom style? Is it ParagraphStyle? If so, please refer to following code:
- Code: Select all
Document doc = new Document(filePath + @"20080.docx");
Section sec = doc.Sections[0];
ParagraphStyle style = new ParagraphStyle(doc);
style.Name = "MyCustomStyle";
style.CharacterFormat.FontSize = 20;
style.CharacterFormat.Bold= true;
doc.Styles.Add(style);
Table table = sec.Tables[0] as Table;
foreach(TableRow row in table.Rows )
{
foreach(TableCell cell in row.Cells)
{
foreach(Paragraph par in cell.Paragraphs)
{
par.ApplyStyle("MyCustomStyle");
}
}
}
doc.SaveToFile("T20080.docx");
If not, please share detailed information along with the input file(if any) and the code you used.
Sincerely,
Betsy
E-iceblue support team
-
Betsy.jiang
-
- Posts: 3099
- Joined: Tue Sep 06, 2016 8:30 am
Fri Jan 03, 2020 2:25 am
no,it's a tableStyle,in ms-word,it like the addachment picture,can spire.doc support this "new table style" operation?
Login to view the files attached to this post.
-
standheo
-
- Posts: 24
- Joined: Mon Oct 08, 2018 11:13 am
Fri Jan 03, 2020 3:34 am
Hi,
Thanks for your information.
Sorry that Spire.Doc doesn't support that at present. We will consider adding the new feature in our future upgrade. Once there is any update, we will let you know.
Sincerely,
Betsy
E-iceblue support team
-
Betsy.jiang
-
- Posts: 3099
- Joined: Tue Sep 06, 2016 8:30 am