Example usage for org.apache.poi.hssf.usermodel HSSFSheet autoSizeColumn

List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet autoSizeColumn

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFSheet autoSizeColumn.

Prototype

@Override
public void autoSizeColumn(int column) 

Source Link

Document

Adjusts the column width to fit the contents.

This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.

Usage

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createHeapAllocSpaceTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;//from   w ww. ja  v  a2s  .  c o  m
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(5, "Total heap alloc space");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Total Heap Allocated Space"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getHeapAllocatedSpace());

            }
        }
        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long heapAllocSpaceDelta = deltaData.get(heap.toLowerCase()).getHeapAllocatedSpace();
            cell.setCellValue(heapAllocSpaceDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }

    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the total heap allocated space for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createHeapFreeSpaceTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;/* w  w w  .j a v  a 2s  .  c om*/
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(6, "Total heap free space");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Total Heap Free Space"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getHeapFreeSpace());
            }
        }

        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long heapFreeeDelta = deltaData.get(heap.toLowerCase()).getHeapFreeSpace();
            cell.setCellValue(heapFreeeDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the total heap free space for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createAllocatedCellsTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;/*  w ww  .jav a  2s  . c  o  m*/
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(7, "Allocated heap cell count");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Allocated heap cell count"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getAllocatedCells());
            }
        }
        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long allocCellsDelta = deltaData.get(heap.toLowerCase()).getAllocatedCells();
            cell.setCellValue(allocCellsDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the allocated heap cell count for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createFreeCellsTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;/*w  w  w  . ja v a  2s.  c  o m*/
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(8, "Free heap cell count");

    row = sheet.createRow(0);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Free heap cell count"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getFreeCells());
            }
        }

        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long heapFreeCellsDelta = deltaData.get(heap.toLowerCase()).getFreeCells();
            cell.setCellValue(heapFreeCellsDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the free heap cell count for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createFreeSlackTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;//from   ww w . jav a  2s.c o m
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(9, "Free Slack");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Free slack"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getFreeSlackSize());
            }
        }
        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long heapSlackDelta = deltaData.get(heap.toLowerCase()).getFreeSlackSize();
            cell.setCellValue(heapSlackDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the free slack size for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createLargestAllocSizeTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;//from   w  ww .ja  v  a  2s .  com
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(10, "Largest allocated cell size in heap");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Largest allocated cell size in heap"));

    sheet.autoSizeColumn((short) 0);

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getLargestAllocCellSize());
            }
        }
        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long largetAllocCellDelta = deltaData.get(heap.toLowerCase()).getLargestAllocCellSize();
            cell.setCellValue(largetAllocCellDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the largest allocated cell size in heap for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createLargestFreeSizeTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;//from   ww  w  .j a  va 2 s .  co  m
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(11, "Largest free cell size in heap");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Largest free cell size in heap"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Threads"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : heapThreads) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ThreadData> heapValues = heapData.get(heap.toLowerCase());

        if (heapValues != null) {
            int j = 1;
            for (int i = 0; i < heapValues.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_number"));
                ThreadData thData = heapValues.get(i);

                if (thData.getStatus() == 0) {
                    //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else
                    cell.setCellValue(thData.getLargestFreeCellSize());
            }
        }

        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (deltaData.get(heap.toLowerCase()) != null) {
            long largestFreeCellDelta = deltaData.get(heap.toLowerCase()).getLargestFreeCellSize();
            cell.setCellValue(largestFreeCellDelta);
        } else
            cell.setCellValue(0);

        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the largest free cell size in heap for each thread in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

/**
 * This method creates the sheet for Global Data.
 * /*  w w w .j  av a2  s . c o  m*/
 *
 */
private void createGlobalChunksSheet() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(2, "Global Data");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Global Data"));

    description = sheet.createRow(1);

    //creates an empty row.
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header1"));
    cell.setCellValue(new HSSFRichTextString("Chunk Names"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : glodChunks) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<GlobalDataChunks> heapValues = glodData.get(heap);

        int j = 1;
        for (int i = 0; i < heapValues.size(); i++) {
            if (constants.contains(i + 1))
                continue;

            cell = row.createCell(j++);
            cell.setCellStyle(styles.get("cell_number"));
            GlobalDataChunks thData = heapValues.get(i);

            if (thData.getAttrib() == 0) {
                //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
            } else
                cell.setCellValue(thData.getSize());
        }

        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (glodDeltaData.get(heap) != null) {
            long largestFreeCellDelta = Long.parseLong(glodDeltaData.get(heap));
            cell.setCellValue(largestFreeCellDelta);
        }
        rowNo++;
    }
    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the chunk sizes in bytes that caontains global data, for each cycle in seconds"));

}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

