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 {}}