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

Free Support Forum - aspose.com

Mail Merge - Export to ODT format

Hello,

I have problem with export Mail Merge File to ODT format.

My template is in DOCX format. I have execute mail merge and data show good in docx generated file.

But I have to convert this one to ODT format. The problem is that Data Source is empty in generated file and only fields is visible - without data.

Is it possible to fix it or set option that Aspose force insert text instead of mail-field.

Hi there,

Thanks for your inquiry. We will appreciate it if you please share following resources here for testing. We will test the scenario at our end and will guide you accordingly.

  • Your input document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document by using Microsoft Word.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

Best Regards,

Hello,

I attached the zip with all files, without code, because it is complex process and this is not easy to separate this to undepended app.

The main problem is that ODT file not support data source like Word (I guess). And I would like insert normal text (replacing fields for example) in output odt file.

Hi there,

Thanks for your feedback.

mati4455:

I attached the zip with all files, without code, because it is complex process and this is not easy to separate this to undepended app.

I am afraid is quite difficult to suggest you any solution without looking into your code. We will appreciate it if you please share a standalone console project to localize the issue.

mati4455:

The main problem is that ODT file not support data source like Word (I guess). And I would like insert normal text (replacing fields for example) in output odt file.

For your requirement, please check following documentation link to find and replace text in the document. Hopefully it will help you to accomplish the task.

Best Regards,

Hello,

to show what is the problem just try:

var document = new Document(@"C:\result_docx.docx");
document.Save(@"C:\result_odt.odt", SaveFormat.Odt);

with files that I attached in previous posts. When document will be save to odt then source data will gone. In result file will stay only fields name instead of values.

Hi there,

Thanks for sharing additional information. You can use ConvertFieldsToStaticText() method of FieldHelper to achieve your requirement. Please check Github example of Aspose.Words for .NET for your reference, it will help you to accomplish the task.

Document doc = new
Document("result_docx.docx");

// Pass the appropriate parameters to convert all IF fields encountered in the document (including headers and footers) to static text.

FieldsHelper.ConvertFieldsToStaticText(doc, FieldType.FieldIf);
FieldsHelper.ConvertFieldsToStaticText(doc, FieldType.FieldMergeField);

// Save the document with fields transformed to disk.
doc.Save("Test_176.odt");

Best Regards,

Thank you so much! That is exactly what I wanted.