@Test public void testCreateDocxWithFontStyle() { try { WordUtil.createWithFontStyle("d: } catch (IOException e) { e.printStackTrace(); } }
public static void createWithFontStyle(String filename) throws IOException { XWPFDocument document = new XWPFDocument(); FileOutputStream out = new FileOutputStream(new File(filename)); XWPFParagraph paragraph = document.createParagraph(); XWPFRun paragraphOneRunOne = paragraph.createRun(); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setItalic(true); paragraphOneRunOne.setText("Font Style"); paragraphOneRunOne.addBreak(); XWPFRun paragraphOneRunTwo = paragraph.createRun(); paragraphOneRunTwo.setText("Font Style two"); paragraphOneRunTwo.setTextPosition(100); XWPFRun paragraphOneRunThree = paragraph.createRun(); paragraphOneRunThree.setStrike(true); paragraphOneRunThree.setFontSize(20); paragraphOneRunThree.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunThree.setText(" Different Font Styles"); document.write(out); out.close(); System.out.printf("create %s written successully\n", filename); }
WordUtil { public static void createWithFontStyle(String filename) throws IOException { XWPFDocument document = new XWPFDocument(); FileOutputStream out = new FileOutputStream(new File(filename)); XWPFParagraph paragraph = document.createParagraph(); XWPFRun paragraphOneRunOne = paragraph.createRun(); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setItalic(true); paragraphOneRunOne.setText("Font Style"); paragraphOneRunOne.addBreak(); XWPFRun paragraphOneRunTwo = paragraph.createRun(); paragraphOneRunTwo.setText("Font Style two"); paragraphOneRunTwo.setTextPosition(100); XWPFRun paragraphOneRunThree = paragraph.createRun(); paragraphOneRunThree.setStrike(true); paragraphOneRunThree.setFontSize(20); paragraphOneRunThree.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunThree.setText(" Different Font Styles"); document.write(out); out.close(); System.out.printf("create %s written successully\n", filename); } }
WordUtil { public static void createWithFontStyle(String filename) throws IOException { XWPFDocument document = new XWPFDocument(); FileOutputStream out = new FileOutputStream(new File(filename)); XWPFParagraph paragraph = document.createParagraph(); XWPFRun paragraphOneRunOne = paragraph.createRun(); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setItalic(true); paragraphOneRunOne.setText("Font Style"); paragraphOneRunOne.addBreak(); XWPFRun paragraphOneRunTwo = paragraph.createRun(); paragraphOneRunTwo.setText("Font Style two"); paragraphOneRunTwo.setTextPosition(100); XWPFRun paragraphOneRunThree = paragraph.createRun(); paragraphOneRunThree.setStrike(true); paragraphOneRunThree.setFontSize(20); paragraphOneRunThree.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunThree.setText(" Different Font Styles"); document.write(out); out.close(); System.out.printf("create %s written successully\n", filename); }  }
WordUtil { public static void createWithFontStyle(String filename) throws IOException { XWPFDocument document = new XWPFDocument(); FileOutputStream out = new FileOutputStream(new File(filename)); XWPFParagraph paragraph = document.createParagraph(); XWPFRun paragraphOneRunOne = paragraph.createRun(); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setItalic(true); paragraphOneRunOne.setText("Font Style"); paragraphOneRunOne.addBreak(); XWPFRun paragraphOneRunTwo = paragraph.createRun(); paragraphOneRunTwo.setText("Font Style two"); paragraphOneRunTwo.setTextPosition(100); XWPFRun paragraphOneRunThree = paragraph.createRun(); paragraphOneRunThree.setStrike(true); paragraphOneRunThree.setFontSize(20); paragraphOneRunThree.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunThree.setText(" Different Font Styles"); document.write(out); out.close(); System.out.printf("create %s written successully\n", filename); }  static void create(String filename); static void create(String filename, String content); static void createWithBorders(String filename, String content); static void createWithTable(String filename); static void createWithFontStyle(String filename); static void createWithAlign(String filename); static void extractor(String filename); static void setDocxProperties(String filename); static void setDocProperties(String filename); }
WordUtil { public static void createWithFontStyle(String filename) throws IOException { XWPFDocument document = new XWPFDocument(); FileOutputStream out = new FileOutputStream(new File(filename)); XWPFParagraph paragraph = document.createParagraph(); XWPFRun paragraphOneRunOne = paragraph.createRun(); paragraphOneRunOne.setBold(true); paragraphOneRunOne.setItalic(true); paragraphOneRunOne.setText("Font Style"); paragraphOneRunOne.addBreak(); XWPFRun paragraphOneRunTwo = paragraph.createRun(); paragraphOneRunTwo.setText("Font Style two"); paragraphOneRunTwo.setTextPosition(100); XWPFRun paragraphOneRunThree = paragraph.createRun(); paragraphOneRunThree.setStrike(true); paragraphOneRunThree.setFontSize(20); paragraphOneRunThree.setSubscript(VerticalAlign.SUBSCRIPT); paragraphOneRunThree.setText(" Different Font Styles"); document.write(out); out.close(); System.out.printf("create %s written successully\n", filename); }  static void create(String filename); static void create(String filename, String content); static void createWithBorders(String filename, String content); static void createWithTable(String filename); static void createWithFontStyle(String filename); static void createWithAlign(String filename); static void extractor(String filename); static void setDocxProperties(String filename); static void setDocProperties(String filename);  }