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

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

Introduction

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

Prototype

@Override
public HSSFRow createRow(int rownum) 

Source Link

Document

Create a new row within the sheet and return the high level representation

Usage

From source file:com.nkapps.billing.services.ReportPrintServiceImpl.java

@Override
public HSSFWorkbook printSmst(List<ReportSmstListPojo> listPojos) throws Exception {
    HSSFWorkbook workbook = null;/*  w  w w.  j  a  v  a 2  s  . co  m*/

    POIFSFileSystem fs = new POIFSFileSystem(
            new FileInputStream(servletContext.getRealPath("templates") + File.separator + "report_smst.xls"));
    workbook = new HSSFWorkbook(fs);
    HSSFSheet sheet = workbook.getSheetAt(0);
    // title
    //HSSFRow row = sheet.getRow(1);
    //HSSFCell cell = row.getCell(1);
    //String title;
    //cell.setCellValue(title);
    //
    HSSFRow row;
    final int CELL_START = 1;
    final int ROW_START = sheet.getLastRowNum() - 1;
    final int CELL_END = sheet.getRow(ROW_START).getLastCellNum();

    int rowCurrent = ROW_START, rowTotal = sheet.getLastRowNum(), cellCurrent;
    //
    HSSFCellStyle[] style = new HSSFCellStyle[CELL_END];
    short styleHeight = sheet.getRow(rowCurrent).getHeight();
    for (int i = CELL_START; i < CELL_END; i++) {
        style[i] = sheet.getRow(rowCurrent).getCell(i).getCellStyle();
    }

    // total style
    HSSFCellStyle[] totalStyle = new HSSFCellStyle[CELL_END];
    short totalStyleHeight = sheet.getRow(rowTotal).getHeight();
    for (int i = CELL_START; i < CELL_END; i++) {
        totalStyle[i] = sheet.getRow(rowTotal).getCell(i).getCellStyle();
    }

    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    int numQuantity = 0;
    for (ReportSmstListPojo rslp : listPojos) {
        numQuantity++;

        row = sheet.createRow(rowCurrent++);
        row.setHeight(styleHeight);

        cellCurrent = CELL_START;
        createCell(row, cellCurrent++, style, numQuantity);
        createCell(row, cellCurrent++, style, dateFormat.format(rslp.getOperationDate()));
        createCell(row, cellCurrent++, style, rslp.getBsPaymentSum());
        createCell(row, cellCurrent++, style, rslp.getSmstPaymentSum());
        createCell(row, cellCurrent++, style, rslp.getDiffSum());
    }
    List<Integer> totalCellIndexes = new ArrayList<>();
    totalCellIndexes.add(CELL_START + 2); // for 
    totalCellIndexes.add(CELL_START + 3); // for 
    totalCellIndexes.add(CELL_START + 4); // for 
    createTotalCells(totalCellIndexes, sheet, totalStyle, totalStyleHeight, ROW_START, CELL_START, rowCurrent);

    return workbook;
}

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

License:Open Source License

