import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
String templatePath = "D:\\up.doc";
HWPFDocument hwpfDocument = new HWPFDocument(new FileInputStream(
new File(templatePath)));
Range range = hwpfDocument.getRange();
range.replaceText("$EnglishNamePlus$", "666");
range.replaceText("$GroupIndividual$Policy", "afds");
range.replaceText("$ClientName$", "发士大夫");
OutputStream os = new FileOutputStream(
new File("D:\\me1" + i
+ ".doc"));
hwpfDocument.write(os);
os.close();
之前操作word用的是
new ActiveXComponent(“Word.Application”);
web服务器上用这个,也是惊天地泣鬼神