List of usage examples for com.lowagie.text Phrase Phrase
public Phrase(float leading, String string)
Phrase
with a certain leading and a certain String
. From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sqlPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/* w ww. j a va2 s . c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // 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); 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"); 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); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } 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) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @param filename//from w w w.j a v a2 s. co m * @param type * @throws DocumentException * @throws IOException */ public void createReport_sqlNewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys"); String[] sysItem1 = { "shared_pool", "large_pool", "buffer_cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // 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(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); this.setCellFormat(cell, true); aTable.addCell(cell); // mems Hashtable sqlValue = new Hashtable(); if ((Hashtable) reportHash.get("sqlValue") != null) sqlValue = (Hashtable) reportHash.get("sqlValue"); Hashtable memValue = new Hashtable(); if (sqlValue.get("mems") != null) memValue = (Hashtable) sqlValue.get("mems"); String totalMemory = "---"; String sqlMem = "---"; String optMemory = "---"; String lockMem = "---"; String conMemory = "---"; if (memValue != null && memValue.size() > 0) { if (memValue.get("totalMemory") != null) totalMemory = (String) memValue.get("totalMemory");// total if (memValue.get("sqlMem") != null) sqlMem = (String) memValue.get("sqlMem");// sql if (memValue.get("optMemory") != null) optMemory = (String) memValue.get("optMemory");// if (memValue.get("lockMem") != null) lockMem = (String) memValue.get("lockMem");// if (memValue.get("conMemory") != null) conMemory = (String) memValue.get("conMemory");// } cell = new Cell(new Phrase("(KB)", titleFont)); cell.setRowspan(3); 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(totalMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SQL", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sqlMem.replace(".0", ""), contextFont1)); 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(optMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lockMem.replace(".0", ""), contextFont1)); 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(conMemory.replace(".0", ""), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); 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.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String productlevel = ""; if (sqlsys.get("productlevel") != null) { productlevel = (String) sqlsys.get("productlevel"); } cell = new Cell(new Phrase(productlevel)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsSingleUser = ""; if (sqlsys.get("IsSingleUser") != null) { IsSingleUser = (String) sqlsys.get("IsSingleUser"); } cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsSingleUser, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsIntegratedSecurityOnly = ""; if (sqlsys.get("IsIntegratedSecurityOnly") != null) { IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly"); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsIntegratedSecurityOnly, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String IsClustered = ""; if (sqlsys.get("IsClustered") != null) { IsClustered = (String) sqlsys.get("IsClustered"); } cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsClustered, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Hashtable dbValue = (Hashtable) reportHash.get("dbValue"); Hashtable alldatabase = new Hashtable(); Hashtable alllogfile = new Hashtable(); alldatabase = (Hashtable) dbValue.get("database"); if (alldatabase == null) alldatabase = new Hashtable(); alllogfile = (Hashtable) dbValue.get("logfile"); if (alllogfile == null) alllogfile = new Hashtable(); Vector names = (Vector) dbValue.get("names"); /* * OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao(); List * list = oraspaceconfigDao.getByIp(ip, 1); */ SqldbconfigDao sqldbconfigDao = new SqldbconfigDao(); List list = null; try { list = sqldbconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sqldbconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); this.setCellFormat(cell5, true); aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== // ==== int row = 0; for (int i = 0; i < names.size(); i++) { Hashtable ht = (Hashtable) dbValue.get(i); String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); for (int j = 0; j < list.size(); j++) { Sqldbconfig vo1 = (Sqldbconfig) list.get(j); if (vo1.getDbname().equals(dbname)) { String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase(dbname, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedsize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedperc, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sqlNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open();//from www. j ava 2 s . c o m // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); 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(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr)); 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(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); 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(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // mems Hashtable sqlValue = new Hashtable(); if ((Hashtable) reportHash.get("sqlValue") != null) sqlValue = (Hashtable) reportHash.get("sqlValue"); Hashtable memValue = new Hashtable(); if (sqlValue.get("mems") != null) memValue = (Hashtable) sqlValue.get("mems"); String totalMemory = "---"; String sqlMem = "---"; String optMemory = "---"; String lockMem = "---"; String conMemory = "---"; if (memValue != null && memValue.size() > 0) { if (memValue.get("totalMemory") != null) totalMemory = (String) memValue.get("totalMemory");// total if (memValue.get("sqlMem") != null) sqlMem = (String) memValue.get("sqlMem");// sql if (memValue.get("optMemory") != null) optMemory = (String) memValue.get("optMemory");// if (memValue.get("lockMem") != null) lockMem = (String) memValue.get("lockMem");// if (memValue.get("conMemory") != null) conMemory = (String) memValue.get("conMemory");// } cell = new Cell(new Phrase("(KB)", titleFont)); cell.setRowspan(3); 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(totalMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("SQL", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sqlMem.replace(".0", ""))); 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(optMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(lockMem.replace(".0", ""))); 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(conMemory.replace(".0", ""))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); 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.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String productlevel = ""; if (sqlsys.get("productlevel") != null) { productlevel = (String) sqlsys.get("productlevel"); } String IsSingleUser = ""; if (sqlsys.get("IsSingleUser") != null) { IsSingleUser = (String) sqlsys.get("IsSingleUser"); } String IsIntegratedSecurityOnly = ""; if (sqlsys.get("IsIntegratedSecurityOnly") != null) { IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly"); } String IsClustered = ""; if (sqlsys.get("IsClustered") != null) { IsClustered = (String) sqlsys.get("IsClustered"); } cell = new Cell(new Phrase(productlevel)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsSingleUser, contextFont)); 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(IsIntegratedSecurityOnly, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(IsClustered, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Hashtable dbValue = (Hashtable) reportHash.get("dbValue"); Hashtable alldatabase = new Hashtable(); Hashtable alllogfile = new Hashtable(); alldatabase = (Hashtable) dbValue.get("database"); if (alldatabase == null) alldatabase = new Hashtable(); alllogfile = (Hashtable) dbValue.get("logfile"); if (alllogfile == null) alllogfile = new Hashtable(); Vector names = (Vector) dbValue.get("names"); SqldbconfigDao sqldbconfigDao = new SqldbconfigDao(); List list = null; try { list = sqldbconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sqldbconfigDao.close(); } // // List list = sqldbconfigDao.getByIp(ip, 1); // for (int i = 0; i < list.size(); i++) { // // } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(2 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // ==== int row = 0; for (int i = 0; i < names.size(); i++) { Hashtable ht = (Hashtable) dbValue.get(i); String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); for (int j = 0; j < list.size(); j++) { Sqldbconfig vo1 = (Sqldbconfig) list.get(j); if (vo1.getDbname().equals(dbname)) { String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(size)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedsize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(usedperc)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); row = row + 1; } } } // ===============end String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if ("0".equals(downnum)) { pinglog = " " + "2 "; } else { pinglog = " " + "2 " + downnum + ""; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sybDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from w ww. j a v a 2s .c om 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"); 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(""); 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); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 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.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(row + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbname, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbsize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(freesize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(userdperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row = row + 1; } } 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) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sybPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;// w w w . j av a 2 s . co m return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // 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); 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"); 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); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(freesize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(userdperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } 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) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sybaseNewDoc(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open();/*from www .java2 s. co m*/ // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); 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(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); 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(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); 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(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont1)); 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(sysbaseVO.getProcedure_hitrate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); 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(sysbaseVO.getServerName(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getVersion(), contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(8 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getIdle(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("cpu()", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getCpu_busy(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("I/O()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IO(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate(), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getSent_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getReceived_rate(), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getWrite_rate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getRead_rate(), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getDisk_count(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getLocks_count(), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getXact_count(), contextFont1)); cell.setColspan(6); 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("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); for (int j = 0; j < list.size(); j++) { Sybspaceconfig vo = (Sybspaceconfig) list.get(j); if (vo.getSpacename().equals(dbname)) { String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase(dbname, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(dbsize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(freesize, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(userdperc, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sybaseNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open();/*from ww w.ja v a 2 s. c om*/ // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); 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(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); 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(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); 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(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate())); 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(sysbaseVO.getProcedure_hitrate(), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); 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(sysbaseVO.getServerName())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getVersion())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(8 + list.size()); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getIdle())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("cpu()", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getCpu_busy())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("I/O()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IO(%)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate())); cell.setColspan(2); 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(sysbaseVO.getSent_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getReceived_rate())); cell.setColspan(2); 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(sysbaseVO.getWrite_rate())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("(/)", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getRead_rate())); cell.setColspan(2); 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(sysbaseVO.getDisk_count())); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getLocks_count())); cell.setColspan(2); 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(sysbaseVO.getXact_count())); cell.setColspan(6); 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("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("%", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); int row = 1; if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); for (int j = 0; j < list.size(); j++) { Sybspaceconfig vo = (Sybspaceconfig) list.get(j); if (vo.getSpacename().equals(dbname)) { String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); cell = new Cell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(dbsize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(freesize)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(userdperc)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } } } String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * mysql doc/*from ww w .ja v a2 s . c o m*/ * * @Author HONGLI * @param filename * @throws DocumentException * @throws IOException */ public void createReport_mysqlNewDoc(String filename, String type) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); DBVo vo = (DBVo) reportHash.get("vo"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); this.setTableFormat(aTable); // 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(0);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); this.setCellFormat(cell, true); cell.setColspan(8); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Vector val = (Vector) reportHash.get("Val"); String Max_used_connections = ""; String Table_locks_immediate = ""; String Table_locks_waited = ""; String Key_read_requests = ""; String Key_reads = ""; String log_slow_queries = ""; String Threads_connected = ""; String Open_tables = ""; String Opened_tables = ""; 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=""; Max_used_connections = value; } if (name.equalsIgnoreCase("Table_locks_immediate")) { // name=""; Table_locks_immediate = value; } if (name.equalsIgnoreCase("Table_locks_waited")) { // name=""; Table_locks_waited = value; } if (name.equalsIgnoreCase("Key_read_requests")) { // name=""; Key_read_requests = value; } if (name.equalsIgnoreCase("Key_reads")) { // name=""; Key_reads = value; } if (name.equalsIgnoreCase("log_slow_queries")) { // name=""; log_slow_queries = value; } if (name.equalsIgnoreCase("Threads_connected")) { // name=""; Threads_connected = value; } if (name.equalsIgnoreCase("Open_tables")) { // name=""; Open_tables = value; } if (name.equalsIgnoreCase("Opened_tables")) { // name=""; Opened_tables = value; } } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Max_used_connections, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_immediate, contextFont1)); 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(Table_locks_waited, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_read_requests, contextFont1)); 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(Key_reads, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(log_slow_queries, contextFont1)); 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(Threads_connected, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Open_tables, contextFont1)); 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(Opened_tables, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); 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); Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); String Threads_cached = ""; String Innodb_buffer_pool_pages_total = ""; String Threads_created = ""; String Uptime = ""; if (tableinfo_v != null) { for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("Threads_cached")) { // size=""; Threads_cached = free; } if (size.equalsIgnoreCase("Innodb_buffer_pool_pages_total")) { // size=""; Innodb_buffer_pool_pages_total = free; } if (size.equalsIgnoreCase("Threads_created")) { // size=""; Threads_created = free; } if (size.equalsIgnoreCase("Uptime")) { // size=":"; Uptime = free; } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Innodb_buffer_pool_pages_total, contextFont1)); 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(Threads_created, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Uptime, contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); 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("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); List list = null; try { list = sybspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { sybspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); // cell5.setRowspan(8 + list.size()); this.setCellFormat(cell5, true); aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getIdle(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("cpu()", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getCpu_busy(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("I/O()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("IO(%)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate(), // contextFont1)); // cell.setColspan(2); // 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(sysbaseVO.getSent_rate(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getReceived_rate(), // contextFont1)); // cell.setColspan(2); // 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(sysbaseVO.getWrite_rate(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getRead_rate(), contextFont1)); // cell.setColspan(2); // 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(sysbaseVO.getDisk_count(), contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getLocks_count(), // contextFont1)); // cell.setColspan(2); // 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(sysbaseVO.getXact_count(), contextFont1)); // cell.setColspan(6); // 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("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("%", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // get dbspace message================== // if (sysbaseVO == null) // sysbaseVO = new SybaseVO(); // List dbsizelist = (List) sysbaseVO.getDbInfo(); // int row = 1; // if (dbsizelist != null && dbsizelist.size() > 0) { // for (int i = 0; i < dbsizelist.size(); i++) { // // TablesVO tablesVO = (TablesVO) dbsizelist.get(i); // String dbname = tablesVO.getDb_name(); // for (int j = 0; j < list.size(); j++) { // Sybspaceconfig vo = (Sybspaceconfig) list.get(j); // if (vo.getSpacename().equals(dbname)) { // // String dbsize = tablesVO.getDb_size(); // String freesize = tablesVO.getDb_freesize(); // String userdperc = tablesVO.getDb_usedperc(); // // cell = new Cell(new Phrase(dbname, contextFont1)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(dbsize, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(freesize, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(userdperc, contextFont1)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // } // } // } // } // String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); this.setCellFormat(cell, true); aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * mysql pdf/*from w w w .ja v a 2s. c o m*/ * * @author HONGLI * @param filename * @throws DocumentException * @throws IOException */ public void createReport_mysqlNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("hostnamestr"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable oramem = (Hashtable) reportHash.get("memvalue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); DBVo vo = (DBVo) reportHash.get("vo"); String runstr = (String) reportHash.get("runstr"); String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" }; String downnum = (String) reportHash.get("downnum"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL); Font contextFont = new Font(bfChinese, 11, Font.NORMAL); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(8); 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(0);// aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(hostnamestr, contextFont1)); 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(ip)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(typename)); 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(runstr, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String grade = (String) reportHash.get("grade"); cell = new Cell(new Phrase(grade, contextFont1)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); Vector val = (Vector) reportHash.get("Val"); String Max_used_connections = ""; String Table_locks_immediate = ""; String Table_locks_waited = ""; String Key_read_requests = ""; String Key_reads = ""; String log_slow_queries = ""; String Threads_connected = ""; String Open_tables = ""; String Opened_tables = ""; 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=""; Max_used_connections = value; } if (name.equalsIgnoreCase("Table_locks_immediate")) { // name=""; Table_locks_immediate = value; } if (name.equalsIgnoreCase("Table_locks_waited")) { // name=""; Table_locks_waited = value; } if (name.equalsIgnoreCase("Key_read_requests")) { // name=""; Key_read_requests = value; } if (name.equalsIgnoreCase("Key_reads")) { // name=""; Key_reads = value; } if (name.equalsIgnoreCase("log_slow_queries")) { // name=""; log_slow_queries = value; } if (name.equalsIgnoreCase("Threads_connected")) { // name=""; Threads_connected = value; } if (name.equalsIgnoreCase("Open_tables")) { // name=""; Open_tables = value; } if (name.equalsIgnoreCase("Opened_tables")) { // name=""; Opened_tables = value; } } } } 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(Max_used_connections, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Table_locks_immediate, contextFont1)); 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(Table_locks_waited, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Key_read_requests, contextFont1)); 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(Key_reads, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(log_slow_queries, contextFont1)); 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(Threads_connected, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Open_tables, contextFont1)); 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(Opened_tables, contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", contextFont1)); 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); Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); String Threads_cached = ""; String Innodb_buffer_pool_pages_total = ""; String Threads_created = ""; String Uptime = ""; if (tableinfo_v != null) { for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String size = ht.get("variable_name").toString(); String free = ht.get("value").toString(); if (size.equalsIgnoreCase("Threads_cached")) { // size=""; Threads_cached = free; } if (size.equalsIgnoreCase("Innodb_buffer_pool_pages_total")) { // size=""; Innodb_buffer_pool_pages_total = free; } if (size.equalsIgnoreCase("Threads_created")) { // size=""; Threads_created = free; } if (size.equalsIgnoreCase("Uptime")) { // size=":"; Uptime = free; } } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Threads_cached)); 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(Threads_cached)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(Uptime)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(1); 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("")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // // // // SybspaceconfigDao sybspaceconfigDao = new SybspaceconfigDao(); // // List list = null; // try { // list = sybspaceconfigDao.getByIp(ip, 1); // } catch (Exception e) { // SysLogger.error("", e); // } finally { // sybspaceconfigDao.close(); // } // Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(1); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell5); 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("avgpingcon"), contextFont1)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1)); cell.setColspan(2); 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(sysbaseVO.getIdle())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("cpu()", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getCpu_busy())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // cell = new Cell(new Phrase("I/O()", titleFont)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("IO(%)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getIo_busy_rate())); // cell.setColspan(2); // 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(sysbaseVO.getSent_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getReceived_rate())); // cell.setColspan(2); // 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(sysbaseVO.getWrite_rate())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("(/)", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getRead_rate())); // cell.setColspan(2); // 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(sysbaseVO.getDisk_count())); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(sysbaseVO.getLocks_count())); // cell.setColspan(2); // 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(sysbaseVO.getXact_count())); // cell.setColspan(6); // 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("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("MB", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase("%", titleFont)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // // get dbspace message================== // if (sysbaseVO == null) // sysbaseVO = new SybaseVO(); // List dbsizelist = (List) sysbaseVO.getDbInfo(); // int row = 1; // if (dbsizelist != null && dbsizelist.size() > 0) { // for (int i = 0; i < dbsizelist.size(); i++) { // // TablesVO tablesVO = (TablesVO) dbsizelist.get(i); // String dbname = tablesVO.getDb_name(); // for (int j = 0; j < list.size(); j++) { // Sybspaceconfig vo = (Sybspaceconfig) list.get(j); // if (vo.getSpacename().equals(dbname)) { // // String dbsize = tablesVO.getDb_size(); // String freesize = tablesVO.getDb_freesize(); // String userdperc = tablesVO.getDb_usedperc(); // // cell = new Cell(new Phrase(dbname)); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(dbsize)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(freesize)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // cell = new Cell(new Phrase(userdperc)); // cell.setColspan(2); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // // aTable.addCell(cell); // } // } // } // } // String count = (String) reportHash.get("count"); cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1)); cell.setColspan(7); aTable.addCell(cell); cell = new Cell(new Phrase("\n" + "" + "\n", titleFont)); cell.setColspan(8); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); String pinglog = ""; if (!"0".equals(downnum)) { pinglog = " " + "2 " + downnum + ""; } else { pinglog = " " + "2 "; } String spacelog = ""; if (!"0".equals(count)) { spacelog = " " + "3 " + count + "" + " "; } else { spacelog = " " + "3 "; } cell = new Cell(new Phrase(" 1 " + "\n" + "\n" + pinglog + "\n" + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1)); cell.setColspan(8); aTable.addCell(cell); document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_db2Doc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from w ww .j ava2 s . c o m*/ 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 servername = (String) reportHash.get("servername"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable returnhash = (Hashtable) reportHash.get("returnhash"); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); 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(""); 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); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// // document.add(aTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); Enumeration dbs = returnhash.keys(); // List retList = new ArrayList(); List retList = new ArrayList(); Paragraph context1 = null; Table aTable1 = null; while (dbs.hasMoreElements()) { aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 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);// String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); String contextString1 = "DB2:" + obj + "(" + "IP:" + ip + ")"; context1 = new Paragraph(contextString1, contextFont); // context1.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context1.setSpacingBefore(5); // context1.setFirstLineIndent(5); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // /* * Hashtable tableinfo_v = (Hashtable) * reportHash.get("tableinfo_v"); * * String[] dbs1 = servername.split(","); for (int i = 0; i < * tableinfo_v.size(); i++) { List list = (List) * tableinfo_v.get(dbs1[i]); for (int k = 0; k < list.size(); * k++) { * * row = row + 1; Hashtable ht = (Hashtable) list.get(k); if (ht == * null) continue; String spacename = ""; if * (ht.get("tablespace_name") != null) spacename = * ht.get("tablespace_name").toString(); String size = ""; if * (ht.get("totalspac") != null) size = * ht.get("totalspac").toString(); String free = ""; if * (ht.get("usablespac") != null) free = * ht.get("usablespac").toString(); String percent = "---"; if * (ht.get("usableper") != null) percent = * ht.get("usableper").toString(); */ for (int i = 0; i < retList.size(); i++) { Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(spacename, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(context1); document.add(aTable1); } 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.close(); } catch (Exception e) { // TODO: handle exception } }