private boolean createOverViewTab() {
    //create a new sheet
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;/* ww w  . j  a  v a2 s .  co  m*/
    // declare a cell object reference
    HSSFCell cell = null;

    //set the sheet name in Unicode
    wb.setSheetName(0, "Overview");

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

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

    row = sheet.createRow(1);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("Number of Cycles"));
    cell = row.createCell(1);
    cell.setCellStyle(styles.get("cell_number"));

    CycleData firstCycle = logData.getLogData()[0];

    if (ovData.noOfcycles == 1)
        cell.setCellValue(new HSSFRichTextString(ovData.noOfcycles + " (" + firstCycle.getCycleNumber() + ")"));
    else
        cell.setCellValue(ovData.noOfcycles);

    row = sheet.createRow(2);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("Number of Cycles Truncated"));
    cell = row.createCell(1);
    cell.setCellValue(constants.size());

    row = sheet.createRow(3);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("Time Period"));
    HSSFCell timePeriod = row.createCell(1);

    row = sheet.createRow(4);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("Time Duration"));
    cell = row.createCell(1);
    cell.setCellValue(new HSSFRichTextString(ovData.duration + " sec(" + ovData.durationString + ")"));

    row = sheet.createRow(5);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("ROM Checksum"));
    cell = row.createCell(1);
    cell.setCellValue(new HSSFRichTextString(firstCycle.getRomCheckSum()));

    row = sheet.createRow(6);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("ROM Version"));
    cell = row.createCell(1);
    cell.setCellValue(new HSSFRichTextString(firstCycle.getRomVersion()));

    sheet.createRow(7);
    sheet.createRow(8);
    sheet.createRow(9);

    row = sheet.createRow(10);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header2"));
    cell.setCellValue(new HSSFRichTextString(""));

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

    HSSFRow totalHeapSizeRow = sheet.createRow(11);
    cell = totalHeapSizeRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Heap Size"));

    HSSFRow freeCellRow = sheet.createRow(12);
    cell = freeCellRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Free Cell count"));

    HSSFRow alloCellRow = sheet.createRow(13);
    cell = alloCellRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Allocated Cell count"));

    HSSFRow freeSpaceRow = sheet.createRow(14);
    cell = freeSpaceRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Free space"));

    HSSFRow allocSpaceRow = sheet.createRow(15);
    cell = allocSpaceRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Allocated space"));

    HSSFRow slackSpaceRow = sheet.createRow(16);
    cell = slackSpaceRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Slack space"));

    HSSFRow filesRow = sheet.createRow(17);
    cell = filesRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Total files"));

    HSSFRow psHandlesRow = sheet.createRow(18);
    cell = psHandlesRow.createCell(0);
    cell.setCellStyle(styles.get("cell_bold"));
    cell.setCellValue(new HSSFRichTextString("Total P&S Handles"));

    sheet.createRow(19);
    sheet.createRow(20);
    sheet.createRow(21);
    sheet.createRow(22);

    row = sheet.createRow(23);
    createOverviewFields(row);

    createDataInOverView(sheet, 24);

    cell = totalHeapSizeRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalHeapSizeChange);

    cell = freeCellRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalFreeCellChange);

    cell = alloCellRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalAllocCellChange);

    cell = freeSpaceRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalFreeSpaceChange);

    cell = allocSpaceRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalAllocSpaceChange);

    cell = slackSpaceRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalSlackSpaceChange);

    cell = filesRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalFilesChange);

    cell = psHandlesRow.createCell(1);
    cell.setCellStyle(styles.get("blue_font"));
    cell.setCellValue(totalHandlesChange);

    sheet.autoSizeColumn((short) 0);
    sheet.autoSizeColumn((short) 1);
    sheet.autoSizeColumn((short) 2);
    sheet.autoSizeColumn((short) 3);
    sheet.autoSizeColumn((short) 4);
    sheet.autoSizeColumn((short) 5);
    sheet.autoSizeColumn((short) 6);
    sheet.autoSizeColumn((short) 7);
    sheet.autoSizeColumn((short) 8);
    sheet.autoSizeColumn((short) 9);
    sheet.autoSizeColumn((short) 10);
    sheet.autoSizeColumn((short) 11);

    if (ovData.noOfcycles > 1)
        timePeriod.setCellValue(new HSSFRichTextString(ovData.fromTime + " to " + ovData.toTime));
    else
        timePeriod.setCellValue(new HSSFRichTextString(ovData.fromTime));

    return true;
}

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

License:Open Source License

/**
 * This method creates the sheet for RAM and DISK Memory data.
 * It shows the variation of RAM and Disk Memory in each cycle.
 *
 *///w  w w. j a  v a 2s .  c  om
