List of usage examples for com.lowagie.text Table setAutoFillEmptyCells
public void setAutoFillEmptyCells(boolean aDoAutoFill)
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI MySQL doc/* w w w .j a v a2s . c om*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(2); float[] width = { 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new Cell(new Phrase(name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(value, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_cabinetWord(String filename, String room) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from ww w .ja v a2s.c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List cabinetlist = (List) reportHash.get("cabinetlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(6); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(room + "", titleFont)); cell.setRowspan(2); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U(%)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Cabinet cabinet = null; if (cabinetlist != null && cabinetlist.size() > 0) { for (int i = 0; i < cabinetlist.size(); i++) { cabinet = (Cabinet) cabinetlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getName(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getAllu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getUseu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getTempu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getRateu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_equipmentWord(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from w w w.ja va 2 s . c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(6); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(roomname + cabinetname + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + roomname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + cabinetname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U:" + uselect, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + unumber, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + rate, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); EquipmentReport equipmentReport = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { equipmentReport = (EquipmentReport) equipmentlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getOperation(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_OperEquipmentWord(String filename, String opername, String contactname, String contactphone) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from www. j av a 2 s .c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(7); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(opername + "", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + opername, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactname, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactphone, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); OperCabinet operCabinet = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { operCabinet = (OperCabinet) equipmentlist.get(i); cell = new Cell(new Phrase(operCabinet.getRoomname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getIpaddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswersMatrix(Document document, Question question, Boolean[][] answerValuesMatrix, String falseMessage, String trueMessage) throws Exception { Table matrixTable; Cell cell;//from w w w . j a v a2 s .c om Paragraph questionParagraph = new Paragraph(); questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont)); document.add(questionParagraph); matrixTable = new Table(question.getColumnLabels().size() + 1); matrixTable.setPadding(2); matrixTable.setWidth(100); matrixTable.setDefaultCellBorder(0); matrixTable.setBorder(0); matrixTable.setOffset(4); matrixTable.setAutoFillEmptyCells(true); matrixTable.setCellsFitPage(true); matrixTable.setTableFitsPage(true); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); } int rowIndex = 0; for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { int columnIndex = 0; questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { questionParagraph = new Paragraph( answerValuesMatrix[rowIndex][columnIndex] ? trueMessage : falseMessage, normalFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); columnIndex++; } rowIndex++; } document.add(matrixTable); }
From source file:com.jd.survey.web.pdf.SurveyPdf.java
License:Open Source License
private void writeAnswersMatrix(Document document, Question question, String[][] answerValuesMatrix) throws Exception { Table matrixTable; Cell cell;//from w w w .jav a 2s. c o m Paragraph questionParagraph = new Paragraph(); questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont)); document.add(questionParagraph); matrixTable = new Table(question.getColumnLabels().size() + 1); matrixTable.setPadding(2); matrixTable.setWidth(100); matrixTable.setDefaultCellBorder(0); matrixTable.setBorder(0); matrixTable.setOffset(4); matrixTable.setAutoFillEmptyCells(true); matrixTable.setCellsFitPage(true); matrixTable.setTableFitsPage(true); cell = new Cell(""); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont)); cell.setBackgroundColor(Color.LIGHT_GRAY); matrixTable.addCell(cell); } int rowIndex = 0; for (QuestionRowLabel questionRowLabel : question.getRowLabels()) { int columnIndex = 0; questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) { questionParagraph = new Paragraph(answerValuesMatrix[rowIndex][columnIndex] == null ? "" : answerValuesMatrix[rowIndex][columnIndex], normalFont); questionParagraph.setLeading(12, 0); cell = new Cell(questionParagraph); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(231, 238, 244)); } matrixTable.addCell(cell); columnIndex++; } rowIndex++; } document.add(matrixTable); }
From source file:opisiame.controller.gestion_resultat.Choix_exportController.java
@FXML public void pdf_export() { File pdf_file = choix_chemin_enregistrement("PDF files (*.pdf)", "*.pdf"); if (onglet_actif.equals("questions")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open();//from w w w . ja v a 2 s.c o m document.add(new Paragraph("Rsultat Quiz")); Table tableau = new Table(6, reponse_questions.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Question"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse A"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse B"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse C"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage reponse D"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage bonne rponse"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } else if (onglet_actif.equals("eleves")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open(); document.add(new Paragraph("Rsultats des tudiants")); Table tableau = new Table(5, resultats_eleves.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Nom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Prnom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("N tudiant"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Note"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } else if (onglet_actif.equals("eleves_pas_num")) { if (pdf_file != null) { Document document = new Document(PageSize.A4); try { PdfWriter.getInstance(document, new FileOutputStream(pdf_file)); document.open(); document.add(new Paragraph("Rsultats des tudiants")); Table tableau = new Table(4, resultats_eleves.size()); tableau.setAutoFillEmptyCells(true); tableau.setPadding(2); Cell cell = new Cell("Nom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Prnom"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Note"); cell.setHeader(true); tableau.addCell(cell); cell = new Cell("Pourcentage"); cell.setHeader(true); tableau.addCell(cell); tableau.endHeaders(); tableau.setWidth(100); fill_data_pdf(tableau); document.add(tableau); } catch (DocumentException | IOException de) { de.printStackTrace(); } document.close(); } } close_window(); }
From source file:org.eclipse.osee.ats.rest.internal.build.report.table.BuildTraceTable.java
License:Open Source License
public void addRpcrToTable(String rpcr, Map<ArtifactReadable, Iterable<ArtifactReadable>> requirementsToTests) throws OseeCoreException { try {/*from w ww.ja va 2s.c om*/ Table nestedRequirementTable = new Table(2); // nestedRequirementTable.setAutoFillEmptyCells(true); SortedSet<Pair<String, Table>> nestedRpcr = new TreeSet<Pair<String, Table>>(PairCompare); for (Entry<ArtifactReadable, Iterable<ArtifactReadable>> entry : requirementsToTests.entrySet()) { ArtifactReadable changedReq = entry.getKey(); if (Conditions.notNull(changedReq)) { Table nestedTestScriptTable = new Table(1 + uriProvider.getColumnCount()); nestedTestScriptTable.setAutoFillEmptyCells(true); addNewTestScriptTraceCells(nestedTestScriptTable, entry.getValue()); // Store Requirement string and TestScriptTable for sorting Pair<String, Table> newPair = new Pair<String, Table>(changedReq.getName(), nestedTestScriptTable); nestedRpcr.add(newPair); } } // Create sorted requirement Table Iterator<Pair<String, Table>> treeItr = nestedRpcr.iterator(); while (treeItr.hasNext()) { Pair<String, Table> pair = treeItr.next(); addRequirementTraceCells(nestedRequirementTable, pair.getFirst()); nestedRequirementTable.insertTable(pair.getSecond()); } // Save RPCR ID with sorted requirement string Table. Pair<String, Table> newPair = new Pair<String, Table>(rpcr, nestedRequirementTable); sortedRpcr.add(newPair); } catch (BadElementException ex) { OseeExceptions.wrapAndThrow(ex); } }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method adds the log lines into the report * /*from www . j a v a 2s . c om*/ * @param reportLog */ private void generateReportLogBody(List<String[]> reportLog) { try { Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); int columnwidths[]; columnwidths = new int[] { 40, 15 }; Table aTable = new Table(2, linesPerPage); int rowsWritten = 0; for (String[] columns : reportLog) { if (pageNumber == 0 || line >= linesPerPage) { if (pageNumber > 0) { this.document.add(aTable); } int elementsLeft = reportLog.size() - rowsWritten; int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft); this.document.newPage(); this.generateColumnHeaders(); aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(columnwidths); aTable.setWidth(100); aTable.setBorder(Rectangle.NO_BORDER); line = 0; pageNumber++; } rowsWritten++; Cell cell; cell = new Cell(new Phrase(columns[0], font)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(new Phrase(columns[1], font)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); line++; } this.document.add(aTable); } catch (DocumentException de) { throw new RuntimeException( "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: " + de.getMessage()); } }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method creates a report group for the error message on the report * /* ww w . j a va 2 s.c om*/ * @throws DocumentException */ private void generateErrorColumnHeaders() throws DocumentException { try { int headerwidths[] = { 60 }; Table aTable = new Table(1, 1); // 2 columns, 1 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(headerwidths); aTable.setWidth(100); Cell cell; Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); cell = new Cell(new Phrase("Error(s)", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setGrayFill(0.9f); aTable.addCell(cell); this.document.add(aTable); } catch (Exception e) { throw new RuntimeException( "DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage()); } }