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.

Wed Nov 07, 2018 2:34 pm

Hello Support Team,

I have a problem when setting the paragraph style inside a table cell.

Initially I load a word document that contains a style "TableContent" (Arial, 10pt).

Our Application then adds html, that contains table markup, to paragraphs. I would like all cells of the resulting table objects to have the style "TableContent".

Before applying my style, the tables have a generated style like "SpireTableThStylec76db6ce-217c-4488-9d03-614ff9cf784f".
After applying, the style is changed to "TableContent" (Name and StyleId) as expected. But when I check the finally generated document with Word, the cells are assigned to a newly created style "Formatvorlage TableContent + 6 Pt." and thus have a font-size of 6pt.

Here are some excerpts of my code...
Code: Select all
var outputDoc = new Spire.Doc.Document();
outputDoc.LoadFromFileInReadMode(templatePath, Spire.Doc.FileFormat.Docx);

...
var docSection = (Spire.Doc.Section)outputDoc.Sections.FirstItem;

var pContent = docSection.AddParagraph();
pContent.AppendHTML(s.Content); //Content contains html table markup!!!
...
foreach (Spire.Doc.Table table in outputDoc.Sections.FirstItem.Body.Tables)
{
...
var tableContentStyle = outputDoc.Styles.FindByName("TableContent");
foreach (Spire.Doc.TableRow row in table.Rows)
            {
                foreach (Spire.Doc.TableCell cell in row.Cells)
                {
                    foreach (Paragraph p in cell.Paragraphs)
                    {
                        p.ApplyStyle(tableContentStyle.StyleId);
                    }
...


Best regards,
Arne

arne.weber@webtelligence.net
 
Posts: 19
Joined: Mon Sep 19, 2016 6:52 am

Thu Nov 08, 2018 7:35 am

Hi,

After an initial test, I have not reproduced the issue which you have encountered. Could you please send your sample Word file as well as the html file to us via email(support@e-iceblue.com) so that we can look into the case?
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Tue Nov 13, 2018 7:37 am

Hi,

after some more investigation, I found the problem on our side. There was a css style definition within the html, containing a font-size definition.

Best regards,
Arne

arne.weber@webtelligence.net
 
Posts: 19
Joined: Mon Sep 19, 2016 6:52 am

Tue Nov 13, 2018 10:06 am

Hi,

I'm glad to hear that you found the solution of the problem.
Any other question, feel free to contact us.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Return to Spire.Doc