Free Support Forum - aspose.com

Identifying Specific Pre-Existing Tables

I am doing a sort of custom report engine that will use existing Word templates for layout. Tabular data will use pre-existing tables in the templates. I plant to handle row creation within those tables by cloning a pre-existing data row (as opposed to a header row) and fill values to the cells. This approach allows non-developers to define very precise layout and formatting. I want a clean separations between data, format and the mechanism for placing the data into format.

I am planning on useing bookmarks to identify insertion locations. To this end, I would like to have the persons editing the Word templates to place some monikor (bookmark, etc.) to identify specific tables for association with particular data sets. This is preferable to making the associations based on assumptions of the ordinality of tables in the document. I thought that the bookmarks can be placed either around, adjacent or within the table. However, I am at a loss as to how to navigate through the Aspose object model to find the bookmark given a reference to a table.

I would appreciate suggestions on how to solve my basic problem of needing to identify tables by name, names being established by the perons editing the Word templates.

Thanks in advance

Hi

Thanks for your interest in Aspose products. I think, in your case, the best way to fill the document with repieated data is using Mail Merge with regions feature. Please see the following link to learn more:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/mail-merge-with-regions-explained.html

To mark the beginning of a mail merge region, insert a MERGEFIELD with the name TableStart:MyTable, where MyTable corresponds to the name of the table. To mark the end of the mail merge region insert another MERGEFIELD with the name TableEnd:MyTable. Between these marking fields, place merge fields that correspond to the fields of your data source (table columns). These merge fields will be populated with data from the first row of the data source, then the whole region will be repeated, and the new fields will be populated with data from the second row, and so on.

Best regards,

Thanks, I will look into this as a possible solution for placing values into place-holders.

I am also getting the sense that I could use bookmarks as part of a general mechanism for content navigation and manipulation. I am seeing that one can use a number of means for obtaining an instance of a Bookmark and can then obtain a pair of document nodes --- the BookmarkStart and BookmarkEnd nodes --- as a means for discovering node(s) that lies between them --- the node(s) wrapped in the bookmark . The discoverd node(s) could be then subjected to all sorts of manipulations, not limited to mere text replacement. Do you see any flaws with this approach.

Thanks again

Hello

Thanks for your request. Bookmarks are used frequently to mark particular places in the document where new elements are to be inserted. To move to a bookmark, use DocumentBuilder.MoveToBookmark. This method has two overloads. The simplest one accepts nothing but the name of the bookmark where the cursor is to be moved.

Also please see the following link to learn more:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/moving-the-cursor.html

Using the classes of the Aspose.Words DOM, you can get detailed programmatic access to document elements and formatting. Please see the following link to learn more about Aspose.Words Document Object Model (DOM) and its relationships.

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/object-model-overview.html

In additional, I think, in your case, you can use DocumentVisitor. Please follow the link to learn more

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.documentvisitor.html

Hope this helps you.

Best regards,

This is a good start. Thanks again