C # reads the Word template and writes data to the specified domain to save as new word

Source: Internet
Author: User
Tags domain list

Reference:

Using System;
Using System.Collections.Generic;
Using System.Aspose.Words;
Using System.Windows.Forms;

To get the template path:

string " Path ";   // Example: string = "E:\\word\\word1.doc" New Document ();

Put the data in the list<string>:

list<stringnew list<string>;  Saved is the domain List<stringnew list<string>;  The data to be inserted is saved
List1. ADD ("Name");
List2. ADD ("Messege"); Give the value Messege in the location of the domain name

Converts a list to a string array, using the Document.MailMerge.Excute (string1,string2) method; string1 is a domain, string2 is the data

string [] S1 = List1. Toarry (); string [] s2 = List2. Toarry ();d m. Mailmerge.excute (S1,S2);    Assigning a value to a domain

Save to a folder create a new Newdoc.doc document:

string @" E:\word\newdoc.doc "  New"Newdoc.doc"@ "e:\word  "Word document (*.doc) |*.doc"; Sfd.show ();dd. Save (SFD. FileName);

C # reads the Word template and writes data to the specified domain as new word

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.