Free Support Forum -

How to set table style in Aspose.Words


Is there a way to set the table style on a table created with Aspose.Words?

While it seems that it preserves table styles of existing tables in a document, I was not able to figure out how one would be able to set the style on a new table.

Many thanks


Thanks for your request. Unfortunately, currently there is no way to set table style in Aspose.Words. Your request has been linked to the appropriate issue. We will let you know once this is supported.

Best regards,


Thanks for your quick reply. Our scenario: We need to add a bunch of new tables to a document and we want to apply different table styles to them.

Interestingly, we somewhat found a way how to tell Aspose.Words to apply a table style of an existing table (manually created and styled in a word template document) to any new table created by using the Aspose.Words API. If we move to the existing table by means of a "MoveToBookmark" before inserting the new table at any location in the document, it seems that Aspose.Words inherits the table style also for the new one! See code below...

Does this make sense for you? Would you say that this is a "supported" scenario?



mDocumentBuilder.MoveToBookmark("BookmarkAroundAStyledTable", true, false);
// BookmarkAroundAStyledTable is a bookmark defined in the template document around a table with a custom table
// style applied. It is this table style that we want to use for the manually created table...
BookmarkStart bookmarkStart = ((BookmarkStart)mDocumentBuilder.CurrentNode);


// Manually create a new table. The table will automatically become the same style as the existing table identified
// by means of a bookmark.


Thanks for your request. The best approach I can suggest you is building an empty table in your template and then fill this table with data using Aspose.Words. For instance, you can use Mail Merge with Regions to achieve this:

Hope this could help you. Please feel free to ask in case of any issues, I will be glad to help you.

Best regards,

The issues you have found earlier (filed as WORDSNET-581) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.