Reassign style for all tables of docx

I would like to change the style for all tables in docx document. Can you tell me how I should select a table in the document, what method should I use for this?

DocumentBuilder version: 8.1
Installation method: CLI
OS: WSL
Additional information:
Any relevant details about the situation. You can also attach images, videofile or docbuilder script to the post (or to place them to external storage)

I just would like to add that this example doesnot work at all.

Hello @foool

If I understand your desired scenario, you can use following approach:

var oDocument  = Api.GetDocument();
var aTables  = oDocument.GetAllTables();
var oTableStyle = oDocument.GetStyle("Bordered");

aTables.forEach(function(table, index) {
    table.SetStyle(oTableStyle);
});

That way to all tables in the document style “Bordered” will be applied.

Used methods: GetAllTables, GetStyle, SetStyle and basic JavaScript forEach method to apply style to all tables.

If I misunderstood, please let me know.


I’d kindly ask you to start a new topic for this report to avoid mixing up different topics in one thread. Thank you for understanding.