Setting a table font

Is there a way to set the font for a table, table row, and table cell without using the document builder?

Kind Regards,

Gavin

Hi Gavin,
Thanks for your request. Sure, you can achieve this. You should simply loop through all Run nodes inside the appropriate Table, Row or Cell node and change the font. Please see Aspose.Words DOM for more information:
https://docs.aspose.com/words/net/aspose-words-document-object-model/
Please let us know in case of any issues, we are always glad to help you.
Best regards,

Hi Andrey,

I have code that already sets the fonts in the run nodes when it adds it the paragraphs. However if a cell does not any paragraphs in the cell there is no way to set the font.

To combat this I initially added paragraphs into the cells when there is no paragraphs to be added just so each cell could have the fonts set.

however there is a square marker at the end of each table row which I have no access to set it’s font.

Kind Regards,

Gavin

Hi
Thank you for additional information. A cell in table in Ms Word document cannot be absolutely empty. Anyways there is one empty paragraph in the empty cell. If not it will be added upon saving the document (to keep the document valid).
If you would like to set the font of empty paragraph, you should simply set font of the paragraph break:
https://reference.aspose.com/words/net/aspose.words/paragraph/paragraphbreakfont/
If you are adding table cells dynamically, you can call EnsureMinimum method to add the required empty paragraph into this cell:
https://reference.aspose.com/words/net/aspose.words.tables/cell/ensureminimum/
Best regards,

Hi Andrey,

As previously indicated I realised that I was unable to place an empty
cell into the document and have thus added a paragraph per cell. However
there is no way to control the row break format.

Kind Regards,

Gavin

Hi
Thank you for additional information. There is no way and no need to set font of the end of row because there cannot be any nodes that could contain text. So it would be enough to set font of paragraphs and runs inside table cells.
Best regards,

Hi Gavin,

Thanks for your inquiry.

I think you may be looking for the ParagraphBreakFont. Please see the code below.

foreach (Paragraph para in table.GetChildNodes(NodeType.Paragraph, true))
    para.ParagraphBreakFont.Size = 1;

Thanks,

Hi Adam,

Unfortunately I am unable to use that code because the data provided has the potential to change font sizes. Which means I can’t generically set the paragraphbreakfonts to a standardised size.

However it seems that it does not matter. I just have to remember to set the font size specified for the cell, which i get from the data, and not worry about that paragraph break font character for the row. It seems to not matter what size is set for the row.

Thanks.

Hi Gavin,

Thanks for this additional information.

It’s great things are working for you now. Please feel free to ask any time you have any queries.

Thanks,