Example usage for com.lowagie.text Cell setColspan

List of usage examples for com.lowagie.text Cell setColspan

Introduction

In this page you can find the example usage for com.lowagie.text Cell setColspan.

Prototype

public void setColspan(int value) 

Source Link

Document

Sets the colspan.

Usage

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_networkNewDoc(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();//ww w.j a v a2s.  co  m
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");

    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc");
    String startdate = (String) reportHash.get("startdate");
    String todate = (String) reportHash.get("todate");
    String starttime = (String) reportHash.get("starttime");
    String avginput = (String) reportHash.get("avginput");
    String avgoutput = (String) reportHash.get("avgoutput");
    String maxinput = (String) reportHash.get("maxinput");
    String maxoutput = (String) reportHash.get("maxoutput");

    int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue();

    int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    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, 12, Font.BOLD);
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(equipnameNetDoc, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell = new Cell(new Phrase(avgcpu, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", contextFont));
    cell.setColspan(2);
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("(KB/S)", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strutil = "";
    String strping = "";
    String strupdown = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (utilvalue > 0) {
        strutil = "3   " + utilvalue
                + "" + "\n"
                + "\n";
    } else {
        strutil = "    3   " + "\n" + "\n";
    }
    if (updownvalue > 0) {
        strupdown = "    4   " + updownvalue + "" + "\n"
                + "\n";
    } else {
        strupdown = "    4   " + "\n" + "\n";
    }
    if (pingvalue > 0) {

        strping = "    5   " + pingvalue + "";
    } else {
        strping = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strutil + strupdown + strping + "\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_networkNewPdf(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();/*from   w  w  w  .  j a  v a 2s.c  o  m*/
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");

    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc");
    String startdate = (String) reportHash.get("startdate");
    String todate = (String) reportHash.get("todate");
    String starttime = (String) reportHash.get("starttime");
    String avginput = (String) reportHash.get("avginput");
    String avgoutput = (String) reportHash.get("avgoutput");
    String maxinput = (String) reportHash.get("maxinput");
    String maxoutput = (String) reportHash.get("maxoutput");

    int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue();

    int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    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 contextFont2 = new Font(bfChinese, 10, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    aTable.setWidths(widths);
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont2));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(equipnameNetDoc, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    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.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("(KB/S)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strutil = "";
    String strping = "";
    String strupdown = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (utilvalue > 0) {
        strutil = "3   " + utilvalue
                + "" + "\n"
                + "\n";
    } else {
        strutil = "    3   " + "\n" + "\n";
    }
    if (updownvalue > 0) {
        strupdown = "    4   " + updownvalue + "" + "\n"
                + "\n";
    } else {
        strupdown = "    4   " + "\n" + "\n";
    }
    if (pingvalue > 0) {

        strping = "    5   " + pingvalue + "";
    } else {
        strping = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strutil + strupdown + strping + "\n" + "\n" + "\n", contextFont)

    );

    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_networkchoce(String starttime, String totime, String file, String username,
        String positionname) throws DocumentException, IOException {

    Hashtable allreporthash = new Hashtable();
    allreporthash = reportHash;/* w  ww . j a va2 s  . c  o m*/
    /*
     * String starttime = (String) reportHash.get("starttime"); String
     * totime = (String) reportHash.get("totime");
     */

    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 titleFont1 = new Font(bfChinese, 14, Font.BOLD);
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    String runAppraise = "";
    if (dataHash.containsKey("runAppraise")) {
        runAppraise = (String) dataHash.get("runAppraise");
    }
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + file;
        Table aTable = new Table(15);
        float[] widths = { 60f, 60f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f };
        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("", titleFont1));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(15);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell("");
        cell = new Cell("" + starttime + "" + totime);
        cell.setColspan(14);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(username, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(3);

        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(positionname, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(3);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        aTable.addCell(cell);
        cell = new Cell(runAppraise);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(4);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3 + allreporthash.size());
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("IP", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("CPU(%)", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("(KB/S)", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("()", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        fileName = ResourceCenter.getInstance().getSysPath() + file;

        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            while (keys.hasNext()) {
                ip = keys.next().toString();
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String hostname = (String) report_has.get("equipname");
                // WritableSheet sheet = wb.createSheet(hostname+"",
                // sheetNum);

                Hashtable CPU = (Hashtable) report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");
                // Hashtable maxping = (Hashtable)
                // report_has.get("maxping");
                String newip = doip(ip);
                Calendar colTime = Calendar.getInstance();
                Date cc = colTime.getTime();
                Vector netifVector = (Vector) report_has.get("netifVector");
                Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash");
                List reportports = (List) report_has.get("reportports");
                Vector iprouterVector = (Vector) report_has.get("iprouterVector");

                Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
                Hashtable maxping = (Hashtable) report_has.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)" };
                String avginput = (String) report_has.get("avginput");
                String avgoutput = (String) report_has.get("avgoutput");
                String maxinput = (String) report_has.get("maxinput");
                String maxoutput = (String) report_has.get("maxoutput");

                String levelone = (String) report_has.get("levelone");
                String levletwo = (String) report_has.get("levletwo");
                String levelthree = (String) report_has.get("levelthree");
                /*
                 * String starttime = (String)report_has.get("starttime");
                 * String totime = (String)report_has.get("totime");
                 */
                cell = new Cell(ip);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(hostname);
                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((String) CPU.get("avgcpu"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell((String) CPU.get("cpumax"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell("");
                aTable.addCell(cell);
                cell = new Cell("");
                aTable.addCell(cell);
                cell = new Cell(avgoutput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(maxoutput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(avginput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(maxinput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levelone);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levletwo);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levelthree);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                /*
                 * cell = (Cell)aTable.getElement(1, 1); cell.add(new
                 * Phrase(""+starttime+""+totime,contextFont));
                 */
            }
        }

        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(15);
        aTable.addCell(cell);
        String businessAnalytics = "";
        if (dataHash.containsKey("businessAnalytics")) {
            businessAnalytics = (String) dataHash.get("businessAnalytics");
        }
        cell = new Cell(businessAnalytics);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(15);
        cell.setRowspan(6);
        aTable.addCell(cell);
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_hostchoce(String starttime, String totime, String file, String username,
        String positionname) throws DocumentException, IOException {
    Hashtable allreporthash = new Hashtable();
    allreporthash = reportHash;/*from   ww  w .  j  av a  2 s.  c  om*/
    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 titleFont1 = new Font(bfChinese, 14, Font.BOLD);
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 14, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);

    fileName = ResourceCenter.getInstance().getSysPath() + file;
    Table aTable = new Table(13);
    float[] widths = { 60f, 100f, 30f, 30f, 30f, 30f, 30f, 30f, 50f, 50f, 30f, 30f, 30f };
    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("", titleFont1));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(13);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell("");
    cell = new Cell(new Phrase("" + starttime + "" + totime, contextFont));
    cell.setColspan(12);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell(new Phrase(username,contextFont));
    cell = new Cell(new Phrase(username, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell.setColspan(4);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell(new Phrase(positionname,contextFont));
    cell = new Cell(new Phrase(positionname, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell.setColspan(4);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String runAppraise = "";
    if (dataHash.containsKey("runAppraise")) {
        runAppraise = (String) dataHash.get("runAppraise");
    }
    // cell = new Cell(new Phrase(positionname,contextFont));
    cell = new Cell(new Phrase(runAppraise, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2 + allreporthash.size());
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(%)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("CPU(%)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("TOP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("()", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    java.text.NumberFormat formate = java.text.NumberFormat.getNumberInstance();
    formate.setMaximumFractionDigits(0);//
    fileName = ResourceCenter.getInstance().getSysPath() + file;
    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);
            String hostname = (String) report_has.get("equipname");
            Hashtable CPU = (Hashtable) report_has.get("CPU");
            String Ping = (String) report_has.get("Ping");
            Calendar colTime = (Calendar) report_has.get("time");
            Date cc = colTime.getTime();
            Hashtable Memory = (Hashtable) report_has.get("Memory");
            Hashtable Disk = (Hashtable) report_has.get("Disk");

            Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
            Hashtable memAvgHash = (Hashtable) report_has.get("memavghash");
            Hashtable maxping = (Hashtable) report_has.get("ping");

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            String[] memoryItemch = { "", "", "", "" };
            String[] memoryItem = { "Capability", "c" };
            String[] diskItem = { "AllSize", "UsedSize", "Utilization", "Utilizationvalue" };
            String[] diskItemch = { "", "", "" };

            String levelone = (String) report_has.get("levelone");
            String levletwo = (String) report_has.get("levletwo");
            String levelthree = (String) report_has.get("levelthree");
            cell = new Cell(new Phrase(ip, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            // =======
            String string1 = ((String) maxping.get("pingmax")).replace("%", "");
            String string2 = ((String) maxping.get("avgpingcon")).replace("%", "");
            // formate.format(Double.valueOf(string1));
            // System.out.println(formate.format(Double.valueOf(string))+"@@@@@@@0000000000");
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string1)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string2)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            String cpu = "";
            if (CPU.get("cpu") != null)
                cpu = (String) CPU.get("cpu");
            String cpumax = "";
            if (CPU.get("cpumax") != null)
                cpumax = (String) CPU.get("cpumax");
            String avgcpu = "";
            if (CPU.get("avgcpu") != null)
                avgcpu = (String) CPU.get("avgcpu");
            String string3 = avgcpu.replace("%", "");
            String string4 = cpumax.replace("%", "");

            cell = new Cell(new Phrase(formate.format(Double.valueOf(string3)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string4)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            String avgvalue = "0.0%";
            if (memAvgHash.get("PhysicalMemory") != null) {

                avgvalue = (String) memAvgHash.get("PhysicalMemory");
                String string5 = avgvalue.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            } else {
                String string5 = avgvalue.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            String value = "0.0%";
            if (memMaxHash.get("PhysicalMemory") != null) {

                value = (String) memMaxHash.get("PhysicalMemory");
                String string6 = value.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            } else {
                String string6 = value.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            String value1 = "0";
            String name = "";
            String Utilization = "";
            if (Disk != null && Disk.size() > 0) {
                for (int i = 0; i < Disk.size(); i++) {
                    Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
                    if (diskhash.get(diskItem[3]) != null) {
                        if (value1.compareTo((String) diskhash.get(diskItem[3])) < 0) {
                            value1 = (String) diskhash.get(diskItem[3]);
                            name = (String) diskhash.get("name");
                            Utilization = (String) diskhash.get(diskItem[2]);
                        }
                    }
                }
                cell = new Cell(name + "  " + Utilization);
                cell.setColspan(2);
                aTable.addCell(cell);

            } else {
                cell = new Cell("---");
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            cell = new Cell(new Phrase(levelone, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(levletwo, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(levelthree, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
        }
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(13);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String businessAnalytics = "";
    if (dataHash.containsKey("businessAnalytics")) {
        businessAnalytics = (String) dataHash.get("businessAnalytics");
    }
    cell = new Cell(businessAnalytics);
    cell.setColspan(13);
    cell.setRowspan(6);
    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 oracleword/*from w  w  w  .  j  a  va 2 s  .  c  om*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportOracleCldDoc(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 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");

        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.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 dbInfoTable = new Table(6);
        float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        dbInfoTable.setWidths(dbInfoWidths);
        dbInfoTable.setWidth(100); //  90%
        dbInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        dbInfoTable.setAutoFillEmptyCells(true); // 
        dbInfoTable.setBorderWidth(1); // 
        dbInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        dbInfoTable.setPadding(2);// 
        dbInfoTable.setSpacing(0);// 
        dbInfoTable.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        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");
            }
        }
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("10", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(buffercache, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(dictionarycache, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(librarycache, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(pctmemorysorts, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(pctbufgets, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(opencurstr, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbInfoTable.addCell(cell);
        document.add(dbInfoTable);

        // 
        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" };
        Table ncTable = new Table(7);
        float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // HONGLI MODIFY END1
        ncTable.setWidths(ncWidths);
        ncTable.setWidth(100); //  90%
        ncTable.setAlignment(Element.ALIGN_CENTER);// 
        ncTable.setAutoFillEmptyCells(true); // 
        ncTable.setBorderWidth(1); // 
        ncTable.setBorderColor(new Color(0, 125, 255)); // 
        ncTable.setPadding(2);// 
        ncTable.setSpacing(0);// 
        ncTable.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[0], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[1], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[2], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[0], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[1], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[2], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[3], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        document.add(ncTable);

        // HONGLI MODIFY START1 
        Table aTable1 = new Table(11);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // HONGLI MODIFY END1
        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(11);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", 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);
        // HONGLI ADD START1
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // HONGLI ADD END1

        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");

        // HONGLI ADD START2
        Hashtable dbio = (Hashtable) reportHash.get("dbio");
        // HONGLI ADD END2

        int row = 0;
        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 = i + 1;
            String rowStr = "" + row;
            cell = new Cell(new Phrase(rowStr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(_filename, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(tablespace, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(size, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(free, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(percent, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

            // HONGLI ADD START4
            cell = new Cell(new Phrase(pyr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pyw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // HONGLI ADD END4

            cell = new Cell(new Phrase(status, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

        }
        document.add(aTable1);

        //    
        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 = String.valueOf(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);

        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

/**
 * @author HONGLI oraclepdf/* w  ww  . j a v  a 2s.  c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportOracleCldPdf(String filename, String type) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        if ("pdf".equals(type)) {
            PdfWriter.getInstance(document, new FileOutputStream(filename));
        } else {
            RtfWriter2.getInstance(document, new FileOutputStream(filename));
        }
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font 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");

        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        Table dbTable = new Table(5);
        this.setTableFormat(dbTable);
        Cell dbCell = null;
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("IP", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(vo.getDbName(), contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(ip, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(typename, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(runstr, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(grade, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);

        Table aTable = new Table(3);
        this.setTableFormat(aTable);
        // float[] widths = { 220f, 220f, 220f };
        // aTable.setWidths(widths);
        // aTable.setWidthPercentage(100);
        Cell cell = null;
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingnow + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingmin + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingconavg + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        // img.setAbsolutePosition(0, 0);
        img.scalePercent(76);
        img.setAlignment(Image.MIDDLE);// 
        document.add(dbTable);
        document.add(new Paragraph("\n"));
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        //  
        Table dbInfoTable = new Table(6);
        this.setTableFormat(dbInfoTable);
        // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        // dbInfoTable.setWidths(dbInfoWidths);
        // dbInfoTable.setWidthPercentage(100);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(6);
        dbInfoTable.addCell(cell);
        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");
            }
        }
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("10", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(buffercache, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(dictionarycache, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(librarycache, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(pctmemorysorts, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(pctbufgets, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(opencurstr, contextFont));
        this.setCellFormat(cell, false);
        dbInfoTable.addCell(cell);
        document.add(dbInfoTable);
        document.add(new Paragraph("\n"));

        // 
        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" };
        Table ncTable = new Table(7);
        this.setTableFormat(ncTable);
        // float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        // HONGLI MODIFY END1
        // ncTable.setWidths(ncWidths);
        // ncTable.setWidthPercentage(100);
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(7);
        this.setCellFormat(cell, true);
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[0], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[1], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch2[2], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[0], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[1], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[2], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(sysItemch1[3], titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ncTable.addCell(cell);
        document.add(ncTable);
        document.add(new Paragraph("\n"));

        // HONGLI MODIFY START1 
        Table aTable1 = new Table(11);
        float[] arg0 = { 10f, 20f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f };
        aTable1.setWidths(arg0);
        this.setTableFormat(aTable1);
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(11);
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // HONGLI ADD START1
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // HONGLI ADD END1

        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");

        // HONGLI ADD START2
        Hashtable dbio = (Hashtable) reportHash.get("dbio");
        // HONGLI ADD END2

        int row = 0;
        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 = i + 1;
            String rowStr = "" + row;
            cell = new Cell(new Phrase(rowStr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(_filename, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(tablespace, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(size, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(free, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(percent, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

            // HONGLI ADD START4
            cell = new Cell(new Phrase(pyr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbr, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pyw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            cell = new Cell(new Phrase(pbw, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);
            // HONGLI ADD END4

            cell = new Cell(new Phrase(status, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable1.addCell(cell);

        }
        document.add(aTable1);

        // 
        document.add(new Paragraph("\n"));
        Table eventTable = new Table(2);
        this.setTableFormat(eventTable);
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, true);
        eventTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        eventTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        eventTable.addCell(cell);
        cell = new Cell(new Phrase((String) reportHash.get("downnum"), contextFont));
        this.setCellFormat(cell, false);
        eventTable.addCell(cell);
        cell = new Cell(new Phrase(reportHash.get("count") + "", contextFont));
        this.setCellFormat(cell, false);
        eventTable.addCell(cell);
        document.add(eventTable);

        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(new Paragraph("\n"));
        // 
        addEventLisToPdf(document);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_oraNewDoc(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");
    String runstr = (String) reportHash.get("runstr");
    // String[] sysItem1 = { "shared pool", "large pool", "buffer cache",
    // "java pool" };
    String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" };
    String downnum = (String) reportHash.get("downnum");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(filename));
    document.open();//from www  .  j a  v  a  2  s.c o m
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    Cell cell = null;

    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnamestr, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(runstr, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase(grade, contextFont1));
    cell.setColspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(4);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("SGA(MB)", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    // SGA
    String valueall = "---";
    String valuebig = "---";
    String valuebuffer = "---";
    String valuejava = "---";
    if (oramem != null) {

        if (oramem.get(sysItem1[0]) != null) {
            valueall = (String) oramem.get(sysItem1[0]);
        }
        if (oramem.get(sysItem1[1]) != null) {
            valuebig = (String) oramem.get(sysItem1[1]);
        }
        if (oramem.get(sysItem1[2]) != null) {
            valuebuffer = (String) oramem.get(sysItem1[2]);
        }
        if (oramem.get(sysItem1[3]) != null) {
            valuejava = (String) oramem.get(sysItem1[3]);
        }
    }
    // SGA END

    cell = new Cell(new Phrase(valueall, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(valuebig, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(valuebuffer, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("Java", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(valuejava, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("PGA(MB)", titleFont));
    cell.setRowspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated",
            "cache_hit_percentage", "bytes_processed", "extra_bytes_read/written", "recompute_count_(total)" };
    String valuepgaall = "---";
    String valuepganow = "---";
    String valuepgabig = "---";
    if (oramem != null) {

        if (oramem.get(sysItem2[0]) != null) {
            valuepgaall = (String) oramem.get(sysItem2[0]);
        }
        if (oramem.get(sysItem2[1]) != null) {
            valuepganow = (String) oramem.get(sysItem2[1]);
        }
        if (oramem.get(sysItem2[2]) != null) {
            valuepgabig = (String) oramem.get(sysItem2[2]);
        }
    }

    cell = new Cell(new Phrase("PGA", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);

    if (!"---".equals(valuepgaall)) {
        valuepgaall = CEIString.round(Double.valueOf(valuepgaall.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepgaall, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("PGA", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    if (!"---".equals(valuepganow)) {
        valuepganow = CEIString.round(Double.valueOf(valuepganow.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepganow, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("PGA", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    if (!"---".equals(valuepgabig)) {
        valuepgabig = CEIString.round(Double.valueOf(valuepgabig.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepgabig, 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);
    // 
    Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");
    OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao();
    List list = null;
    try {
        list = oraspaceconfigDao.getByIp(ip, 1);
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        oraspaceconfigDao.close();
    }
    Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell5.setRowspan(2 + list.size());
    this.setCellFormat(cell, true);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(MB)", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(%)", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    // ====

    int row = 0;
    for (int i = 0; i < tableinfo_v.size(); i++) {
        Hashtable ht = (Hashtable) tableinfo_v.get(i);
        String tablespace = ht.get("tablespace").toString();
        for (int j = 0; j < list.size(); j++) {
            Oraspaceconfig vo1 = (Oraspaceconfig) list.get(j);
            if (vo1.getSpacename().equals(tablespace)) {
                String size = ht.get("size_mb").toString();
                String percent = ht.get("percent_free").toString();
                String status = ht.get("status").toString();

                cell = new Cell(new Phrase(tablespace, contextFont1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(size, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(percent, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(status, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                row = row + 1;
            }
        }
    }
    // ===============end

    String count = (String) reportHash.get("count");
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1));
    this.setCellFormat(cell, true);
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1));
    this.setCellFormat(cell, true);
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    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_oraNewPDF(String filename, String type) 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");
    String runstr = (String) reportHash.get("runstr");
    // String[] sysItem1 = { "shared pool", "large pool", "buffer cache",
    // "java pool" };
    String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" };
    String downnum = (String) reportHash.get("downnum");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    if ("pdf".equals(type)) {
        PdfWriter.getInstance(document, new FileOutputStream(filename));
    } else {//  ww  w  . j  av  a2s .co  m
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
    }
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL);
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    this.setTableFormat(aTable);
    // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    // aTable.setWidths(widths);
    // aTable.setWidth(100); //  90%
    // aTable.setAlignment(Element.ALIGN_CENTER);// 
    // aTable.setAutoFillEmptyCells(true); // 
    // aTable.setBorderWidth(1); // 
    // aTable.setBorderColor(new Color(0, 125, 255)); // 
    // aTable.setPadding(2);// 
    // aTable.setSpacing(0);// 
    // aTable.setBorder(2);// 
    Cell cell = null;

    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setColspan(8);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnamestr, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(runstr, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase(grade, contextFont));
    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(4);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("SGA(MB)", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // SGA
    String valueall = "---";
    String valuebig = "---";
    String valuebuffer = "---";
    String valuejava = "---";
    if (oramem != null) {

        if (oramem.get(sysItem1[0]) != null) {
            valueall = (String) oramem.get(sysItem1[0]);
        }
        if (oramem.get(sysItem1[1]) != null) {
            valuebig = (String) oramem.get(sysItem1[1]);
        }
        if (oramem.get(sysItem1[2]) != null) {
            valuebuffer = (String) oramem.get(sysItem1[2]);
        }
        if (oramem.get(sysItem1[3]) != null) {
            valuejava = (String) oramem.get(sysItem1[3]);
        }
    }
    // SGA END

    cell = new Cell(new Phrase(valueall));
    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(valuebig));
    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(valuebuffer));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("Java", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(valuejava));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("PGA(MB)", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated",
            "cache_hit_percentage", "bytes_processed", "extra_bytes_read/written", "recompute_count_(total)" };
    String valuepgaall = "---";
    String valuepganow = "---";
    String valuepgabig = "---";
    if (oramem != null) {

        if (oramem.get(sysItem2[0]) != null) {
            valuepgaall = (String) oramem.get(sysItem2[0]);
        }
        if (oramem.get(sysItem2[1]) != null) {
            valuepganow = (String) oramem.get(sysItem2[1]);
        }
        if (oramem.get(sysItem2[2]) != null) {
            valuepgabig = (String) oramem.get(sysItem2[2]);
        }
    }

    cell = new Cell(new Phrase("PGA", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    if (!"---".equals(valuepgaall)) {
        valuepgaall = CEIString.round(Double.valueOf(valuepgaall.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepgaall));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("PGA", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (!"---".equals(valuepganow)) {
        valuepganow = CEIString.round(Double.valueOf(valuepganow.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepganow));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("PGA", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (!"---".equals(valuepgabig)) {
        valuepgabig = CEIString.round(Double.valueOf(valuepgabig.replace("MB", "")), 2) + "";
    }
    cell = new Cell(new Phrase(valuepgabig));
    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);
    // 
    Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");
    OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao();
    List list = null;
    try {
        list = oraspaceconfigDao.getByIp(ip, 1);
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        oraspaceconfigDao.close();
    }
    Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell5.setRowspan(2 + list.size());
    this.setCellFormat(cell5, true);
    aTable.addCell(cell5);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase((String) maxping.get("avgpingcon")));
    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.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(MB)", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(%)", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // ====

    int row = 0;
    for (int i = 0; i < tableinfo_v.size(); i++) {
        Hashtable ht = (Hashtable) tableinfo_v.get(i);
        String tablespace = ht.get("tablespace").toString();
        for (int j = 0; j < list.size(); j++) {
            Oraspaceconfig vo1 = (Oraspaceconfig) list.get(j);
            if (vo1.getSpacename().equals(tablespace)) {
                String size = ht.get("size_mb").toString();
                String percent = ht.get("percent_free").toString();
                String status = ht.get("status").toString();

                cell = new Cell(new Phrase(tablespace));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(size));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(percent));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(status));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                row = row + 1;
            }
        }
    }
    // ===============end
    String count = (String) reportHash.get("count");
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setColspan(8);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);

    String pinglog = "";
    if ("0".equals(downnum)) {
        pinglog = "   " + "2    ";

    } else {
        pinglog = "   " + "2    " + downnum + "";
    }
    String spacelog = "";
    if (!"0".equals(count)) {
        spacelog = "   " + "3    " + count
                + "" + "    ";
    } else {
        spacelog = "   " + "3    ";
    }
    cell = new Cell(new Phrase("   1      " + "\n" + "\n" + pinglog + "\n"
            + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont));
    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @param filename/*from   ww  w.  j a  v a2 s  .c  o m*/
 * @param type
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_sqlNewDoc(String filename, String type) throws DocumentException, IOException {
    String hostname = (String) reportHash.get("dbname");
    String hostnamestr = (String) reportHash.get("hostnamestr");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String Ping = (String) reportHash.get("Ping");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    Hashtable oramem = (Hashtable) reportHash.get("memvalue");
    Hashtable maxping = (Hashtable) reportHash.get("ping");
    String runstr = (String) reportHash.get("runstr");
    Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys");
    String[] sysItem1 = { "shared_pool", "large_pool", "buffer_cache", "java pool" };
    String downnum = (String) reportHash.get("downnum");

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    if ("pdf".equals(type)) {
        PdfWriter.getInstance(document, new FileOutputStream(filename));
    } else {
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
    }
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    this.setTableFormat(aTable);
    // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    // aTable.setWidths(widths);
    // aTable.setWidth(100); //  90%
    // aTable.setAlignment(Element.ALIGN_CENTER);// 
    // aTable.setAutoFillEmptyCells(true); // 
    // aTable.setBorderWidth(1); // 
    // aTable.setBorderColor(new Color(0, 125, 255)); // 
    // aTable.setPadding(2);// 
    // aTable.setSpacing(0);// 
    // aTable.setBorder(2);// 
    Cell cell = null;

    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setColspan(8);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnamestr, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase(runstr, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase(grade, contextFont1));
    cell.setColspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(5);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);

    // mems
    Hashtable sqlValue = new Hashtable();
    if ((Hashtable) reportHash.get("sqlValue") != null)
        sqlValue = (Hashtable) reportHash.get("sqlValue");
    Hashtable memValue = new Hashtable();
    if (sqlValue.get("mems") != null)
        memValue = (Hashtable) sqlValue.get("mems");
    String totalMemory = "---";
    String sqlMem = "---";
    String optMemory = "---";
    String lockMem = "---";
    String conMemory = "---";
    if (memValue != null && memValue.size() > 0) {
        if (memValue.get("totalMemory") != null)
            totalMemory = (String) memValue.get("totalMemory");// total
        if (memValue.get("sqlMem") != null)
            sqlMem = (String) memValue.get("sqlMem");// sql
        if (memValue.get("optMemory") != null)
            optMemory = (String) memValue.get("optMemory");// 
        if (memValue.get("lockMem") != null)
            lockMem = (String) memValue.get("lockMem");// 
        if (memValue.get("conMemory") != null)
            conMemory = (String) memValue.get("conMemory");// 
    }
    cell = new Cell(new Phrase("(KB)", titleFont));
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(totalMemory.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("SQL", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(sqlMem.replace(".0", ""), contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(optMemory.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(lockMem.replace(".0", ""), contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(conMemory.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String productlevel = "";
    if (sqlsys.get("productlevel") != null) {
        productlevel = (String) sqlsys.get("productlevel");
    }
    cell = new Cell(new Phrase(productlevel));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String IsSingleUser = "";
    if (sqlsys.get("IsSingleUser") != null) {
        IsSingleUser = (String) sqlsys.get("IsSingleUser");
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsSingleUser, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String IsIntegratedSecurityOnly = "";
    if (sqlsys.get("IsIntegratedSecurityOnly") != null) {
        IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly");
    }

    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsIntegratedSecurityOnly, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String IsClustered = "";
    if (sqlsys.get("IsClustered") != null) {
        IsClustered = (String) sqlsys.get("IsClustered");
    }

    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsClustered, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // 
    Hashtable dbValue = (Hashtable) reportHash.get("dbValue");
    Hashtable alldatabase = new Hashtable();
    Hashtable alllogfile = new Hashtable();
    alldatabase = (Hashtable) dbValue.get("database");
    if (alldatabase == null)
        alldatabase = new Hashtable();
    alllogfile = (Hashtable) dbValue.get("logfile");
    if (alllogfile == null)
        alllogfile = new Hashtable();
    Vector names = (Vector) dbValue.get("names");

    /*
     * OraspaceconfigDao oraspaceconfigDao = new OraspaceconfigDao(); List
     * list = oraspaceconfigDao.getByIp(ip, 1);
     */
    SqldbconfigDao sqldbconfigDao = new SqldbconfigDao();

    List list = null;
    try {
        list = sqldbconfigDao.getByIp(ip, 1);
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        sqldbconfigDao.close();
    }
    Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell5.setRowspan(2 + list.size());
    this.setCellFormat(cell5, true);
    aTable.addCell(cell5);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("MB", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("MB", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("%", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // ====
    // ====

    int row = 0;
    for (int i = 0; i < names.size(); i++) {
        Hashtable ht = (Hashtable) dbValue.get(i);
        String key = (String) names.get(i);
        if (alldatabase.get(key) == null)
            continue;
        Hashtable data = (Hashtable) alldatabase.get(key);
        String dbname = data.get("dbname").toString();

        for (int j = 0; j < list.size(); j++) {
            Sqldbconfig vo1 = (Sqldbconfig) list.get(j);
            if (vo1.getDbname().equals(dbname)) {

                String size = data.get("size").toString();
                String usedsize = "";
                if (data.get("usedsize") != null) {
                    usedsize = data.get("usedsize").toString();
                }
                String usedperc = "";
                if (data.get("usedperc") != null)
                    usedperc = data.get("usedperc").toString();

                cell = new Cell(new Phrase(dbname, contextFont1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(size, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(usedsize, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(usedperc, contextFont1));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                row = row + 1;
            }
        }
    }
    // ===============end

    String count = (String) reportHash.get("count");
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(2);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setColspan(8);
    this.setCellFormat(cell, true);
    aTable.addCell(cell);

    String pinglog = "";
    if ("0".equals(downnum))

    {
        pinglog = "   " + "2    ";
    } else {
        pinglog = "   " + "2    " + downnum + "";
    }
    String spacelog = "";
    if (!"0".equals(count)) {
        spacelog = "   " + "3    " + count
                + "" + "    ";
    } else {
        spacelog = "   " + "3    ";
    }
    cell = new Cell(new Phrase("   1      " + "\n" + "\n" + pinglog + "\n"
            + "\n" + spacelog + "\n", contextFont1));
    cell.setColspan(8);

    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_sqlNewPDF(String filename) throws DocumentException, IOException {
    String hostname = (String) reportHash.get("dbname");
    String hostnamestr = (String) reportHash.get("hostnamestr");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String Ping = (String) reportHash.get("Ping");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    Hashtable oramem = (Hashtable) reportHash.get("memvalue");
    Hashtable maxping = (Hashtable) reportHash.get("ping");
    String runstr = (String) reportHash.get("runstr");
    String[] sysItem1 = { "shared pool", "large pool", "buffer cache", "java pool" };
    String downnum = (String) reportHash.get("downnum");
    Hashtable sqlsys = (Hashtable) reportHash.get("sqlsys");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    document.open();/*from  w  w  w  . j  a va 2 s  . c  om*/
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont = new Font(bfChinese, 11, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    Cell cell = null;

    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + starttime + "" + totime + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnamestr));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));

    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(runstr, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase(grade, contextFont1));
    cell.setColspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(5);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    // mems
    Hashtable sqlValue = new Hashtable();
    if ((Hashtable) reportHash.get("sqlValue") != null)
        sqlValue = (Hashtable) reportHash.get("sqlValue");
    Hashtable memValue = new Hashtable();
    if (sqlValue.get("mems") != null)
        memValue = (Hashtable) sqlValue.get("mems");
    String totalMemory = "---";
    String sqlMem = "---";
    String optMemory = "---";
    String lockMem = "---";
    String conMemory = "---";
    if (memValue != null && memValue.size() > 0) {
        if (memValue.get("totalMemory") != null)
            totalMemory = (String) memValue.get("totalMemory");// total
        if (memValue.get("sqlMem") != null)
            sqlMem = (String) memValue.get("sqlMem");// sql
        if (memValue.get("optMemory") != null)
            optMemory = (String) memValue.get("optMemory");// 
        if (memValue.get("lockMem") != null)
            lockMem = (String) memValue.get("lockMem");// 
        if (memValue.get("conMemory") != null)
            conMemory = (String) memValue.get("conMemory");// 
    }
    cell = new Cell(new Phrase("(KB)", titleFont));
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(totalMemory.replace(".0", "")));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("SQL", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(sqlMem.replace(".0", "")));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(optMemory.replace(".0", "")));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(lockMem.replace(".0", "")));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(conMemory.replace(".0", "")));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String productlevel = "";
    if (sqlsys.get("productlevel") != null) {
        productlevel = (String) sqlsys.get("productlevel");
    }
    String IsSingleUser = "";
    if (sqlsys.get("IsSingleUser") != null) {
        IsSingleUser = (String) sqlsys.get("IsSingleUser");
    }

    String IsIntegratedSecurityOnly = "";
    if (sqlsys.get("IsIntegratedSecurityOnly") != null) {
        IsIntegratedSecurityOnly = (String) sqlsys.get("IsIntegratedSecurityOnly");
    }
    String IsClustered = "";
    if (sqlsys.get("IsClustered") != null) {
        IsClustered = (String) sqlsys.get("IsClustered");
    }

    cell = new Cell(new Phrase(productlevel));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsSingleUser, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsIntegratedSecurityOnly, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(IsClustered, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // 
    Hashtable dbValue = (Hashtable) reportHash.get("dbValue");
    Hashtable alldatabase = new Hashtable();
    Hashtable alllogfile = new Hashtable();
    alldatabase = (Hashtable) dbValue.get("database");
    if (alldatabase == null)
        alldatabase = new Hashtable();
    alllogfile = (Hashtable) dbValue.get("logfile");
    if (alllogfile == null)
        alllogfile = new Hashtable();
    Vector names = (Vector) dbValue.get("names");

    SqldbconfigDao sqldbconfigDao = new SqldbconfigDao();

    List list = null;
    try {
        list = sqldbconfigDao.getByIp(ip, 1);
    } catch (Exception e) {
        SysLogger.error("", e);
    } finally {
        sqldbconfigDao.close();
    }

    // // List list = sqldbconfigDao.getByIp(ip, 1);
    // for (int i = 0; i < list.size(); i++) {
    //
    // }
    Cell cell5 = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell5.setRowspan(2 + list.size());
    cell5.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell5);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("MB", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("MB", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("%", titleFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // ====

    int row = 0;
    for (int i = 0; i < names.size(); i++) {
        Hashtable ht = (Hashtable) dbValue.get(i);
        String key = (String) names.get(i);
        if (alldatabase.get(key) == null)
            continue;
        Hashtable data = (Hashtable) alldatabase.get(key);
        String dbname = data.get("dbname").toString();

        for (int j = 0; j < list.size(); j++) {
            Sqldbconfig vo1 = (Sqldbconfig) list.get(j);
            if (vo1.getDbname().equals(dbname)) {

                String size = data.get("size").toString();
                String usedsize = "";
                if (data.get("usedsize") != null) {
                    usedsize = data.get("usedsize").toString();
                }
                String usedperc = "";
                if (data.get("usedperc") != null)
                    usedperc = data.get("usedperc").toString();

                cell = new Cell(new Phrase(dbname));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(size));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(usedsize));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(usedperc));
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                row = row + 1;
            }
        }
    }
    // ===============end

    String count = (String) reportHash.get("count");
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + downnum + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + count + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String pinglog = "";
    if ("0".equals(downnum))

    {
        pinglog = "   " + "2    ";
    } else {
        pinglog = "   " + "2    " + downnum + "";
    }
    String spacelog = "";
    if (!"0".equals(count)) {
        spacelog = "   " + "3    " + count
                + "" + "    ";
    } else {
        spacelog = "   " + "3    ";
    }
    cell = new Cell(new Phrase("   1      " + "\n" + "\n" + pinglog + "\n"
            + "\n" + spacelog + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", contextFont1));
    cell.setColspan(8);

    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}