private void createNonHeapChunkSheet() {
    //create a new sheet
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;//  w w  w . java 2  s.c  om
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(3, "Non-heap chunks");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Non-Heap Chunk Size"));

    description = sheet.createRow(1);

    //creates an empty row
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Chunk Names"));
    addCycleIntervals(row);

    cell = row.createCell((int) row.getLastCellNum());
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Delta"));

    int rowNo = 4;

    for (String heap : nonHeapChunks) {
        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(heap));

        ArrayList<ChunksData> chunkValues = chunkData.get(heap);

        int j = 1;
        for (int i = 0; i < chunkValues.size(); i++) {
            if (constants.contains(i + 1))
                continue;

            cell = row.createCell(j++);
            cell.setCellStyle(styles.get("cell_number"));
            ChunksData chData = chunkValues.get(i);

            if (chData.getAttrib() == 0) {
                //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
            } else
                cell.setCellValue(chData.getSize());
        }

        cell = row.createCell(logData.getNumberOfCycles() + 1 - constants.size());
        cell.setCellStyle(styles.get("cell_number"));

        if (chunkDeltaData.get(heap) != null) {
            long largestFreeCellDelta = Long.parseLong(chunkDeltaData.get(heap));
            cell.setCellValue(largestFreeCellDelta);
        }
        rowNo++;
    }

    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }

    cell = description.createCell(0);
    cell.setCellValue(
            new HSSFRichTextString("Specifies the non heap chunk sizes in bytes, for each cycle in seconds"));
}

From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java

License:Open Source License

/**
 * This method creates sheet with Window Group events.
 *
 *///from  www  .  j  a  va 2 s .  c om
private void createWindowGroupSheet() {
    //create a new sheet
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;
    HSSFRow description = null;
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(12, "Window Groups");

    row = sheet.createRow(0);
    //r.setHeight((short)500);

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Window Group Events"));

    description = sheet.createRow(1);

    //creates an empty row
    row = sheet.createRow(2);

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString("Window Group Names"));
    addCycleIntervals(row);

    SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
    ArrayList<String> wndg_names = utils.getWindowGroupNames(logData);

    int rowNo = 4;

    if (wndg_names == null)
        return;
    else {
        for (String name : wndg_names) {
            row = sheet.createRow(rowNo++);
            cell = row.createCell(0);
            cell.setCellStyle(styles.get("cell_normal"));
            cell.setCellValue(new HSSFRichTextString(name));

            ArrayList<WindowGroupEventData> events_list = utils.getAllWindowGroupEvents(name, logData);

            int j = 1;

            for (int i = 0; i < events_list.size(); i++) {
                if (constants.contains(i + 1))
                    continue;

                cell = row.createCell(j++);
                cell.setCellStyle(styles.get("cell_normal"));

                WindowGroupEventData eventSet = events_list.get(i);

                if (eventSet == null) {
                    cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
                } else {
                    StringBuffer tmp = new StringBuffer();

                    if (eventSet.getEvent_0_count() > 0)
                        tmp.append(" NoEvent(" + eventSet.getEvent_0_count() + ")");
                    if (eventSet.getEvent_1_count() > 0)
                        tmp.append(" NameChanged(" + eventSet.getEvent_1_count() + ")");
                    if (eventSet.getEvent_2_count() > 0)
                        tmp.append(" FocusGained(" + eventSet.getEvent_2_count() + ")");
                    if (eventSet.getEvent_3_count() > 0)
                        tmp.append(" FocusLost(" + eventSet.getEvent_3_count() + ")");

                    cell.setCellValue(new HSSFRichTextString(tmp.toString()));
                }

            }
        }

        for (int i = 0; i <= logData.getNumberOfCycles(); i++)
            sheet.autoSizeColumn((short) i);

        cell = description.createCell(0);
        cell.setCellValue(new HSSFRichTextString(
                "Specifies the type and number of events for each window group, in each cycle."));
    }
}