List of usage examples for org.jfree.chart ChartUtilities writeChartAsPNG
public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReportOra_event(String filename) { if (impReport.getTable() == null) { fileName = null;//from w w w . j a va 2 s . c o m return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); WritableSheet sheet = wb.createSheet("", 0); List memlist = (List) reportHash.get("eventlist"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "IP", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 4, "", _labelFormat); sheet.addCell(tmpLabel); // I_MonitorIpList monitorManager=new MonitoriplistManager(); String ipaddress = (String) memlist.get(0); String typevo = (String) memlist.get(1); String dbname = (String) memlist.get(2); String pingvalue = memlist.get(3) + ""; tmpLabel = new Label(0, 5, 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, ipaddress, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, typevo, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 5, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 5, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 5, pingvalue, p_labelFormat); sheet.addCell(tmpLabel); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReportusa_ora(String filename) { if (impReport.getTable() == null) { fileName = null;//w ww . j ava2 s . c o m return; } WritableWorkbook wb = null; try { fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); 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"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, sheet.addImage(new WritableImage(1, 6, 7, 7, file)); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReportusa_oraPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from w w w .j a va2 s . c o m return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, 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); 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, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new PdfPCell(new Phrase((String) maxping.get("ping"))); cell = new PdfPCell(new Phrase((String) maxping.get("pingmin")));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); 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("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * modify HONG 2010-10-27/*ww w. j a v a2 s . c om*/ */ public void createReport_ora(String filename) { if (impReport.getTable() == null) { fileName = null; return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); 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"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 5, (String) maxping.get("pingnow"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(7, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 14, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 14, "", _labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(11, 14, "", _labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); int row = 14; // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = row + (i); tmpLabel = new Label(1, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 15 + i, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, 15 + i, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(7, 15 + i, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, 15 + i, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 15 + i, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, 15 + i, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(11, 15 + i, status, p_labelFormat); sheet.addCell(tmpLabel); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_db2(String filename) { if (impReport.getTable() == null) { fileName = null;/* w w w . ja v a 2s. c om*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String servername = (String) reportHash.get("servername"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); Hashtable returnhash = (Hashtable) reportHash.get("returnhash"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; // Hashtable returnhash = (Hashtable)reportHash.get("db2space"); Enumeration dbs = returnhash.keys(); // List retList = new ArrayList(); int row = 15; int num = 0; List retList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); retList = (List) returnhash.get(obj); // row = row; tmpLabel = new Label(0, row - 1, "DB2:" + obj + "(" + "IP:" + ip + ")", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(%)", _labelFormat); sheet.addCell(tmpLabel); // String obj = (String)dbs.nextElement(); // retList = (List)returnhash.get(obj); Hashtable tableinfo_v = (Hashtable) reportHash.get("tableinfo_v"); String[] dbs1 = servername.split(","); /* * for(int i=0;i<tableinfo_v.size();i++){ List list= * (List)tableinfo_v.get(dbs1[i]); for(int k=0;k<list.size();k++){ * * row = row+1; Hashtable ht = (Hashtable)list.get(k); if(ht == * null)continue; String spacename = ""; if * (ht.get("tablespace_name")!=null)spacename=ht.get("tablespace_name").toString(); * String size = ""; * if(ht.get("totalspac")!=null)size=ht.get("totalspac").toString(); * String free = ""; * if(ht.get("usablespac")!=null)free=ht.get("usablespac").toString(); * String percent = ""; if(ht.get("usableper")!= * null)percent=ht.get("usableper").toString(); */ for (int i = 0; i < retList.size(); i++) { row = row + 1; Hashtable ht = (Hashtable) retList.get(i); if (ht == null) continue; String spacename = ""; if (ht.get("tablespace_name") != null) spacename = ht.get("tablespace_name").toString(); String size = ""; if (ht.get("totalspac") != null) size = ht.get("totalspac").toString(); String free = ""; if (ht.get("usablespac") != null) free = ht.get("usablespac").toString(); String percent = ""; if (ht.get("usableper") != null) percent = ht.get("usableper").toString(); // row = row + (i); tmpLabel = new Label(0, row, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, spacename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, percent, p_labelFormat); sheet.addCell(tmpLabel); } row = row + 2; } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_syb(String filename) { if (impReport.getTable() == null) { fileName = null;// w ww . j a v a2 s .co m return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; // fileName = CommonAppUtil.getAppName() + // "/temp/hostnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); 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"); WritableFont labelFont = new WritableFont(WritableFont.createFont(""), 12, WritableFont.BOLD, false); WritableCellFormat labelFormat = new WritableCellFormat(labelFont); WritableCellFormat _labelFormat = new WritableCellFormat(); _labelFormat.setBackground(jxl.format.Colour.GRAY_25); WritableCellFormat p_labelFormat = new WritableCellFormat(); p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); WritableCellFormat b_labelFormat = new WritableCellFormat(); b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; tmpLabel = new Label(1, 0, hostname + "", labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + starttime + " " + totime); sheet.addCell(tmpLabel); tmpLabel = new Label(0, 4, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 4, "", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 5, (String) maxping.get("pingmax"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 5, (String) maxping.get("avgpingcon"), p_labelFormat); sheet.addCell(tmpLabel); // File file = new File(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // sheet,0,0,5,1,,, // allRow = allRow+2; sheet.addImage(new WritableImage(1, 6, 7, 7, file)); // allRow = allRow+7; tmpLabel = new Label(0, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 14, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 14, "MB", _labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 14, "", _labelFormat); sheet.addCell(tmpLabel); int row = 14; // SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); if (sysbaseVO == null) sysbaseVO = new SybaseVO(); List dbsizelist = (List) sysbaseVO.getDbInfo(); if (dbsizelist != null && dbsizelist.size() > 0) { for (int i = 0; i < dbsizelist.size(); i++) { TablesVO tablesVO = (TablesVO) dbsizelist.get(i); String dbname = tablesVO.getDb_name(); String dbsize = tablesVO.getDb_size(); String freesize = tablesVO.getDb_freesize(); String userdperc = tablesVO.getDb_usedperc(); row = row + 1; tmpLabel = new Label(0, 15 + i, i + 1 + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 15 + i, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, 15 + i, dbsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, 15 + i, freesize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, 15 + i, userdperc, p_labelFormat); sheet.addCell(tmpLabel); } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } wb.write(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_oraall2(String filename) { if (impReport.getTable() == null) { fileName = null;//from ww w .j ava2s . c o m return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreport_has = new Hashtable(); allreport_has = reportHash; if (allreport_has != null && allreport_has.size() > 0) { Iterator keys = allreport_has.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreport_has.get(ip); reportHash = report_has; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; String hostname = (String) reportHash.get("dbname"); // String ip = (String) reportHash.get("ip"); // String newip = doip(ip); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); 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 buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, reportHash); int row = 18; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "10", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, buffercache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, dictionarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, librarycache, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctmemorysorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pctbufgets, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, opencurstr, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 2, row); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, sysItemch2[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, sysItemch2[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, sysItemch2[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysItemch1[0], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, sysItemch1[1], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, sysItemch1[2], b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, sysItemch1[3], b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; tmpLabel = new Label(0, row, memValue.get(sysItem2[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, memValue.get(sysItem2[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, memValue.get(sysItem2[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, memValue.get(sysItem1[0]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, memValue.get(sysItem1[1]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, memValue.get(sysItem1[2]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, memValue.get(sysItem1[3]) + "MB", p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); // row += 2; tmpLabel = new Label(0, row, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "MB", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START1 tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "", b_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END1 // HONGLI MODIFY START1 tmpLabel = new Label(10, row, "", b_labelFormat); // HONGLI MODIFY END1 sheet.addCell(tmpLabel); // row = row++; Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 for (int i = 0; i < tableinfo_v.size(); i++) { p_labelFormat = super.colorChange(i); Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 tmpLabel = new Label(0, row, String.valueOf(i + 1), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, _filename, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tablespace, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, free, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, percent, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD START4 tmpLabel = new Label(6, row, pyr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, pbr, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, pyw, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, pbw, p_labelFormat); sheet.addCell(tmpLabel); // HONGLI ADD END4 tmpLabel = new Label(10, row, status, p_labelFormat); sheet.addCell(tmpLabel); row++; } // row++; this.addEventReport(sheet, report_has, row); row += 2; // addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } sheetNum++; } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_db2all2(String filename) { if (impReport.getTable() == null) { fileName = null;/*from w w w .ja v a 2 s . c o m*/ return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); reportHash = report_has; String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", 0); String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable conn = (Hashtable) report_has.get("conn");// if (conn == null) conn = new Hashtable(); Hashtable poolInfo = (Hashtable) report_has.get("poolInfo");// if (poolInfo == null) poolInfo = new Hashtable(); Hashtable log = (Hashtable) report_has.get("log");// if (log == null) log = new Hashtable(); Hashtable spaceInfo = (Hashtable) report_has.get("spaceInfo");// if (spaceInfo == null) spaceInfo = new Hashtable(); String[] sysDbStatus = { "", "", "", "" }; Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // WritableFont labelFont = new // WritableFont(WritableFont.createFont(""), 12, // WritableFont.BOLD, // false); // WritableCellFormat labelFormat = new // WritableCellFormat(labelFont); // // WritableCellFormat _labelFormat = new // WritableCellFormat(); // _labelFormat.setBackground(jxl.format.Colour.GRAY_25); // // WritableCellFormat p_labelFormat = new // WritableCellFormat(); // p_labelFormat.setBackground(jxl.format.Colour.ICE_BLUE); // // WritableCellFormat b_labelFormat = new // WritableCellFormat(); // b_labelFormat.setBackground(jxl.format.Colour.GRAY_50); // WritableCellFormat red_labelFormat = new WritableCellFormat(); red_labelFormat.setBackground(jxl.format.Colour.RED); WritableCellFormat orange_labelFormat = new WritableCellFormat(); orange_labelFormat.setBackground(jxl.format.Colour.ORANGE); WritableCellFormat yellow_labelFormat = new WritableCellFormat(); yellow_labelFormat.setBackground(jxl.format.Colour.YELLOW); Label tmpLabel = null; // ip this.dbTitlePing(sheet, ip, report_has); // tmpLabel = new Label(0, 18, "", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, 18, 10, 18); tmpLabel = new Label(0, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, 19, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, 19, "MB ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, 19, " %", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, 19, 4, 19); sheet.mergeCells(5, 19, 6, 19); sheet.mergeCells(7, 19, 8, 19); sheet.mergeCells(9, 19, 10, 19); List toolsdb = (ArrayList) spaceInfo.get("toolsdb"); int row = 20; if (toolsdb != null && toolsdb.size() > 0) { for (int i = 0; i < toolsdb.size(); i++) { Hashtable tempSpace = new Hashtable(); tempSpace = (Hashtable) toolsdb.get(i); String tablespace_name = (String) tempSpace.get("tablespace_name"); String totalspac = (String) tempSpace.get("totalspac"); String usablespac = (String) tempSpace.get("usablespac"); String usableper = (String) tempSpace.get("usableper"); if (usableper == null || "0".equals(totalspac.trim())) { usableper = "100"; } p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tablespace_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, totalspac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, usablespac, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, usableper, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(1, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } row++; // tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "SQL ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs = conn.keys(); Hashtable<String, Object> allhash = new Hashtable(); List poolList = new ArrayList(); while (dbs.hasMoreElements()) { String obj = (String) dbs.nextElement(); List connList = (List) conn.get(obj); for (int i = 0; i < connList.size(); i++) { Hashtable ht = (Hashtable) connList.get(i); String db_name = ht.get("db_name").toString(); String db_path = ht.get("db_path").toString(); String db_status = ht.get("db_status").toString(); String sqlm_elm_last_backup = ht.get("sqlm_elm_last_backup").toString(); String total_cons = ht.get("total_cons").toString(); String connections_top = ht.get("connections_top").toString(); String appls_cur_cons = ht.get("appls_cur_cons").toString(); String failedsql = ht.get("failedsql").toString(); String commitsql = ht.get("commitsql").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, db_path, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, sysDbStatus[Integer.parseInt(db_status)], p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, sqlm_elm_last_backup, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, total_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, connections_top, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, appls_cur_cons, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, failedsql, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, commitsql, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; Enumeration dbs2 = poolInfo.keys(); Hashtable<String, Object> allhash2 = new Hashtable(); List poolList2 = new ArrayList(); while (dbs2.hasMoreElements()) { String obj = (String) dbs2.nextElement(); allhash = (Hashtable) poolInfo.get(obj); poolList = (List) allhash.get("poolValue"); List lockList = (List) allhash.get("lockValue"); List readList = (List) allhash.get("readValue"); List writeList = (List) allhash.get("writeValue"); for (int i = 0; i < poolList.size(); i++) { Hashtable ht = (Hashtable) poolList.get(i); String bp_name = ht.get("bp_name").toString(); String data_hit_ratio = ht.get("data_hit_ratio").toString(); String index_hit_ratio = ht.get("index_hit_ratio").toString(); String BP_hit_ratio = ht.get("BP_hit_ratio").toString(); String Async_read_pct = ht.get("Async_read_pct").toString(); String Direct_RW_Ratio = ht.get("Direct_RW_Ratio").toString(); p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, bp_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, data_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, index_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, BP_hit_ratio, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, Async_read_pct, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(10, row, Direct_RW_Ratio, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs3 = poolInfo.keys(); Hashtable<String, Object> allhash3 = new Hashtable(); List poolList3 = new ArrayList(); while (dbs3.hasMoreElements()) { String obj = (String) dbs3.nextElement(); allhash3 = (Hashtable) poolInfo.get(obj); poolList3 = (List) allhash3.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); List lockList = (List) allhash3.get("lockValue"); List readList = (List) allhash3.get("readValue"); List writeList = (List) allhash3.get("writeValue"); for (int i = 0; i < lockList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) lockList.get(i); String db_name = ht.get("db_name").toString(); String rows_read = ht.get("rows_read").toString(); String rows_selected = ht.get("rows_selected").toString(); String lock_waits = ht.get("lock_waits").toString(); String lock_wait_time = ht.get("lock_wait_time").toString(); String deadlocks = ht.get("deadlocks").toString(); String lock_escals = ht.get("lock_escals").toString(); String total_sorts = ht.get("total_sorts").toString(); String total_sort_time = ht.get("total_sort_time").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, db_name, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_selected, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, lock_waits, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, lock_wait_time, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, deadlocks, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, lock_escals, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, total_sorts, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, total_sort_time, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(9, row, 10, row); row++; } } // row++; tmpLabel = new Label(0, row, " ", labelFormat); sheet.mergeCells(0, row, 10, row); sheet.addCell(tmpLabel); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "(%) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, "(Mb) ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, "/ ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs4 = log.keys(); Hashtable<String, Object> allhash4 = new Hashtable(); List poolList4 = new ArrayList(); int cc = 0; while (dbs4.hasMoreElements()) { String obj = (String) dbs4.nextElement(); List logList = (List) log.get(obj); p_labelFormat = this.colorChange(cc); cc++; for (int i = 0; i < logList.size(); i++) { Hashtable ht = (Hashtable) logList.get(i); String logused = ht.get("logused").toString(); String logspacefree = ht.get("logspacefree").toString(); String pctused = ht.get("pctused").toString(); String maxlogused = ht.get("maxlogused").toString(); String maxsecused = ht.get("maxsecused").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, obj, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, logused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, logspacefree, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, pctused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, maxlogused, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, maxsecused, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; Enumeration dbs5 = poolInfo.keys(); Hashtable<String, Object> allhash5 = new Hashtable(); List poolList5 = new ArrayList(); String obj = null; Hashtable allhash6 = null; List lockList = null; List readList = null; List writeList = null; while (dbs5.hasMoreElements()) { obj = (String) dbs5.nextElement(); allhash6 = (Hashtable) poolInfo.get(obj); poolList = (List) allhash6.get("poolValue"); // System.out.println("poolList size === // "+poolList.size()); lockList = (List) allhash6.get("lockValue"); readList = (List) allhash6.get("readValue"); writeList = (List) allhash6.get("writeValue"); } if (readList != null && readList.size() > 0) { for (int i = 0; i < readList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) readList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // 10 row++; tmpLabel = new Label(0, row, "10 ", labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 10, row); row++; tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, " ", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, " ", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; if (writeList != null && writeList.size() > 0) { for (int i = 0; i < writeList.size(); i++) { p_labelFormat = this.colorChange(i); Hashtable ht = (Hashtable) writeList.get(i); String tbschema = ht.get("tbschema").toString(); String tbname = ht.get("tbname").toString(); String rows_read = ht.get("rows_read").toString(); String rows_written = ht.get("rows_written").toString(); String overflow_accesses = ht.get("overflow_accesses").toString(); String page_reorgs = ht.get("page_reorgs").toString(); tmpLabel = new Label(0, row, (i + 1) + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(1, row, tbschema, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, tbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(3, row, rows_read, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, rows_written, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(7, row, overflow_accesses, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(9, row, page_reorgs, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(3, row, 4, row); sheet.mergeCells(5, row, 6, row); sheet.mergeCells(7, row, 8, row); sheet.mergeCells(9, row, 10, row); row++; } } // row++; this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sqlall2(String filename) { if (impReport.getTable() == null) { fileName = null;//from www .j a va2 s .com return; } WritableWorkbook wb = null; try { // fileName = ResourceCenter.getInstance().getSysPath() + // "temp\\dhcnms_report.xls"; fileName = ResourceCenter.getInstance().getSysPath() + filename; wb = Workbook.createWorkbook(new File(fileName)); Hashtable allreporthash = new Hashtable(); allreporthash = reportHash; if (allreporthash != null && allreporthash.size() > 0) { Iterator keys = allreporthash.keySet().iterator(); String ip = ""; int sheetNum = 0; while (keys.hasNext()) { ip = keys.next().toString(); String newip = doip(ip); Hashtable report_has = (Hashtable) allreporthash.get(ip); // reportHash = report_has; String hostname = (String) report_has.get("dbname"); WritableSheet sheet = wb.createSheet(hostname + "", sheetNum); sheetNum++; String Ping = (String) report_has.get("Ping"); String starttime = (String) report_has.get("starttime"); String totime = (String) report_has.get("totime"); Hashtable mems = (Hashtable) report_has.get("mems");// Hashtable sysValue = (Hashtable) report_has.get("sysValue");// String typename = (String) report_has.get("typename"); String runstr = (String) report_has.get("runstr"); String grade = (String) report_has.get("grade"); String pingnow = (String) report_has.get("pingnow"); String pingmin = (String) report_has.get("pingmin"); String pingconavg = (String) report_has.get("pingconavg"); DBVo vo = (DBVo) report_has.get("vo"); Hashtable maxping = (Hashtable) report_has.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Label tmpLabel = null; this.dbTitlePing(sheet, ip, report_has); int row = 18; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "SQL", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); row++; tmpLabel = new Label(0, row, (String) mems.get("totalMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) mems.get("optMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, (String) mems.get("conMemory"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, (String) mems.get("sqlMem"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, (String) mems.get("lockMem"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); row += 2; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 4, row); sheet.mergeCells(5, row, 7, row); sheet.mergeCells(8, row, 10, row); row++; tmpLabel = new Label(0, row, (String) sysValue.get("productlevel"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, (String) sysValue.get("IsIntegratedSecurityOnly"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(5, row, (String) sysValue.get("IsSingleUser"), p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, (String) sysValue.get("IsClustered"), p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 4, row); sheet.mergeCells(5, row, 7, row); sheet.mergeCells(8, row, 10, row); row += 2; // tmpLabel = new Label(0, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, "", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, "(MB)", b_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, "(%)", b_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); // Hashtable dbValue = (Hashtable) report_has.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); row = row + 1; p_labelFormat = this.colorChange(i); tmpLabel = new Label(0, row, i + "", p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(2, row, dbname, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(4, row, size, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(6, row, usedsize, p_labelFormat); sheet.addCell(tmpLabel); tmpLabel = new Label(8, row, usedperc, p_labelFormat); sheet.addCell(tmpLabel); sheet.mergeCells(0, row, 1, row); sheet.mergeCells(2, row, 3, row); sheet.mergeCells(4, row, 5, row); sheet.mergeCells(6, row, 7, row); sheet.mergeCells(8, row, 10, row); } } // row = row + 2; this.addEventReport(sheet, report_has, row); row += 2; // this.addEventListToExcel(sheet, row); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { SysLogger.error("", ioe); } WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray()); sheet.addImage(wi); } } wb.write(); } } catch (Exception e) { SysLogger.error("", e); } finally { try { if (wb != null) wb.close(); } catch (Exception e) { SysLogger.error("", e); } } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_networkDoc(String file) throws DocumentException, IOException { String runmodel = PollingEngine.getCollectwebflag(); Hashtable CPU = (Hashtable) reportHash.get("CPU"); String Ping = (String) reportHash.get("Ping"); String ip = (String) reportHash.get("ip"); String newip = doip(ip);//from ww w.j a v a2 s . c om Calendar colTime = (Calendar) reportHash.get("time"); Date cc = colTime.getTime(); Vector netifVector = (Vector) reportHash.get("netifVector"); Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash"); List reportports = (List) reportHash.get("reportports"); Vector iprouterVector = (Vector) reportHash.get("iprouterVector"); Hashtable Memory = (Hashtable) reportHash.get("Memory"); Hashtable Disk = (Hashtable) reportHash.get("Disk"); String hostname = (String) reportHash.get("equipname"); Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String[] netIfItemch = { "", "", "", "(M)", "", "", "" }; String[] ipRouterItemch = { "", "", "", "", "", "" }; String[] memoryItem = { "Capability", "Utilization" }; String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" }; String[] diskItemch = { "", "", "", "i-node", "i-node" }; String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" }; String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" }; // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + sdf.format(cc); Paragraph context = new Paragraph(contextString, titleFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); // Table Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black); Table aTable = new Table(4); float[] widths = { 220f, 300f, 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 cellt0 = new Cell(""); cellt0.setBackgroundColor(Color.LIGHT_GRAY); cellt0.setHorizontalAlignment(Element.ALIGN_CENTER); cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE); cellt0.setRowspan(2); Cell cellt1 = new Cell(""); cellt1.setBackgroundColor(Color.LIGHT_GRAY); Cell cellt2 = new Cell(""); cellt2.setBackgroundColor(Color.LIGHT_GRAY); Cell cellt3 = new Cell(""); cellt3.setBackgroundColor(Color.LIGHT_GRAY); aTable.addCell(cellt0); aTable.addCell(cellt1); aTable.addCell(cellt2); aTable.addCell(cellt3); // aTable.addCell("3.2",Ping+"%"); // Cell cellt4 = new Cell(""); // cellt4.setBackgroundColor(Color.LIGHT_GRAY); // aTable.addCell(cellt4); aTable.addCell(Ping + "%"); aTable.addCell((String) maxping.get("pingmax")); aTable.addCell((String) maxping.get("avgpingcon")); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(aTable); document.add(img); // document.add(new Paragraph("\n")); // document.close(); Table aTable1 = new Table(4); float[] width = { 220f, 300f, 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);// aTable1.endHeaders(); cellt0 = new Cell("CPU"); cellt0.setBackgroundColor(Color.LIGHT_GRAY); cellt0.setHorizontalAlignment(Element.ALIGN_CENTER); cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE); cellt1 = new Cell(""); cellt1.setBackgroundColor(Color.LIGHT_GRAY); cellt2 = new Cell(""); cellt2.setBackgroundColor(Color.LIGHT_GRAY); cellt3 = new Cell(""); cellt3.setBackgroundColor(Color.LIGHT_GRAY); aTable1.addCell(cellt0); aTable1.addCell(cellt1); aTable1.addCell(cellt2); aTable1.addCell(cellt3); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); aTable1.addCell((String) CPU.get("cpu") + "%"); aTable1.addCell((String) CPU.get("cpumax")); aTable1.addCell((String) CPU.get("avgcpu")); cellt0.setRowspan(2); Image img1 = Image.getInstance( ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.MIDDLE);// document.add(aTable1); document.add(img1); if (netifVector != null && netifVector.size() > 0) { Table aTable2 = new Table(8); float[] width2 = { 300f, 220f, 220f, 180f, 300f, 180f, 220f, 220f }; aTable2.setWidths(width2); aTable2.setWidth(100); // 100% aTable2.setAlignment(Element.ALIGN_CENTER);// aTable2.setAutoFillEmptyCells(true); // aTable2.setBorderWidth(1); // aTable2.setBorderColor(new Color(0, 125, 255)); // aTable2.setPadding(2);// aTable2.setSpacing(0);// aTable2.setBorder(2);// aTable2.endHeaders(); Cell c = new Cell(""); c.setBackgroundColor(Color.LIGHT_GRAY); c.setRowspan(netifVector.size() + 1); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable2.addCell(c); // // allRow = allRow; for (int i = 0; i < netIfItemch.length; i++) { Cell cell = new Cell(netIfItemch[i]); cell.setBackgroundColor(Color.LIGHT_GRAY); aTable2.addCell(cell); } Color color = new Color(204, 204, 255); // for (int i = 0; i < netifVector.size(); i++) { // aTable2.addCell(""); String[] strs = (String[]) netifVector.get(i); String ifname = strs[1]; String index = strs[0]; for (int j = 0; j < strs.length; j++) { if (j == 1) { String linkuse = ""; if (portconfigHash != null && portconfigHash.size() > 0) { if (portconfigHash.get(ip + ":" + index) != null) linkuse = (String) portconfigHash.get(ip + ":" + index); } Cell cell1 = new Cell(strs[j]); Cell cell2 = new Cell(linkuse); if (i % 2 != 0) { cell1.setBackgroundColor(color); cell2.setBackgroundColor(color); } aTable2.addCell(cell1); aTable2.addCell(cell2); } else if (j > 1) { Cell cell3 = new Cell(strs[j]); if (i % 2 != 0) { cell3.setBackgroundColor(color); } aTable2.addCell(cell3); } else { Cell cell4 = new Cell(strs[j]); if (i % 2 != 0) { cell4.setBackgroundColor(color); } aTable2.addCell(cell4); } } // end } document.add(aTable2); } if ("0".equals(runmodel)) { // if (iprouterVector != null && iprouterVector.size() > 0) { Table aTable3 = new Table(7); float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f }; aTable3.setWidths(width2); aTable3.setWidth(100); // 100% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); aTable3.addCell(""); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Cell cell = new Cell(ipRouterItemch[i]); aTable3.addCell(cell); } // for (int i = 0; i < iprouterVector.size(); i++) { aTable3.addCell(""); /* allRow = allRow + 1; */ IpRouter iprouter = (IpRouter) iprouterVector.get(i); Cell cell = new Cell(iprouter.getIfindex()); aTable3.addCell(cell); Cell cell1 = new Cell(iprouter.getDest()); aTable3.addCell(cell1); Cell cell2 = new Cell(iprouter.getNexthop()); aTable3.addCell(cell2); Cell cell3 = new Cell(iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")]); aTable3.addCell(cell3); Cell cell4 = new Cell(iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")]); aTable3.addCell(cell4); Cell cell5 = new Cell(iprouter.getMask()); aTable3.addCell(cell5); } document.add(aTable3); } } else { // List routerList = (ArrayList) reportHash.get("routerList"); Table aTable3 = new Table(7); float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f }; aTable3.setWidths(width2); aTable3.setWidth(100); // 100% aTable3.setAlignment(Element.ALIGN_CENTER);// aTable3.setAutoFillEmptyCells(true); // aTable3.setBorderWidth(1); // aTable3.setBorderColor(new Color(0, 125, 255)); // aTable3.setPadding(2);// aTable3.setSpacing(0);// aTable3.setBorder(2);// aTable3.endHeaders(); aTable3.addCell(""); // // allRow = allRow+1; for (int i = 0; i < ipRouterItemch.length; i++) { Cell cell = new Cell(ipRouterItemch[i]); aTable3.addCell(cell); } if (routerList != null) { for (int i = 0; i < routerList.size(); i++) { aTable3.addCell(""); RouterNodeTemp iprouter = (RouterNodeTemp) routerList.get(i); Cell cell = new Cell(iprouter.getIfindex()); aTable3.addCell(cell); Cell cell1 = new Cell(iprouter.getDest()); aTable3.addCell(cell1); Cell cell2 = new Cell(iprouter.getNexthop()); aTable3.addCell(cell2); Cell cell3 = new Cell(iprouter.getType()); aTable3.addCell(cell3); Cell cell4 = new Cell(iprouter.getProto()); aTable3.addCell(cell4); Cell cell5 = new Cell(iprouter.getMask()); aTable3.addCell(cell5); } document.add(aTable3); } } // doc if (reportports != null && reportports.size() > 0) { // // aTable4.addCell(""); for (int i = 0; i < reportports.size(); i++) { Table aTable4 = new Table(2); float[] width2 = { 300f, 300f }; aTable4.setWidths(width2); aTable4.setWidth(100); // 100% aTable4.setAlignment(Element.ALIGN_CENTER);// aTable4.setAutoFillEmptyCells(true); // aTable4.setBorderWidth(1); // aTable4.setBorderColor(new Color(0, 125, 255)); // aTable4.setPadding(2);// aTable4.setSpacing(0);// aTable4.setBorder(2);// aTable4.endHeaders(); // SysLogger.info(reportports.get(i).getClass()+"============================================="); com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports .get(i); /* * tmpLabel = new Label(0, allRow, "" + * portconfig.getPortindex() + "(" + portconfig.getName() + * ")", b_labelFormat); * * sheet.addCell(tmpLabel); */ Cell cell = new Cell("" + portconfig.getPortindex() + "(" + portconfig.getName() + ")"); aTable4.addCell(cell); if (portconfig.getLinkuse() == null) portconfig.setLinkuse(""); Cell cell1 = new Cell(":" + portconfig.getLinkuse()); aTable4.addCell(cell1); document.add(aTable4); // Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png"); img2.setAbsolutePosition(0, 0); img2.setAlignment(Image.LEFT);// // sheet,0,0,5,1,,, img2.scalePercent(67); document.add(img2); } } // if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } /* * WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos * .toByteArray()); */ Image img2 = Image.getInstance(baos.toByteArray()); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// img.scalePercent(67); document.add(img2); } document.close(); }