<%@ page import="java.io.FileOutputStream" %> <%@ page import="org.apache.poi.xwpf.usermodel.ParagraphAlignment" %> <%@ page import="org.apache.poi.xwpf.usermodel.XWPFDocument" %> <%@ page import="org.apache.poi.xwpf.usermodel.XWPFParagraph" %> <%@ page import="org.apache.poi.xwpf.usermodel.XWPFRun" %> <html> <head> <title>ThaiCreate.Com JSP Tutorial</title> </head> <body> <% try{ String fileName = application.getRealPath("/data/myWord.doc"); XWPFDocument doc = new XWPFDocument(); XWPFParagraph para = doc.createParagraph(); para.setAlignment(ParagraphAlignment.CENTER); XWPFRun run = para.createRun(); run.setBold(true); run.setFontSize(36); run.setText("ThaiCreate.Com"); doc.write(new FileOutputStream(fileName)); out.println("Word document created to : " + application.getRealPath("/data/")); } catch (Exception e) { e.printStackTrace(); } %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท