Free Support Forum - aspose.com

MailMerge.ExecuteWithRegions(dataSet);

Hi!

I have table with subtables. I want to use a command MailMerge.ExecuteWithRegions(dataSet);.

But this command make a problem in Subtables. I attach the template file and Xml file.

Are you have another way to do this?

Thank's.

private void BuildingTable_V2()

{

string[] strNameTable = new string[10];

int intmaxTables =0;

int strNameTableCount =0;

string[] strFieldNames;

strFieldNames = AsposeDocument.MailMerge.GetFieldNames();

DataSet dataSet = new DataSet();

try

{

for (int intFieldNames=0 ; intFieldNames< strFieldNames.Length ; intFieldNames++)

{

//Name of Tables

if (strFieldNames[intFieldNames].IndexOf("TableStart") ==0)

{

//Name of Table

string strHelp = strFieldNames[intFieldNames];

strNameTable[strNameTableCount] = strHelp.Substring(11);

strNameTableCount++;

}

}

intmaxTables = strNameTableCount;

for ( int intNameTable=0 ; intNameTable< intmaxTables ; intNameTable++)

{

string strNameTagOfTable =strNameTable[intNameTable];

DataTable myTable = new DataTable(strNameTagOfTable);

System.Xml.XmlNodeList nodeTableRows = XmlLetters.SelectNodes("//"+strNameTagOfTable);

if (nodeTableRows.Count >0)

{

System.Xml.XmlNodeList nodeTableCell = nodeTableRows.Item(0).ChildNodes;

for (int intnodelist = 0 ; intnodelist< nodeTableCell.Count;intnodelist++)

{

//Add columns to table

try //!!!*****

{//!!!*****

myTable.Columns.Add(nodeTableCell.Item(intnodelist).Name);

}//!!!*****

catch {} //!!!*****

// myTable.Columns.Add("Company");

}

for (int intnodeRow = 0 ; intnodeRow< nodeTableRows.Count;intnodeRow++)

{

nodeTableCell = nodeTableRows.Item(intnodeRow).ChildNodes;

DataRow row = myTable.NewRow();

for (int intnodelist = 0 ; intnodelist< nodeTableCell.Count;intnodelist++)

{

row[nodeTableCell.Item(intnodelist).Name] = nodeTableCell.Item(intnodelist).InnerText;

//row["Company"] = "Company" + i.ToString();

// myTable.Columns.Add("Company");

}

myTable.Rows.Add(row);

}

//Populate tables and add to the dataset.

dataSet.Tables.Add(myTable);

}//if (nodeTableRows.Count >0)

else

{

WriteToTextLog("Table is empty : " + strNameTagOfTable ,2);

myTable.Clear();

dataSet.Tables.Add(myTable);

}

}//for Tables

AsposeDocument.MailMerge.ExecuteWithRegions(dataSet);

SaveTempDocument(TempPath+strSystemNameFile);

}

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your interest in Aspose products. Unfortunately, nested data is unsupported yet. See FAQ for more information. As workaround you can try using multiple templates and merge these templates during mail merge.

Best regards.

And how I know that some cell include subtable in Aspose.Words.

You have a command?

Thank's

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. No, there is no command to determine if Region contains nested region. The best way to check this is opening your document by MS Word and reviewing your document. For example the following construction in your document will cause an exception.

[TableStart:tab1]

[TableStart:tab2]

[TableEnd:tab2]

[TableEnd:tab1]

You can also open your document using Document Explorer (Demo application). And find nested regions.

Best reagards.

This code supports nested regions and also provides a validation function to check for nested regions before merging:

http://antscode.blogspot.com/2009/03/advanced-word-mail-merge-component.html

Anthony.

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.
(33)