nestedTables MailMerge Workaround

Hi,

I´ve found some really usefull stuff in here, but nothing could help me much with my problem.

I try to build a parser witch accepts a Word Document, extracts the tablestructure (including nested tables), builds the SQL stuff and then does a mail merge on the document for a often used server application. (I’ve got a chance to do this … :S … I belive)

The first thing is about getting the mail merge fields from the Document. If i use the MergeFieldEventHandler for this, it deletes all the fields and then I can not mail merge later (I guess). Is there any other way to solve this? (tought about doc2 = doc.Clone(), and use doc2 for this - but this might be too slow) but i need to edit them, because of issue #2.

The second prob.: If i build a nested table word document and merge it, even if i try not to paste in some nested object, it throws an exeption about nested tables. I would try to solve this over manually delete (and save the position, format, etc) the Windows mergefield, but aspose.field (think it´s stored in there) has no delete function.

used:
MailMerge.ExecuteWithRegions() to perform the merge.


If anyone has a clue or eaven an little idea how i could word it around …

Thank you for spending your time on my bad english :wink:

greets, Skunker

Unfortunately in our current API there is no simple way to get a hold of the merge fields.

Concerning your second problem. Please send me a sample document with direction as to what field you need to delete and I will try to find a way to do it with our current API.

Regards,

Hi,
Thanks for your fast answer,

The main problem is: There is no standard document. It got to be a solution for almoast every possible kind of documents: Object tables, sales invoices, letter, multi-page documents … At this moment an similar System using RTF/ is running, so my solution should have no lesser functionallity. I am only allowed to use winword placeholder (and 2 special placeholders for table start/end ) in the template. It looks like I´ve got to write my own method for nested MailMerge, using aspose as a kind of an advanced read & write Interface for Word. About the field I want to delete - this is not so easy to explain, I try my best:

extract table structure :
This is where I want to iterate the nested objects, then, when I found a table inside a table(else use usual MailMerge.ExecuteWithRegions), then replace the placeholders for a nested Table: (myTableStart:[tablename],col,col,col,myTableEnd:[tablename])

will be replaced with my own string placeholders:
(#tableStart0# #col000# #col01# #col02# #tableStart1# #col 01# #col02# #tableEnd1# … #TableEnd0#)
in #tableStart0# the 0 is the number (level) of the nested table. For a later use of the method where I can find and replace my own placeholder . I’ve got to use own Placeholder, because the parser would deletes all non-used placeholder and gives a exeption for nested. maybe i use the table names and colum names instead of numbers.

(edit: thinking abouf if this is neccacary if I don´t use the aspose.mailmerge parser in the paste stuff)

Now I can use the self made:

paste content:

A Document is parsed for each level of nested tables. 1x usual table(not nested) 2x to 10x (for each level one - limit 10(table9)
Usually there are 2-3 level. so 10 should be enough for long time. the regex for finding the #tableStart[0-9]# is changing each iteration: 0,1, 2, 3, 4, 5 …9. top -> down. similar is colum and Tableend regex. (0 = top lv table)

I´m wondering if I can do this to a performant generation time (>0.3 - 0.4 s/page @ a 10page docuement 3 lv of nested (~2,8GHZ, 1GB RAM, HT, low prio process/thread) means 3s for the whoe document, usual mailmerge is now @ 0.3s so I got 10x time of now, one of the fastest tools I’ve seen by the way :slight_smile: ). that´s why i need to know if there is a way to access/iterate the Winword placeholder without parsing the whole document. This would give me maybe a little bit more time while extracting the document´s structure for the sql querry and switching nested: yes / no.

The code is not really far, so I don’t post it here atm.
I´m still thinking about if this is possible, and working on logical parts.

Thanks,
Skunker

using .net version of aspose
P.S.: also thinking if i could use the eventhandler & builder to paste in and out those usual placeholders…

edit: so far the first part works fine, I can replace them really easy. now for the structure - is there any way to iterate the winword placeholders by code, without event handler. Got some issues with saving the structure. – read only –

edit again: got the structure with MailMerge.GetFieldNames()- no more questions at this moment - thanks :smiley:

maybe the last edit: Done it, nested MailMerge almoast works.

Hi,
while I´m still evaluating Aspose.words, and trying about some nested mail merge, I wonder if there is a way to solve this problem:

to not insert tables that do not exist - yes it sounds crazy.
the tables do not exists, but there are table start and table ends inside the Document, wich say they do. Is there any way to say, ignore table starts and ands wich where found and not in the DataSet, and go on? (and maybe delete the fields)

I use atm:
executeMailMergeWithRegions(DataSet)


thanks & best regards,

Skunker

erm … by the way: is the forum search broken? didn’t work with my mozilla & i-explorer

sry for my bad english

Thanks for your research and your valuable suggestions.

I don't think we are going to make any patches to the existing MailMerge behavior except for bug fixes. We have plans for a major update of our current MailMerge engine, but it is still several months away. Your suggestions will be duly taken into account then.

We still could go for some minor fixes now, so if you have any clear cut suggestions which can be illustrated with a code snippet and a test document I promise we will consider implementing them as soon as possible.

Best regards,

The issues you have found earlier (filed as 39) have been fixed in this update.


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