# 不扯那些没用的,看代码

 * 导出二维码答题地址。
	 * 
	 * @param surveyForm
	 * @param file
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("resource")
	public String createUrlWordFile(String strFilePath, String sueveyFormid, String multilId) {
		String strFilePath3 = GetProperties.getValue("tmpPath");
		String strFilePath2 = strFilePath3 + File.separator + "AnswerUrl.xls";
		File file = new File(strFilePath2);
		if (file == null) {
			logger.info("文件不合法");
			return strFilePath + "AnswerUrl.doc";
		} else {
			List<ReplyUser> lstReplyUser = new ArrayList<ReplyUser>();
			lstReplyUser = replyUserDao.getListStatu(sueveyFormid);
			if (null == lstReplyUser || lstReplyUser.size() <= 0) {
				logger.error("获取答题人员集合为空!");
				return strFilePath + "AnswerUrl.doc";
			}

			// logger.info("文件路径是:---" + objFile.getAbsolutePath());
			// 创建XWPFDocument对象;
			CustomXWPFDocument document = new CustomXWPFDocument();
			// 利用XWPFDocument对象创建XWPFParagraph对象;
			XWPFParagraph paragraph = document.createParagraph();
			// 创建XWPFRun行对象,新建一行;
			// XWPFRun run = paragraph.createRun();
			List<XWPFParagraph> xwpfParas = document.getParagraphs();
			try {
				for (int i = 0; i < lstReplyUser.size(); i++) {
					XWPFRun run = xwpfParas.get(i).createRun();
					// 添加文本信息
					run.addBreak();
					run.setText((i +1)+".状态:" + statu+";");
					run.setText(" 用户编号:" + lstReplyUser.get(i).getReplyUserId()+";");
					run.setText(" 分类:" + lstReplyUser.get(i).getUserClass().trim());
					run.addBreak();
					run.setText("邮件地址:" + "" + lstReplyUser.get(i).getEmail());
					run.addBreak();
					run.setText("二维码:");
					run.addBreak();
					run.setText(outLinkUrl);
					createPath(document, paragraph, run, filePathName);
					System.out.print(filePathName);
					System.out.print(filePathName.substring(40,filePathName.length()));
					System.out.print("D:/workspace10/tesla_console_E/WebRoot/"+filePathName.substring(40,filePathName.length()));
				}
				FileOutputStream out = new FileOutputStream(strFilePath + "AnswerUrl.doc");
				document.write(out);
				out.flush();
				delAllFile("D:/workspace10/tesla_console_E/WebRoot/image");

下载word 查看生成如图所示:

https://img.cncreator.cn/blog/8854f39a7624d12fd75c8f4185705f06.png