private void createDiskVariationSheet() {
    //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(1, "RAM and Disk Memory");

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

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("RAM and Disk Memory"));

    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(""));

    addCycleIntervals(row);

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

    SWMTLogReaderUtils utils = new SWMTLogReaderUtils();
    ArrayList<String> diskNames = utils.getAllDiskNames(logData);

    int rowNo = 4;

    row = sheet.createRow(rowNo);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("cell_normal"));
    cell.setCellValue(new HSSFRichTextString("RAM (Used)"));

    ArrayList<SystemData> systemData = utils.getSystemDataFromAllCycles(logData);

    long[] usedMemValues = new long[logData.getNumberOfCycles()];

    j = 1;
    for (int i = 0; i < logData.getNumberOfCycles(); i++) {
        long totalMem = systemData.get(i).getTotalMemory();
        long freeMem = systemData.get(i).getFreeMemory();

        if (totalMem == -1 || freeMem == -1) {
            //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
            usedMemValues[i] = -1;
        } else {
            long usedMemory = totalMem - freeMem;
            usedMemValues[i] = usedMemory;
        }

        if (constants.contains(i + 1))
            continue;

        cell = row.createCell(j++);
        cell.setCellStyle(styles.get("cell_number"));
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

        if (usedMemValues[i] == -1)
            cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
        else
            cell.setCellValue(usedMemValues[i]);

        //cell.setCellValue(logData.get(i).getFreeMemory());
    }

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

    cell.setCellValue(usedMemChange);

    /*cell = row.createCell(logData.size()+1);
    cell.setCellStyle(styles.get("cell_number"));
            
    long firstCycleValue = logData.get(0).getFreeMemory();
    long lastCycleValue = logData.get(logData.size()-1).getFreeMemory();
            
    if(firstCycleValue!= -1 &&  lastCycleValue!= -1)
       cell.setCellValue(lastCycleValue - firstCycleValue);
    else{
       //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
       cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
    }*/

    rowNo++;

    row = sheet.createRow(rowNo);
    cell = row.createCell(0);
    cell.setCellStyle(styles.get("cell_normal"));
    cell.setCellValue(new HSSFRichTextString("RAM (Size)"));

    long[] totalMemValues = new long[logData.getNumberOfCycles()];

    j = 1;
    for (int i = 0; i < logData.getNumberOfCycles(); i++) {
        long totalMem = systemData.get(i).getTotalMemory();

        if (totalMem == -1) {
            totalMemValues[i] = -1;
        } else {
            totalMemValues[i] = totalMem;
        }
        //cell.setCellValue(logData.get(i).getFreeMemory());

        if (constants.contains(i + 1))
            continue;

        cell = row.createCell(j++);
        cell.setCellStyle(styles.get("cell_number"));
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

        if (totalMemValues[i] == -1)
            cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
        else
            cell.setCellValue(totalMemValues[i]);
    }

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

    cell.setCellValue(totalMemChange);

    Collections.sort(diskNames);

    for (String name : diskNames) {
        rowNo++;

        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(name + " (Used)"));

        ArrayList<DiskOverview> values = utils.getUsedMemoryAndSizesForDisk(name, logData);
        long[] usedSizes = new long[values.size()];

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

            cell = row.createCell(j++);
            cell.setCellStyle(styles.get("cell_number"));
            cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

            long usedSize = values.get(i).getUsedSize();

            if (usedSize == -1) {
                //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
            } else
                cell.setCellValue(usedSize);

            usedSizes[i] = usedSize;

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

        cell.setCellValue(deltaValue);
        rowNo++;

        row = sheet.createRow(rowNo);
        cell = row.createCell(0);
        cell.setCellStyle(styles.get("cell_normal"));
        cell.setCellValue(new HSSFRichTextString(name + " (Size)"));

        long[] sizeValues = new long[values.size()];

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

            cell = row.createCell(j++);
            cell.setCellStyle(styles.get("cell_number"));
            cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

            long size = values.get(i).getSize();

            if (size == -1) {
                //cell.getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);
                cell.setCellValue(new HSSFRichTextString(NOT_AVAILABLE));
            } else
                cell.setCellValue(size);

            sizeValues[i] = size;
        }

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

        cell.setCellValue(sizeDelta);

    }

    for (int i = 0; i <= logData.getNumberOfCycles(); i++) {
        sheet.autoSizeColumn((short) i);
    }
    cell = description.createCell(0);
    cell.setCellValue(new HSSFRichTextString(
            "Specifies the amount of used RAM and disk memories of all drives in bytes, for each cycle in seconds"));
}

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

License:Open Source License

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

    //set the sheet name in Unicode
    wb.setSheetName(4, "Total Heap Size");

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

    cell = row.createCell(0);
    cell.setCellStyle(styles.get("header"));
    cell.setCellValue(new HSSFRichTextString("Total Heap 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("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)) {
                    if (heap.equalsIgnoreCase("!SensorServer[1020507e]0001::OrientationThread"))
                        DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Skipping data from Cycle.." + i);
                    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.getHeapChunkSize());
            }
        }

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

        ThreadData delta = deltaData.get(heap.toLowerCase());

        //DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Delta for the thread " + heap + " is " + delta);

        if (delta != null) {
            long heapSizeDelta = delta.getHeapChunkSize();
            cell.setCellValue(heapSizeDelta);
        } 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 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 createHeapAllocSpaceTab() {
    HSSFSheet sheet = wb.createSheet();
    // declare a row object reference
    HSSFRow row = null;/*from   w w w  . j  av  a 2  s  . c om*/
    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;//from www  . j  ava2  s  .  co  m
    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;//  ww w  . j ava 2 s  .  com
    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. j a va2 s  .com*/
    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;/*  w w  w . j  a  va 2s.  co  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  w  w .  ja v a  2  s  .  c  o  m
    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"));
}