Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Nov 29, 2019 12:50 pm

Hello,

I want to get the document text after Mail Merge is executed. I use the following code:

Code: Select all
using (var document = new Spire.Doc.Document())
{
    document.LoadFromFile(template);
    document.MailMerge.ClearFields = true;
    var updateFieldsAfterMerge = needToUpdate();

    foreach (var dr in dataSource)
    {
        var d = document.Clone();

        d.MailMerge.Execute(dr);

        d.IsUpdateFields = updateFieldsAfterMerge;

        plainText = d.GetText(); // expect to return the merged document content

        d.ViewSetup.DocumentViewType = DocumentViewType.PrintLayout;
        d.SaveToFile(resultFile);

        //d.LoadText(resultFile);
        //plainText = d.GetText();
    }
}


d.GetText() doesn't return the text with the merged values. They are blank. The merged content is returned by d.GetText() only if I save the document and then load the text (the last two commented lines of code).

Is there I way to get the merged content without save and load? I want to skip save/load operations for performance reasons.

Regards,
Velislav

profiler007
 
Posts: 72
Joined: Wed Nov 13, 2019 11:32 am

Mon Dec 02, 2019 3:43 am

Hi,

Thanks for your inquiry.
We will look into your requirement without saving file to get merged content. Once there is any update, we will let you know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Dec 20, 2019 8:52 am

Hi,

Thanks for waiting.
Now the issue is solved in Spire.Office Platinum (DLL Only) Version:4.12.6.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.Office/

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Dec 23, 2019 9:08 am

Great, thanks!

profiler007
 
Posts: 72
Joined: Wed Nov 13, 2019 11:32 am

Mon Dec 23, 2019 9:11 am

Hi,

If there is any question while using our product, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc