List of usage examples for com.lowagie.text Table setAlignment
public void setAlignment(String alignment)
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_inforNewPDF(String filename) throws DocumentException, IOException { String hostname = (String) reportHash.get("dbname"); String hostnamestr = (String) reportHash.get("dbnamestr"); 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"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); ArrayList dbspaces = new ArrayList(); dbspaces = (ArrayList) dbinfo.get("informixspaces");// DBTypeDao typedao = new DBTypeDao(); DBTypeVo typevo = typedao.findByDbtype("informix"); 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 w w w. j a v a2s . 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 contextFont2 = 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", contextFont2)); 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); 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("", 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("", 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("", 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("", 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("", 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); 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("", 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("", 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); // InformixspaceconfigDao informixspaceconfigDao = new InformixspaceconfigDao(); List list = null; try { list = informixspaceconfigDao.getByIp(ip, 1); } catch (Exception e) { SysLogger.error("", e); } finally { informixspaceconfigDao.close(); } Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont)); cell5.setRowspan(15 + 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("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"))); 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"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // io ArrayList dbabout = new ArrayList(); dbabout = (ArrayList) dbinfo.get("aboutlist");// Hashtable hashtable = new Hashtable(); if (dbabout != null && dbabout.size() > 0) { for (int i = 0; i < dbabout.size(); i++) { Hashtable tablesVO = (Hashtable) dbabout.get(i); String name = ((String) tablesVO.get("name")).trim(); String desc = ""; if ("dskreads".equals(name)) { desc = ""; hashtable.put("dskreads", tablesVO.get("value")); } else if ("bufreads".equals(name)) { desc = ""; hashtable.put("bufreads", tablesVO.get("value")); } else if ("dskwrites".equals(name)) { desc = ""; hashtable.put("dskwrites", tablesVO.get("value")); } else if ("bufwrites".equals(name)) { desc = ""; hashtable.put("bufwrites", tablesVO.get("value")); } else if ("isamtot".equals(name)) { desc = ""; hashtable.put("isamtot", tablesVO.get("value")); } else if ("isopens".equals(name)) { desc = "isopen"; hashtable.put("isopens", tablesVO.get("value")); } else if ("isstarts".equals(name)) { desc = "isstart"; hashtable.put("isstarts", tablesVO.get("value")); } else if ("isreads".equals(name)) { desc = "isread"; hashtable.put("isreads", tablesVO.get("value")); } else if ("iswrites".equals(name)) { desc = "iswirte"; hashtable.put("iswrites", tablesVO.get("value")); } else if ("isrewrites".equals(name)) { desc = "isrewrite"; hashtable.put("isrewrites", tablesVO.get("value")); } else if ("isdeletes".equals(name)) { desc = "isdelete"; hashtable.put("isdeletes", tablesVO.get("value")); } else if ("iscommits".equals(name)) { desc = "iscommit"; hashtable.put("iscommits", tablesVO.get("value")); } else if ("isrollbacks".equals(name)) { desc = "isrollback"; hashtable.put("isrollbacks", tablesVO.get("value")); } else if ("ovlock".equals(name)) { desc = ""; hashtable.put("ovlock", tablesVO.get("value")); } else if ("ovuser".equals(name)) { desc = ""; hashtable.put("ovuser", tablesVO.get("value")); } else if ("ovtrans".equals(name)) { desc = ""; hashtable.put("ovtrans", tablesVO.get("value")); } else if ("latchwts".equals(name)) { desc = ""; hashtable.put("latchwts", tablesVO.get("value")); } else if ("buffwts".equals(name)) { desc = ""; hashtable.put("buffwts", tablesVO.get("value")); } else if ("lockreqs".equals(name)) { desc = ""; hashtable.put("lockreqs", tablesVO.get("value")); } else if ("lockwts".equals(name)) { desc = ""; hashtable.put("lockwts", tablesVO.get("value")); } else if ("ckptwts".equals(name)) { desc = ""; hashtable.put("ckptwts", tablesVO.get("value")); } else if ("deadlks".equals(name)) { desc = ""; hashtable.put("deadlks", tablesVO.get("value")); } else if ("lktouts".equals(name)) { desc = ""; hashtable.put("lktouts", tablesVO.get("value")); } else if ("numckpts".equals(name)) { desc = ""; hashtable.put("numckpts", tablesVO.get("value")); } else if ("plgpagewrites".equals(name)) { desc = ""; hashtable.put("plgpagewrites", tablesVO.get("value")); } else if ("plgwrites".equals(name)) { desc = ""; hashtable.put("plgwrites", tablesVO.get("value")); } else if ("llgrecs".equals(name)) { desc = ""; hashtable.put("llgrecs", tablesVO.get("value")); } else if ("llgpagewrites".equals(name)) { desc = ""; hashtable.put("llgpagewrites", tablesVO.get("value")); } else if ("llgwrites".equals(name)) { desc = ""; hashtable.put("llgwrites", tablesVO.get("value")); } else if ("pagreads".equals(name)) { desc = ""; hashtable.put("pagreads", tablesVO.get("value")); } else if ("pagwrites".equals(name)) { desc = ""; hashtable.put("pagwrites", tablesVO.get("value")); } else if ("flushes".equals(name)) { desc = ""; hashtable.put("flushes", tablesVO.get("value")); } else if ("compress".equals(name)) { desc = ""; hashtable.put("compress", tablesVO.get("value")); } else if ("fgwrites".equals(name)) { desc = ""; hashtable.put("fgwrites", tablesVO.get("value")); } else if ("lruwrites".equals(name)) { desc = "LRU"; hashtable.put("lruwrites", tablesVO.get("value")); } else if ("chunkwrites".equals(name)) { desc = ""; hashtable.put("chunkwrites", tablesVO.get("value")); } else if ("btradata".equals(name)) { desc = ""; hashtable.put("btradata", tablesVO.get("value")); } else if ("btraidx".equals(name)) { desc = ""; hashtable.put("btraidx", tablesVO.get("value")); } else if ("dpra".equals(name)) { desc = ""; hashtable.put("dpra", tablesVO.get("value")); } else if ("rapgs_used".equals(name)) { desc = ""; hashtable.put("rapgs_used", tablesVO.get("value")); } else if ("seqscans".equals(name)) { desc = ""; hashtable.put("seqscans", tablesVO.get("value")); } else if ("totalsorts".equals(name)) { desc = ""; hashtable.put("totalsorts", tablesVO.get("value")); } else if ("memsorts".equals(name)) { desc = ""; hashtable.put("memsorts", tablesVO.get("value")); } else if ("disksorts".equals(name)) { desc = ""; hashtable.put("disksorts", tablesVO.get("value")); } else if ("maxsortspace".equals(name)) { desc = ""; hashtable.put("maxsortspace", tablesVO.get("value")); } } } cell = new Cell(new Phrase("IO", titleFont)); cell.setRowspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskreads"))); 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) hashtable.get("bufreads"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("dskwrites"))); 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) hashtable.get("bufwrites"))); 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); 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); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isamtot"), contextFont1)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isopen")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isopens"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isstart")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isstarts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isread")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isreads"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iswirte")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iswrites"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrewrite")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrewrites"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isdelete")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isdeletes"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("iscommit")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("iscommits"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("isrollback")); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("isrollbacks"))); 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("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("latchwts"))); 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) hashtable.get("buffwts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lockreqs"))); 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) hashtable.get("lockwts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("ckptwts"))); 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) hashtable.get("deadlks"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) hashtable.get("lktouts"))); 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) hashtable.get("numckpts"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(list.size() + 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("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.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // get dbspace message================== int row = 0; DecimalFormat df = new DecimalFormat("#.###"); if (dbspaces != null && dbspaces.size() > 0) { for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); double all = 100.00; double show = all - Double.parseDouble(tablesVO.get("percent_free").toString()); String str = df.format(show) + ""; String spacenameString = (String) tablesVO.get("dbspace"); for (int j = 0; j < list.size(); j++) { Informixspaceconfig vo = (Informixspaceconfig) list.get(j); DBDao dbdao = new DBDao(); // dbdao = new DBDao(); List shareList = null; try { shareList = dbdao.getDbByTypeAndIpaddress(typevo.getId(), vo.getIpaddress()); } catch (Exception e) { } finally { dbdao.close(); } if (shareList == null || shareList.size() == 0) continue; DBVo dbvo = (DBVo) shareList.get(0); if (spacenameString.equals(vo.getSpacename())) { cell = new Cell(new Phrase(spacenameString)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("pages_size"))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")))); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(str)); 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 "; } 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_faworklistdoc(String filename, User user) throws DocumentException, IOException { // // ww w. j a v a 2s. co m 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); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); // document.add(new Paragraph("\n")); Table aTable = new Table(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 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; NodeMonitorDao nmdao = new NodeMonitorDao(); List moidlist = new ArrayList(); try { moidlist = nmdao.loadByBID(user.getBusinessids()); } catch (Exception e) { } finally { nmdao.close(); } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); 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); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); try { vo = dao.loadHost(nm.getNodeID()); } catch (Exception e) { } finally { dao.close(); } String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime0() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_faworklistsearchdoc(String filename) throws DocumentException, IOException { // /*from ww w. j av a 2 s .co m*/ 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); Paragraph title = new Paragraph("", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); // document.add(new Paragraph("\n")); Table aTable = new Table(13); float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 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; List moidlist = (List) reportHash.get("list"); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("()", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); 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); if (moidlist != null) { for (int i = 0; i < moidlist.size(); i++) { NodeMonitor nm = (NodeMonitor) moidlist.get(i); HostNode vo = new HostNode(); HostNodeDao dao = new HostNodeDao(); vo = dao.loadHost(nm.getNodeID()); String enable = ""; if (!nm.isEnabled()) enable = ""; if (vo == null) continue; dao.close(); String sms0 = ""; if (nm.getSms0() == 0) sms0 = ""; String sms1 = ""; if (nm.getSms1() == 0) sms1 = ""; String sms2 = ""; if (nm.getSms2() == 0) sms2 = ""; cell = new Cell(new Phrase(i + 1 + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getDescr(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(enable, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime0() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms0, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms1, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(nm.getTime1() + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(sms2, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI DB2 doc//from w ww .ja v a 2 s. c o m * @param filename * @throws DocumentException * @throws IOException */ public void createReportDB2SelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(5); float[] width = { 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("(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 spaceInfo = (Hashtable) reportHash.get("spaceInfo"); if (spaceInfo.get("toolsdb") != null) { List toolsdb = (ArrayList) spaceInfo.get("toolsdb");// if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = (Hashtable) toolsdb.get(i); String SYSCATSPACE = tempSpace.get("tablespace_name") + ""; String totalspac = tempSpace.get("totalspac") + ""; String usablespac = tempSpace.get("usablespac") + ""; String usableper = (String) tempSpace.get("usableper"); if (usableper == null || usableper.trim().equals("")) { usableper = "0"; } 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(SYSCATSPACE, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(totalspac, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usablespac, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usableper, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI Sybase doc/*from w ww.j av a2 s .c o m*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReportSybaseSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); 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(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); // List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new Cell(new Phrase((i + 1) + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_name, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_freesize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_usedperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(spaceTable); document.close(); } catch (Exception e) { SysLogger.error("ExcelReport1.createReportDB2SelfDoc()"); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI Sybaseword//from w w w .ja v a 2 s.co m * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SybaseCldDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); 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"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); 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 dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", 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(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_freesize, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_usedperc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } document.add(spaceTable); // Table memTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; memTable.setWidths(dbInfoWidths); memTable.setWidth(100); // 90% memTable.setAlignment(Element.ALIGN_CENTER);// memTable.setAutoFillEmptyCells(true); // memTable.setBorderWidth(1); // memTable.setBorderColor(new Color(0, 125, 255)); // memTable.setPadding(2);// memTable.setSpacing(0);// memTable.setBorder(2);// Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(%) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); document.add(memTable); // Sysbase Table remoteServerTable = new Table(5); float[] remoteServerWidths = { 220f, 220f, 220f, 220f, 220f }; remoteServerTable.setWidths(remoteServerWidths); remoteServerTable.setWidth(100); // 90% remoteServerTable.setAlignment(Element.ALIGN_CENTER);// remoteServerTable.setAutoFillEmptyCells(true); // remoteServerTable.setBorderWidth(1); // remoteServerTable.setBorderColor(new Color(0, 125, 255)); // remoteServerTable.setPadding(2);// remoteServerTable.setSpacing(0);// remoteServerTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase("Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); cell = new Cell(new Phrase((k + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_network_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_class(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_status(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); } } document.add(remoteServerTable); Table userTable = new Table(5); float[] uWidth = { 220f, 220f, 220f, 220f, 220f }; userTable.setWidths(uWidth); userTable.setWidth(100); // 90% userTable.setAlignment(Element.ALIGN_CENTER);// userTable.setAutoFillEmptyCells(true); // userTable.setBorderWidth(1); // userTable.setBorderColor(new Color(0, 125, 255)); // userTable.setPadding(2);// userTable.setSpacing(0);// userTable.setBorder(2);// cell = new Cell(new Phrase(" Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase("id ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); // userTable.endHeaders(); List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); cell = new Cell(new Phrase((k + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getUsers_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getID_in_db(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getGroup_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getLogin_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); } } document.add(userTable); 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); } // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI Informix doc/* w w w. j a va 2 s . co m*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReportInformixSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); // Informix Table spaceTable = new Table(8); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } } document.add(spaceTable); // Informix Table hhTable = new Table(8); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hhTable.setWidths(hhWidth); hhTable.setWidth(100); // 90% hhTable.setAlignment(Element.ALIGN_CENTER);// hhTable.setAutoFillEmptyCells(true); // hhTable.setBorderWidth(1); // hhTable.setBorderColor(new Color(0, 125, 255)); // hhTable.setPadding(2);// hhTable.setSpacing(0);// hhTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(seqscans, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(total_sorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(dsksorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); } } document.add(hhTable); // Informix Table lockTable = new Table(6); float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidth); lockTable.setWidth(100); // 90% lockTable.setAlignment(Element.ALIGN_CENTER);// lockTable.setAutoFillEmptyCells(true); // lockTable.setBorderWidth(1); // lockTable.setBorderColor(new Color(0, 125, 255)); // lockTable.setPadding(2);// lockTable.setSpacing(0);// lockTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(desc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); 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) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI date 2010-11-11 doc//from ww w. j a v a2s.c o m */ public void createReportPingDoc(String filename) { 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 dbtype = (String) reportHash.get("dbtype"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // System.out.println("newi ========================"+newip); Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", 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.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Table aTable = new Table(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", 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 = new Cell(new Phrase(reportHash.get("pingnow") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("ping"),contextFont)); cell = new Cell(new Phrase(reportHash.get("pingmin") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(reportHash.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"); document.add(aTable); document.add(img); document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI word/*from www . j a v a 2 s.c o m*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReport_EventDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); DBVo vo = (DBVo) reportHash.get("vo"); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; 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 dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(vo.getDbName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); document.add(dbTable); addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI MySQL doc/*from w w w . j av a2 s. c om*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(2); float[] width = { 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new Cell(new Phrase(name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(value, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } }