List of usage examples for org.apache.poi.xwpf.usermodel XWPFTable setInsideHBorder
public void setInsideHBorder(XWPFBorderType type, int size, int space, String rgbColor)
From source file:com.foc.vaadin.gui.mswordGenerator.FocMSWordLayout.java
License:Apache License
public void applyBorderAttribute(XWPFTable newTable) { String borderAtt = getXmlAttribute().getValue(FXML.ATT_BORDER); if (borderAtt != null && (borderAtt.toLowerCase().equals("true") || borderAtt.equals("1"))) { } else {/*w ww . j a va2 s .co m*/ newTable.getCTTbl().getTblPr().unsetTblBorders(); newTable.setInsideHBorder(XWPFBorderType.NONE, 0, 0, null); newTable.setInsideVBorder(XWPFBorderType.NONE, 0, 0, null); newTable.setRowBandSize(200); } newTable.setCellMargins(0, 0, 0, 0); }
From source file:MainPackage.Controllers.OrderController.java
public void Print(Frame frame, Orders order, Account _account) { try {/*from w w w . j a va 2s . c o m*/ XWPFDocument document = new XWPFDocument(); File file = new File("Ha n " + order.getIdCode() + ".doc"); if (file.exists()) { file.createNewFile(); } FileOutputStream out = new FileOutputStream(file); XWPFParagraph paragraph = document.createParagraph(); paragraph.setAlignment(ParagraphAlignment.CENTER); XWPFRun run; // BookViewModel bookView = new BookViewModel(book); ///////////////// run = createFieldRun(paragraph, "CHI TIT HA ?N"); run.setFontSize(24); paragraph = createPrintInformation(document, _account); paragraph = createBookProductInformation(document, order); paragraph = createBookInformation(document, order); //create table XWPFTable table = document.createTable(); setTableAlignment(table, STJc.CENTER); table.setCellMargins(50, 50, 50, 50); table.setInsideHBorder(XWPFTable.XWPFBorderType.SINGLE, 10, 10, ""); table.setInsideVBorder(XWPFTable.XWPFBorderType.NONE, 20, 20, ""); //create first row XWPFTableRow row = table.getRow(0); row.setHeight(40); row.getCell(0).setText("STT"); row.addNewTableCell().setText("M Sn phm"); row.addNewTableCell().setText("Tn Sn phm"); row.addNewTableCell().setText("?n v"); row.addNewTableCell().setText("S lng"); row.addNewTableCell().setText("Gi ti?n"); row.addNewTableCell().setText("Thnh ti?n"); List<OrderLine> list = (List<OrderLine>) order.getOrderLineCollection(); for (int i = 0; i < list.size(); i++) { OrderLine line = list.get(i); row = table.createRow(); row.getCell(0).setText((i + 1) + ""); row.getCell(1).setText(line.getProductId().getIdCode()); row.getCell(2).setText(line.getProductId().getName()); row.getCell(3).setText("Quyn "); row.getCell(4).setText(line.getQuantity() + " "); row.getCell(5).setText(IntToVND(line.getUnitPrice()) + " "); row.getCell(6).setText(IntToVND(line.getTotalPrice()) + " "); } document.write(out); out.close(); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(file); } JOptionPane .showMessageDialog(frame, "Xut file " + file.getName() + " thnh cng" + '\n' + "Ti v tr: " + file.getAbsolutePath(), "In thng tin Ha n", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(frame, "Xut file tht bi." + '\n' + "Vui lng ng ca s ang s dng file", "In thng tin Ha n", JOptionPane.WARNING_MESSAGE); } }