Example usage for org.apache.poi.hssf.usermodel HSSFRow getLastCellNum

List of usage examples for org.apache.poi.hssf.usermodel HSSFRow getLastCellNum

Introduction

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

Prototype

@Override
public short getLastCellNum() 

Source Link

Document

Gets the index of the last cell contained in this row PLUS ONE.

Usage

From source file:com.ms.commons.file.excel.ExcelParser.java

License:Open Source License

@SuppressWarnings({ "deprecation", "unused" })
public String[] splitLine() throws Exception {
    if (m_iCurrentRow == m_iNbRows)
        return null;

    HSSFRow row = m_sheet.getRow(m_iCurrentRow);
    if (row == null) {
        return null;
    } else {/* ww w  . j a v a  2  s  .  c  o m*/
        int cellIndex = 0;
        int noOfCells = row.getPhysicalNumberOfCells();
        short firstCellNum = row.getFirstCellNum();
        short lastCellNum = row.getLastCellNum();
        String[] values = new String[lastCellNum];

        if (firstCellNum >= 0 && lastCellNum >= 0) {
            for (short iCurrent = firstCellNum; iCurrent < lastCellNum; iCurrent++) {
                HSSFCell cell = (HSSFCell) row.getCell(iCurrent);
                if (cell == null) {
                    values[iCurrent] = StringUtils.EMPTY;
                    cellIndex++;
                    continue;
                } else {
                    switch (cell.getCellType()) {

                    case HSSFCell.CELL_TYPE_NUMERIC:
                        double value = cell.getNumericCellValue();
                        if (HSSFDateUtil.isCellDateFormatted(cell)) {
                            if (HSSFDateUtil.isValidExcelDate(value)) {
                                Date date = HSSFDateUtil.getJavaDate(value);
                                SimpleDateFormat dateFormat = new SimpleDateFormat(JAVA_TOSTRING);
                                values[iCurrent] = dateFormat.format(date);
                            } else {
                                throw new Exception("Invalid Date value found at row number " + row.getRowNum()
                                        + " and column number " + cell.getCellNum());
                            }
                        } else {
                            values[iCurrent] = value + StringUtils.EMPTY;
                        }
                        break;

                    case HSSFCell.CELL_TYPE_STRING:
                        values[iCurrent] = cell.getStringCellValue();
                        break;

                    case HSSFCell.CELL_TYPE_BLANK:
                        values[iCurrent] = null;
                        break;

                    default:
                        values[iCurrent] = null;
                    }
                }
            }
        }
        m_iCurrentRow++;
        return values;
    }
}

From source file:com.ms.commons.test.datareader.impl.ExcelReadUtil.java

License:Open Source License

/**
 * A column means an item in table. With horizontal style, in contrast, a row represents an item in table.
 * /*from   w  w  w . ja va2s  .  co m*/
 * @author Qiu Shuo
 */
private static MemoryTable readSheetWithVerticalStyle(String name, HSSFSheet sheet) {
    MemoryTable table = new MemoryTable(name.trim());
    List<MemoryRow> itemList = new ArrayList<MemoryRow>();
    int maxRows = sheet.getPhysicalNumberOfRows();
    int maxItemNumPlusOne = 0;
    // get maxItemNumPlusOne
    {
        for (int i = 0; i < maxRows; i++) {
            HSSFRow row = sheet.getRow(i);
            int cur = row.getLastCellNum();
            maxItemNumPlusOne = (cur > maxItemNumPlusOne) ? cur : maxItemNumPlusOne;
        }
    }
    for (int i = 0; i < maxRows; i++) {
        HSSFRow row = sheet.getRow(i);
        HSSFCell columnNameCell = row.getCell((short) 0);
        String columnName = columnNameCell.getRichStringCellValue().getString();
        for (short j = 1; j < maxItemNumPlusOne; j++) {
            HSSFCell cell = row.getCell(j);
            MemoryField field = readCellValue(columnName, cell);
            while (itemList.size() <= j - 1) {
                itemList.add(new MemoryRow(new ArrayList<MemoryField>()));
            }
            MemoryRow item = itemList.get(j - 1);
            item.getFieldList().add(field);
        }
    }
    table.setRowList(itemList);
    return table;
}

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.
 *
 *//*from  www.  j  a  va  2s  .  co m*/
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();//from w w  w  .j a v  a2s  . c  o m
    // 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(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();/*  w w  w.  j a va  2s .  co  m*/
    // 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(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();/* w  w w  .  j  ava2 s . c  om*/
    // 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(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();/*  w w  w .  jav a2s  .  c o  m*/
    // 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(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();// w  w w. ja  v  a  2s .c  o  m
    // 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(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();//from  www  . j  av  a2 s .  c  o  m
    // 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(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();//from w  w  w . ja  va2s. c  o m
    // 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(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"));
}