Export word,

Source: Internet
Author: User

Export word,

A simple small instance

Put the place where the word is to be bound into a placeholder.

Open the word in Google browser and format it as xml. You can also change the extension. (The generated xml file and word file can be displayed to each other as long as the extension is changed)

Background code

Public void CreateWordWXDF (string str, string SavePath) {// stream-based read and write string [] xx = str. split (','); // str is the result to be displayed on the word try {StreamReader sr = new StreamReader (@ "f: \ xm \ repair ticket template. xml "); // xml is the final generated xml. You only need to change the extension doc. Open
As shown in the figure above, string content = sr. readToEnd (); content = content. replace ("{0}", xx [0]. toString ()). replace ("{1}", xx [1]. toString ()). replace
("{2}", xx [2]. toString ()). replace ("{3}", xx [3]. toString ()). replace ("{4}", xx [4]. toString ()). replace ("{5}", xx [4]. toString ());
// Assign StreamWriter sw = new StreamWriter (SavePath. trim () + ". doc "); // SavePath save path sw. write (content); sr. close (); sw. close () ;}catch {}}

  

 

Related Article

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.