We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Don't work up tag <<cellMerge [invoice.IndexOf()]>>

Good day! Pls tell me what could be the reason? I use the <> tag, everything works. If I use the tag <<cellMerge [invoice.IndexOf()]>> then the error is -Tag ‘cellMerge’ is not well-formed. Character ‘[’ is unexpected. I am attaching the files. Thanks a lot!

aspose support.zip (41.6 KB)

@fedorov.java IndexOf() is LINQ extension method from .NET and seems cannot be used in Java. In your case you can use <<cellMerge [invoice.Number]>> syntax. It works correct on my side. Here is a simple template and output produced by the following code: in.docx (13.0 KB)
out.docx (10.5 KB)

Report r = new Report();
Invoice i1 = new Invoice();
i1.Number = 1;
i1.Items.add(new InvoiceItem("test", "test", 1));
i1.Items.add(new InvoiceItem("test", "test1", 1));
i1.Items.add(new InvoiceItem("test1", "test2", 1));
r.invoices.add(i1);

Invoice i2 = new Invoice();
i2.Number = 2;
i2.Items.add(new InvoiceItem("test2", "test21", 1));
i2.Items.add(new InvoiceItem("test2", "test22", 1));
r.invoices.add(i2);

Document doc = new Document("C:\\Temp\\in.docx");
ReportingEngine.setUseReflectionOptimization(false);
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, r, "report2");
doc.save("C:\\Temp\\out.docx");

Good day! Thank you very much for your reply. with stack Trace.docx (13.7 KB)
<<cellMerge [invoice. Number]>> same error - Tag ‘cellMerge’ is not well-formed. Character ‘[’ is unexpected. If I write the <> tag, then the file is formed but does not merge as I want. Please tell me what could be the issue? I am attaching the stack trace.
PC I am using jdk-11.0.13 and aspose -

com.aspose
aspose-words
19.11

@fedorov.java Unfortunately, this feature is not available in your version of Aspose.Words. It has been introduced in 21.5 version of Aspose.Words for Java.
To use this feature, please update to newer version of Aspose.Words for Java.

Thank you very much, yes, when i upgrade the version to 21.5, the code works. Tell me more please, are version 19.11 compatible for 21.5? Thank you.

@fedorov.java Yes, the versions are compatible. Though there might be breaking changes in the API, which will require minor code changes on your side. You can learn about breaking changes in API from Aspose.Words for Java Release Notes.
Please let us know if you need help with updating your code. We will be glad to help you.