Region not hidden when no data

Hi,
I’m testing Aspose Words 9.1.0 and 9.2.0
I made a template like this :
MERGEFIELD TableStart:TABLE0
[cell][cell][cell]
[cell MERGEFIELD TableStart:TABLE1][cell MERGEFIELD data][cell MERGEFIELD TableEnd:TABLE1]
MERGEFIELD TableEnd:TABLE0
I’m using a dataset with TABLE0 and TABLE1 datatable.
code :

if (File.Exists(@"path\out.doc"))
    File.Delete(@"path\out.doc");
if (File.Exists(@"path\out_withData.doc"))
    File.Delete(@"path\out_withData.doc");
if (File.Exists(@"path\out_withoutData.doc"))
    File.Delete(@"path\out_withoutData.doc");
Document doc = new Document();
DocumentBuilder db = new DocumentBuilder(doc);
db.InsertField("MERGEFIELD TableStart:TABLE0");
db.InsertCell();
db.InsertCell();
db.InsertCell();
db.EndRow();
db.InsertCell();
db.InsertField("MERGEFIELD TableStart:TABLE1");
db.InsertCell();
db.InsertField("MERGEFIELD data");
db.InsertCell();
db.InsertField("MERGEFIELD TableEnd:TABLE1");
db.MoveToDocumentEnd();
db.InsertField("MERGEFIELD TableEnd:TABLE0");
doc.Save(@"path\out.doc");
XmlDocument XmlDataset = new XmlDocument();
XmlDataset.LoadXml("1donne");
XmlDataset.Save(@"path\dataset.xml");
DataSet ds = new DataSet();
ds.ReadXml(@"path\dataset.xml");
File.Delete(@"path\dataset.xml");
doc.MailMerge.ExecuteWithRegions(ds);
doc.UpdateFields();
doc.Save(@"path\out_withData.doc");
doc = new Document();
db = new DocumentBuilder(doc);
db.InsertField("MERGEFIELD TableStart:TABLE0");
db.InsertCell();
db.InsertCell();
db.InsertCell();
db.EndRow();
db.InsertCell();
db.InsertField("MERGEFIELD TableStart:TABLE1");
db.InsertCell();
db.InsertField("MERGEFIELD data");
db.InsertCell();
db.InsertField("MERGEFIELD TableEnd:TABLE1");
db.MoveToDocumentEnd();
db.InsertField("MERGEFIELD TableEnd:TABLE0");
doc.Save(@"path\out.doc");

ds = new DataSet("NewDataSet");
ds.Tables.Add(new DataTable("TABLE0"));
ds.Tables.Add(new DataTable("TABLE1"));

doc.MailMerge.ExecuteWithRegions(ds);
doc.UpdateFields();
doc.Save(@"path\out_withoutData.doc");

With Aspose.Word 9.0.0, table is hidden in out_withoutData.doc.
With Aspose.Word 9.1.0 and 9.2.0, table is not hidden in out_withoutData.doc.
Did you change something ?
Is there any way to have the same fonctionality as with 9.0.0 version of aspose Words ?
(I made the same test with text inside region, with the same result. Text is not hidden when there is no row in my dataset)
Thanks

Hi
Thanks for your request. Yes you are right, we made some changes, but it is not a bug. We will consider adding an option like RemoveEmptyParagraphs, but for regions. Your request has been linked to the appropriate issue. You will be notified as soon as it is supported.
As a temporary workaround you can try using RemoveEmptyRegions class:

// Open the template document
Document doc = new Document(@"in.doc");
// Merge data
doc.MailMerge.ExecuteWithRegions(Dataset);
// Remove any remaining unused regions from the document
doc.Accept(new RemoveEmptyRegions());

RemoveEmptyRegions class is attached.
Best regards,

Ok
I didn’t see that in patch note 9.1.0. Could you please specify these kind of changes in patch note, it’s not easy to test everything to ensure ascendant compatibility on Aspose update with our customers templates.
Thanks for your quick reply and this workaround

Hi

Thanks for your inquiry. Sorry for inconvenience. We will let you know once RemoveEmptyRegions option is available.
Best regards,

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

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