Example usage for org.apache.poi.ss.usermodel Cell setCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell setCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell setCellValue.

Prototype

void setCellValue(boolean value);

Source Link

Document

Set a boolean value for the cell

Usage

From source file:cn.edu.pku.lib.dataverse.UsageLogStatisPage.java

private File generateExcelRequestJoinGroupLogFile() {
    //excel workbook
    Workbook wb = new XSSFWorkbook();
    CreationHelper createHelper = wb.getCreationHelper();
    Sheet sheet = wb.createSheet(WorkbookUtil.createSafeSheetName("User Join Group Statistic"));
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss"));
    Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();

    //generate header
    String heads = ResourceBundle.getBundle("Bundle", locale).getString("log.requestjoingroup.header");
    String[] array = heads.split(",");
    Row row = sheet.createRow(0);//from  w  w  w  . jav a  2s.c o  m
    for (int k = 0; k < array.length; k++) {
        Cell cell = row.createCell(k);
        cell.setCellValue(array[k]);
    }

    //generate logs
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    final long size = 100L;
    UsageLogSearchQuery query = queryForGroup.clone();
    query.setSize(size);
    query.setDateHistogramInterval(null);
    UsageLogSearchResult searchResult = null;
    int i = 0;
    int j = 1;
    Cell cell;
    do {
        query.setFrom(i * size);
        searchResult = usageLogSearchService.search(query);
        List<EventLog> logs = searchResult.getEventLogs();
        for (EventLog log : logs) {
            row = sheet.createRow(j);
            AuthenticatedUser user;
            if (log.getUserId().equals(":guest")
                    || (user = authenticationServiceBean.getAuthenticatedUser(log.getUserId())) == null) {
                cell = row.createCell(0);
                cell.setCellValue(log.getDate());
                cell.setCellStyle(cellStyle);
                cell = row.createCell(1);
                cell.setCellValue(log.getIp());
                cell = row.createCell(2);
                cell.setCellValue(log.getContinent());
                cell = row.createCell(3);
                cell.setCellValue(log.getCountry());
                cell = row.createCell(4);
                cell.setCellValue(log.getSubdivision());
                cell = row.createCell(5);
                cell.setCellValue(log.getCity());
                cell = row.createCell(6);
                cell.setCellValue(log.getUserId());
                cell = row.createCell(7);
                cell.setCellValue(log.getUserName());
                cell = row.createCell(8);
                cell.setCellValue(log.getAffiliation());
                cell = row.createCell(9);
                cell.setCellValue(log.getPosition());
                cell = row.createCell(10);
                cell.setCellValue(getDisplayString(log.getEventType()));
                cell = row.createCell(11);
                cell.setCellValue(groupId2Group.get(log.getGroupId()).getDisplayName());
            } else {
                if (user.isBuiltInUser()) {
                    BuiltinUser b = builtinUserService.findByUserName(user.getUserIdentifier());
                    cell = row.createCell(0);
                    cell.setCellValue(log.getDate());
                    cell.setCellStyle(cellStyle);
                    cell = row.createCell(1);
                    cell.setCellValue(log.getIp());
                    cell = row.createCell(2);
                    cell.setCellValue(log.getContinent());
                    cell = row.createCell(3);
                    cell.setCellValue(log.getCountry());
                    cell = row.createCell(4);
                    cell.setCellValue(log.getSubdivision());
                    cell = row.createCell(5);
                    cell.setCellValue(log.getCity());

                    cell = row.createCell(6);
                    cell.setCellValue(log.getUserId());
                    cell = row.createCell(7);
                    cell.setCellValue(log.getUserName());
                    cell = row.createCell(8);
                    cell.setCellValue(b.getAffiliation());
                    cell = row.createCell(9);
                    cell.setCellValue(b.getPosition());
                    cell = row.createCell(10);
                    cell.setCellValue(getDisplayString(log.getEventType()));
                    cell = row.createCell(11);
                    cell.setCellValue(groupId2Group.get(log.getGroupId()).getDisplayName());

                    cell = row.createCell(12);
                    cell.setCellValue(b.getDepartment());
                    cell = row.createCell(13);
                    cell.setCellValue(b.getEmail());
                    cell = row.createCell(14);
                    cell.setCellValue(b.getSpeciality());
                    cell = row.createCell(15);
                    cell.setCellValue(b.getResearchInterest());
                    cell = row.createCell(16);
                    cell.setCellValue(b.getGender());
                    cell = row.createCell(17);
                    cell.setCellValue(b.getEducation());

                    cell = row.createCell(18);
                    cell.setCellValue(b.getProfessionalTitle());
                    cell = row.createCell(19);
                    cell.setCellValue(b.getSupervisor());
                    cell = row.createCell(20);
                    cell.setCellValue(b.getCertificateType());
                    cell = row.createCell(21);
                    cell.setCellValue(b.getCertificateNumber());
                    cell = row.createCell(22);
                    cell.setCellValue(b.getOfficePhone());
                    cell = row.createCell(23);
                    cell.setCellValue(b.getCellphone());

                    cell = row.createCell(24);
                    cell.setCellValue(b.getOtherEmail());
                    cell = row.createCell(25);
                    cell.setCellValue(b.getCountry());
                    cell = row.createCell(26);
                    cell.setCellValue(b.getProvince());
                    cell = row.createCell(27);
                    cell.setCellValue(b.getCity());
                    cell = row.createCell(28);
                    cell.setCellValue(b.getAddress());
                    cell = row.createCell(29);
                    cell.setCellValue(b.getZipCode());

                    cell = row.createCell(30);
                    cell.setCellValue("Built In");
                } else if (user.isPKUIAAAUser()) {
                    PKUIAAAUser p = pkuIAAAUserService.findByUserName(user.getUserIdentifier());
                    cell = row.createCell(0);
                    cell.setCellValue(log.getDate());
                    cell.setCellStyle(cellStyle);
                    cell = row.createCell(1);
                    cell.setCellValue(log.getIp());
                    cell = row.createCell(2);
                    cell.setCellValue(log.getContinent());
                    cell = row.createCell(3);
                    cell.setCellValue(log.getCountry());
                    cell = row.createCell(4);
                    cell.setCellValue(log.getSubdivision());
                    cell = row.createCell(5);
                    cell.setCellValue(log.getCity());

                    cell = row.createCell(6);
                    cell.setCellValue(log.getUserId());
                    cell = row.createCell(7);
                    cell.setCellValue(log.getUserName());
                    cell = row.createCell(8);
                    cell.setCellValue(p.getAffiliation());
                    cell = row.createCell(9);
                    cell.setCellValue(p.getPosition());
                    cell = row.createCell(10);
                    cell.setCellValue(getDisplayString(log.getEventType()));
                    cell = row.createCell(11);
                    cell.setCellValue(groupId2Group.get(log.getGroupId()).getDisplayName());

                    cell = row.createCell(12);
                    cell.setCellValue(p.getDepartment());
                    cell = row.createCell(13);
                    cell.setCellValue(p.getEmail());
                    cell = row.createCell(14);
                    cell.setCellValue(p.getSpeciality());
                    cell = row.createCell(15);
                    cell.setCellValue(p.getResearchInterest());
                    cell = row.createCell(16);
                    cell.setCellValue(p.getGender());
                    cell = row.createCell(17);
                    cell.setCellValue(p.getEducation());

                    cell = row.createCell(18);
                    cell.setCellValue(p.getProfessionalTitle());
                    cell = row.createCell(19);
                    cell.setCellValue(p.getSupervisor());
                    cell = row.createCell(20);
                    cell.setCellValue(p.getCertificateType());
                    cell = row.createCell(21);
                    cell.setCellValue(p.getCertificateNumber());
                    cell = row.createCell(22);
                    cell.setCellValue(p.getOfficePhone());
                    cell = row.createCell(23);
                    cell.setCellValue(p.getCellphone());

                    cell = row.createCell(24);
                    cell.setCellValue(p.getOtherEmail());
                    cell = row.createCell(25);
                    cell.setCellValue(p.getCountry());
                    cell = row.createCell(26);
                    cell.setCellValue(p.getProvince());
                    cell = row.createCell(27);
                    cell.setCellValue(p.getCity());
                    cell = row.createCell(28);
                    cell.setCellValue(p.getAddress());
                    cell = row.createCell(29);
                    cell.setCellValue(p.getZipCode());

                    cell = row.createCell(30);
                    cell.setCellValue("PKU IAAA");
                }
            }
            j++;
        }
        i++;
    } while (i < searchResult.getPages());

    String filesRootDirectory = System.getProperty("dataverse.files.directory");
    if (filesRootDirectory == null || filesRootDirectory.equals("")) {
        filesRootDirectory = "/tmp/files";
    }
    File file = new File(filesRootDirectory + "/temp/" + UUID.randomUUID());
    try (FileOutputStream out = new FileOutputStream(file)) {
        wb.write(out);
        return file;
    } catch (IOException ioe) {
        logger.log(Level.SEVERE, null, ioe);
    }
    if (file.exists()) {
        file.delete();
    }
    return null;
}

From source file:cn.mypandora.util.MyExcelUtil.java

License:Apache License

/**
 * Excel ????List<Map<String K,String V>>
 *
 * @param filepath    ?/*from w  ww .j  a v  a  2 s  .c om*/
 * @param sheetTitle  Sheet??
 * @param fieldTitles Sheet????
 * @param objList     ??
 * @param fieldNames  ?objClassfield??
 */
public static void writeExcel(String filepath, String sheetTitle, String fieldTitles,
        List<Map<String, String>> objList, String fieldNames) {
    Workbook[] wbs = new Workbook[] { new HSSFWorkbook(), new XSSFWorkbook() };
    for (int j = 0; j < wbs.length; j++) {
        Workbook workbook = wbs[j];
        CreationHelper creationHelper = workbook.getCreationHelper();

        // ExcelSheet
        Sheet sheet = workbook.createSheet(sheetTitle);
        workbook.setSheetName(0, sheetTitle);

        // Sheet
        createTitle(sheet, fieldTitles);

        // Sheet?
        String[] strArray = fieldNames.split(",");
        for (int objIndex = 0; objIndex < objList.size(); objIndex++) {
            Map<String, String> map = objList.get(objIndex);
            Row row = sheet.createRow(objIndex + 1);
            for (int cellNum = 0; cellNum < strArray.length; cellNum++) {
                Cell cell = row.createCell(cellNum);
                cell.setCellType(CellType.STRING);
                if (map.get(strArray[cellNum]) != null)
                    cell.setCellValue(map.get(strArray[cellNum]).toString());
                else {
                    cell.setCellValue("");
                }
            }
        }

        // ?Excel
        saveExcelFile(workbook, filepath);
    }

}

From source file:cn.mypandora.util.MyExcelUtil.java

License:Apache License

/**
 * Excel?sheet?//from w w w.j  a v  a 2 s  .  c om
 *
 * @param sheet       Excelsheet
 * @param fieldTitles sheet?(sheet?)
 */
private static void createTitle(Sheet sheet, String fieldTitles) {
    Row row = sheet.createRow(0);
    Cell cell;

    String[] strArray = fieldTitles.split(",");
    for (int i = 0; i < strArray.length; i++) {
        cell = row.createCell(i);
        cell.setCellType(CellType.STRING);
        cell.setCellValue(strArray[i]);
    }
}

From source file:cn.mypandora.util.MyExcelUtil.java

License:Apache License

/**
 * Excel?sheet/*from ww  w.ja va  2s .  com*/
 *
 * @param sheet      sheet
 * @param objList    ??
 * @param objClass   ???
 * @param fieldNames ?objClassfield??
 */
private static void createBody(Sheet sheet, List<?> objList, Class<?> objClass, String fieldNames) {
    String[] targetMethod = fieldNames.split(",");
    Method[] ms = objClass.getMethods();
    Pattern pattern = Pattern.compile("^get.*");

    // objList?sheet
    for (int objIndex = 0; objIndex < objList.size(); objIndex++) {
        Object obj = objList.get(objIndex);
        Row row = sheet.createRow(objIndex + 1);
        // strBody?sheet
        for (int strIndex = 0; strIndex < targetMethod.length; strIndex++) {
            String targetMethodName = targetMethod[strIndex];
            // msstrBody
            for (int i = 0; i < ms.length; i++) {
                Method srcMethod = ms[i];
                if (pattern.matcher(srcMethod.getName()).matches()) {
                    int len = targetMethodName.indexOf(".") < 0 ? targetMethodName.length()
                            : targetMethodName.indexOf(".");
                    if (srcMethod.getName()
                            .equals(("get"
                                    + String.valueOf(targetMethodName.substring(0, len).charAt(0)).toUpperCase()
                                    + targetMethodName.substring(1, len)))) {
                        Cell cell = row.createCell(strIndex);
                        cell.setCellType(CellType.STRING);
                        try {
                            // 
                            if (targetMethodName.contains(".")) {
                                cell.setCellValue(referenceInvoke(targetMethodName, obj));
                                // 
                            } else {
                                cell.setCellValue((srcMethod.invoke(obj)).toString());
                            }
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
            }
        }
    }

}

From source file:cn.org.vbn.util.LinkedDropDownLists.java

License:Apache License

/**
 * Called to populate the named areas/regions. The contents of the cells on
 * row one will be used to populate the first drop down list. The contents of
 * the cells on rows two, three and four will be used to populate the second
 * drop down list, just which row will be determined by the choice the user
 * makes in the first drop down list.//from   w  w  w.ja  v a 2 s.com
 *
 * In all cases, the approach is to create a row, create and populate cells
 * with data and then specify a name that identifies those cells. With the
 * exception of the first range, the names that are chosen for each range
 * of cells are quite important. In short, each of the options the user
 * could select in the first drop down list is used as the name for another
 * range of cells. Thus, in this example, the user can select either
 * 'Animal', 'Vegetable' or 'Mineral' in the first drop down and so the
 * sheet contains ranges named 'ANIMAL', 'VEGETABLE' and 'MINERAL'.
 *
 * @param dataSheet An instance of a class that implements the Sheet Sheet
 *        interface (HSSFSheet or XSSFSheet).
 */
private static final void buildDataSheet(Sheet dataSheet) {
    Row row = null;
    Cell cell = null;
    Name name = null;

    // The first row will hold the data for the first validation.
    row = dataSheet.createRow(10);
    cell = row.createCell(0);
    cell.setCellValue("Animal");
    cell = row.createCell(1);
    cell.setCellValue("Vegetable");
    cell = row.createCell(2);
    cell.setCellValue("Mineral");
    name = dataSheet.getWorkbook().createName();
    name.setRefersToFormula("$A$11:$C$11");
    name.setNameName("CHOICES");

    // The next three rows will hold the data that will be used to
    // populate the second, or linked, drop down list.
    row = dataSheet.createRow(11);
    cell = row.createCell(0);
    cell.setCellValue("Lion");
    cell = row.createCell(1);
    cell.setCellValue("Tiger");
    cell = row.createCell(2);
    cell.setCellValue("Leopard");
    cell = row.createCell(3);
    cell.setCellValue("Elephant");
    cell = row.createCell(4);
    cell.setCellValue("Eagle");
    cell = row.createCell(5);
    cell.setCellValue("Horse");
    cell = row.createCell(6);
    cell.setCellValue("Zebra");
    name = dataSheet.getWorkbook().createName();
    name.setRefersToFormula("$A$12:$G$12");
    name.setNameName("ANIMAL");

    row = dataSheet.createRow(12);
    cell = row.createCell(0);
    cell.setCellValue("Cabbage");
    cell = row.createCell(1);
    cell.setCellValue("Cauliflower");
    cell = row.createCell(2);
    cell.setCellValue("Potato");
    cell = row.createCell(3);
    cell.setCellValue("Onion");
    cell = row.createCell(4);
    cell.setCellValue("Beetroot");
    cell = row.createCell(5);
    cell.setCellValue("Asparagus");
    cell = row.createCell(6);
    cell.setCellValue("Spinach");
    cell = row.createCell(7);
    cell.setCellValue("Chard");
    name = dataSheet.getWorkbook().createName();
    name.setRefersToFormula("$A$13:$H$13");
    name.setNameName("VEGETABLE");

    row = dataSheet.createRow(13);
    cell = row.createCell(0);
    cell.setCellValue("Bauxite");
    cell = row.createCell(1);
    cell.setCellValue("Quartz");
    cell = row.createCell(2);
    cell.setCellValue("Feldspar");
    cell = row.createCell(3);
    cell.setCellValue("Shist");
    cell = row.createCell(4);
    cell.setCellValue("Shale");
    cell = row.createCell(5);
    cell.setCellValue("Mica");
    name = dataSheet.getWorkbook().createName();
    name.setRefersToFormula("$A$14:$F$14");
    name.setNameName("MINERAL");
}

From source file:cn.study.innerclass.PoiUtil.java

License:Open Source License

public static void setCellData(Cell cell) {
    cell.setCellValue(5);
}

From source file:co.com.runt.runistac.logica.ReporteLogica.java

public static byte[] generar(InputStream plantilla, Map<String, String> parametros, List<Object[]> datos)
        throws Exception {
    XSSFWorkbook wb = new XSSFWorkbook(plantilla);
    XSSFSheet mySheet = wb.getSheetAt(0);
    for (int i = 0; i < mySheet.getLastRowNum(); i++) {
        Row row = mySheet.getRow(i);/*from w w  w . j a v a  2  s. c  o m*/
        if (row != null && row.getCell(0) != null && row.getCell(0).getCellTypeEnum() == CellType.STRING) {
            for (String key : parametros.keySet()) {
                String valor = row.getCell(0).getStringCellValue();
                valor = valor.replaceAll("\\{" + key + "\\}", parametros.get(key));
                row.getCell(0).setCellValue(valor);
            }
        }
    }

    int rows = mySheet.getLastRowNum();
    int i = 0;
    Row base = mySheet.getRow(rows);
    CellStyle[] cs = null;
    if (!datos.isEmpty()) {
        int cant = datos.get(0).length;
        cs = new CellStyle[cant];
        for (int j = 0; j < cant; j++) {
            cs[j] = base.getCell(j).getCellStyle();
        }
    }
    for (Object[] o : datos) {
        Row row = mySheet.createRow(rows + i);
        for (int j = 0; j < o.length; j++) {
            Cell c = row.createCell(j);
            String value = "";
            if (o[j] != null) {
                if (o[j] instanceof String) {
                    value = (String) o[j];
                    c.setCellValue(value);
                } else if (o[j] instanceof Integer) {//integer
                    c.setCellValue((Integer) o[j]);
                } else if (o[j] instanceof Double) {
                    c.setCellValue((Double) o[j]);
                } else if (o[j] instanceof Float) {
                    c.setCellValue((Float) o[j]);
                } else if (o[j] instanceof BigDecimal) {
                    c.setCellValue(((BigDecimal) o[j]).doubleValue());
                } else if (o[j] instanceof Date) {
                    c.setCellValue(((Date) o[j]));
                } else if (o[j] instanceof BigInteger) {
                    c.setCellValue(((BigInteger) o[j]).intValue());
                } else {
                    c.setCellValue(o[j].toString());
                    System.out.println("No se encontro tipo: " + j + "-" + o[j].getClass());
                }
            }
            c.setCellStyle(cs[j]);
        }
        i++;
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    wb.write(baos);

    return baos.toByteArray();
}

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeActionActorClassTable(HSSFWorkbook workbook, HotspotsDataAnalyser analyzer) {
    HSSFSheet sheet = workbook.createSheet("<Action, ActorClass>");
    // Action Actor Class Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Action and Actor Class Results");
    title.applyFont(titleFont);// ww  w .  j ava  2  s . c  om
    cell.setCellValue(title);

    Row row = sheet.createRow(1);
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 0, 0));
    row.createCell(0).setCellValue("Action");
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 1, 1));
    row.createCell(1).setCellValue("Actor Class");

    sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 7));
    row.createCell(2).setCellValue("Total Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 8, 12));
    row.createCell(8).setCellValue("Non Deferrable Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 13, 17));
    row.createCell(13).setCellValue("Critical Executions");

    row = sheet.createRow(2);
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 2, 3));
    row.createCell(2).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 4, 6));
    row.createCell(4).setCellValue("Clock Cycles");
    row.createCell(7).setCellValue("Slack");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 8, 9));
    row.createCell(8).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 10, 12));
    row.createCell(10).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 13, 14));
    row.createCell(13).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 15, 17));
    row.createCell(15).setCellValue("Clock Cycles");

    row = sheet.createRow(3);
    row.createCell(2).setCellValue("%");
    row.createCell(3).setCellValue("abs");
    row.createCell(4).setCellValue("%");
    row.createCell(5).setCellValue("mean");
    row.createCell(6).setCellValue("variance");
    row.createCell(7).setCellValue("min");
    row.createCell(8).setCellValue("%");
    row.createCell(9).setCellValue("abs");
    row.createCell(10).setCellValue("%");
    row.createCell(11).setCellValue("mean");
    row.createCell(12).setCellValue("variance");
    row.createCell(13).setCellValue("%");
    row.createCell(14).setCellValue("abs");
    row.createCell(15).setCellValue("%");
    row.createCell(16).setCellValue("mean");
    row.createCell(17).setCellValue("variance");

    Table<ActorClass, Action, ExtendExecData> cTable = analyzer.getSumDataTable(ActorClass.class,
            Key.CRITICAL_CLOCKCYCLES, Order.DECREASING);

    // row index
    int rowi = 4;
    for (Table.Cell<ActorClass, Action, ExtendExecData> entry : cTable.cellSet()) {

        row = sheet.createRow(rowi);
        rowi++;

        row.createCell(0).setCellValue(entry.getColumnKey().getId());
        row.createCell(1).setCellValue(entry.getRowKey().getName());

        ExtendExecData exec = entry.getValue();
        cell = row.createCell(2);
        cell.setCellFormula("D" + rowi + "/Summary!A14*100");
        row.createCell(3).setCellValue(exec.getTotalExec().getExecutions());
        cell = row.createCell(4);
        cell.setCellFormula("F" + rowi + "/Summary!B14*100");
        row.createCell(5).setCellValue(exec.getTotalExec().getClockCyclesMean());
        row.createCell(6).setCellValue(exec.getTotalExec().getClockCyclesVariance());

        double slack = exec.getSlack().getMin();
        slack = slack > AnalysisUtil.PRECISION_EPS ? slack : 0.0;
        row.createCell(7).setCellValue(slack);
        cell = row.createCell(8);
        cell.setCellFormula("J" + rowi + "/Summary!E14*100");
        row.createCell(9).setCellValue(exec.getNotDeferrableExec().getExecutions());
        cell = row.createCell(10);
        cell.setCellFormula("L" + rowi + "/Summary!G14*100");
        row.createCell(11).setCellValue(exec.getNotDeferrableExec().getClockCyclesMean());
        row.createCell(12).setCellValue(exec.getNotDeferrableExec().getClockCyclesVariance());
        cell = row.createCell(13);
        cell.setCellFormula("O" + rowi + "/Summary!J14*100");
        row.createCell(14).setCellValue(exec.getCriticalExec().getExecutions());
        cell = row.createCell(15);
        cell.setCellFormula("Q" + rowi + "/Summary!L14*100");
        row.createCell(16).setCellValue(exec.getCriticalExec().getClockCyclesMean());
        row.createCell(17).setCellValue(exec.getCriticalExec().getClockCyclesVariance());
    }
}

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeActionActorTable(HSSFWorkbook workbook, HotspotsDataAnalyser analyzer) {
    HSSFSheet sheet = workbook.createSheet("<Action, Actor>");
    // Action Actor Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Action and Actor Results");
    title.applyFont(titleFont);//from   ww w.j  av  a 2 s  .c o m
    cell.setCellValue(title);
    Row row = sheet.createRow(1);
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 0, 0));
    row.createCell(0).setCellValue("Action");
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 1, 1));
    row.createCell(1).setCellValue("Actor");

    sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 9));
    row.createCell(2).setCellValue("Total Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 10, 14));
    row.createCell(10).setCellValue("Non Deferrable Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 15, 19));
    row.createCell(15).setCellValue("Critical Executions");

    row = sheet.createRow(2);
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 2, 3));
    row.createCell(2).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 4, 6));
    row.createCell(4).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 7, 9));
    row.createCell(7).setCellValue("Slack");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 10, 11));
    row.createCell(10).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 12, 14));
    row.createCell(12).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 15, 16));
    row.createCell(15).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 17, 19));
    row.createCell(17).setCellValue("Clock Cycles");

    row = sheet.createRow(3);
    row.createCell(2).setCellValue("%");
    row.createCell(3).setCellValue("abs");
    row.createCell(4).setCellValue("%");
    row.createCell(5).setCellValue("mean");
    row.createCell(6).setCellValue("variance");
    row.createCell(7).setCellValue("min");
    row.createCell(8).setCellValue("average");
    row.createCell(9).setCellValue("variance");
    row.createCell(10).setCellValue("%");
    row.createCell(11).setCellValue("abs");
    row.createCell(12).setCellValue("%");
    row.createCell(13).setCellValue("mean");
    row.createCell(14).setCellValue("variance");
    row.createCell(15).setCellValue("%");
    row.createCell(16).setCellValue("abs");
    row.createCell(17).setCellValue("%");
    row.createCell(18).setCellValue("mean");
    row.createCell(19).setCellValue("variance");

    Table<Actor, Action, ExtendExecData> aTable = analyzer.getSumDataTable(Actor.class,
            Key.CRITICAL_CLOCKCYCLES, Order.DECREASING);

    // row index
    int rowi = 4;
    for (Table.Cell<Actor, Action, ExtendExecData> entry : aTable.cellSet()) {
        row = sheet.createRow(rowi);
        rowi++;

        row.createCell(0).setCellValue(entry.getColumnKey().getId());
        row.createCell(1).setCellValue(entry.getRowKey().getId());

        ExtendExecData exec = entry.getValue();
        cell = row.createCell(2);
        cell.setCellFormula("D" + rowi + "/Summary!A14*100");
        row.createCell(3).setCellValue(exec.getTotalExec().getExecutions());
        cell = row.createCell(4);
        cell.setCellFormula("F" + rowi + "/Summary!B14*100");
        row.createCell(5).setCellValue(exec.getTotalExec().getClockCyclesMean());
        row.createCell(6).setCellValue(exec.getTotalExec().getClockCyclesVariance());

        double slack = exec.getSlack().getMin();
        slack = slack > AnalysisUtil.PRECISION_EPS ? slack : 0.0;
        row.createCell(7).setCellValue(slack);
        double slackAvg = exec.getSlack().getMean();
        slackAvg = slackAvg > AnalysisUtil.PRECISION_EPS ? slackAvg : 0.0;
        row.createCell(8).setCellValue(slackAvg);
        double slackVar = exec.getSlack().getVariance();
        slackVar = slackVar > AnalysisUtil.PRECISION_EPS ? slackVar : 0.0;
        row.createCell(9).setCellValue(slackVar);
        cell = row.createCell(10);
        cell.setCellFormula("L" + rowi + "/Summary!E14*100");
        row.createCell(11).setCellValue(exec.getNotDeferrableExec().getExecutions());
        cell = row.createCell(12);
        cell.setCellFormula("N" + rowi + "/Summary!G14*100");
        row.createCell(13).setCellValue(exec.getNotDeferrableExec().getClockCyclesMean());
        row.createCell(14).setCellValue(exec.getNotDeferrableExec().getClockCyclesVariance());
        cell = row.createCell(15);
        cell.setCellFormula("Q" + rowi + "/Summary!J14*100");
        row.createCell(16).setCellValue(exec.getCriticalExec().getExecutions());
        cell = row.createCell(17);
        cell.setCellFormula("S" + rowi + "/Summary!L14*100");
        row.createCell(18).setCellValue(exec.getCriticalExec().getClockCyclesMean());
        row.createCell(19).setCellValue(exec.getCriticalExec().getClockCyclesVariance());

    }

}

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeActorClassesTable(HSSFWorkbook workbook, HotspotsDataAnalyser analyzer) {
    HSSFSheet sheet = workbook.createSheet("ActorClasses");

    // Actor classes Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("ActorClasses Results");
    title.applyFont(titleFont);/*from   w w  w.  ja  v a2 s  .c o m*/
    cell.setCellValue(title);

    Row row = sheet.createRow(1);
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 0, 0));
    row.createCell(0).setCellValue("Class");
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 1, 1));
    row.createCell(1).setCellValue("File");
    sheet.addMergedRegion(new CellRangeAddress(1, 2, 2, 3));
    row.createCell(2).setCellValue("Version");

    sheet.addMergedRegion(new CellRangeAddress(1, 1, 4, 8));
    row.createCell(4).setCellValue("Total Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 9, 13));
    row.createCell(9).setCellValue("Non Deferrable Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 14, 18));
    row.createCell(14).setCellValue("Critical Executions");

    row = sheet.createRow(2);
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 4, 5));
    row.createCell(4).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 6, 8));
    row.createCell(6).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 9, 10));
    row.createCell(9).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 11, 13));
    row.createCell(11).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 14, 15));
    row.createCell(14).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 16, 18));
    row.createCell(16).setCellValue("Clock Cycles");

    row = sheet.createRow(3);
    row.createCell(2).setCellValue("ID");
    row.createCell(3).setCellValue("Last Modification");
    row.createCell(4).setCellValue("%");
    row.createCell(5).setCellValue("abs");
    row.createCell(6).setCellValue("%");
    row.createCell(7).setCellValue("mean");
    row.createCell(8).setCellValue("variance");
    row.createCell(9).setCellValue("%");
    row.createCell(10).setCellValue("abs");
    row.createCell(11).setCellValue("%");
    row.createCell(12).setCellValue("mean");
    row.createCell(13).setCellValue("variance");
    row.createCell(14).setCellValue("%");
    row.createCell(15).setCellValue("abs");
    row.createCell(16).setCellValue("%");
    row.createCell(17).setCellValue("mean");
    row.createCell(18).setCellValue("variance");

    Map<ActorClass, ExtendExecData> cMap = analyzer.getSumDataMap(ActorClass.class, Key.CRITICAL_CLOCKCYCLES,
            Order.DECREASING);

    // row index
    int rowi = 4;
    for (Entry<ActorClass, ExtendExecData> entry : cMap.entrySet()) {
        ActorClass clazz = entry.getKey();
        ExtendExecData exec = entry.getValue();

        row = sheet.createRow(rowi);
        rowi++;

        row.createCell(0).setCellValue(clazz.getName());
        row.createCell(1).setCellValue(clazz.getSourceFile());
        row.createCell(2).setCellValue(clazz.getVersion().getId());
        cell = row.createCell(3);
        cell.setCellValue(clazz.getVersion().getLastModificationDate());
        cell.setCellStyle(cellStyle);
        cell = row.createCell(4);
        cell.setCellFormula("F" + rowi + "/Summary!A14*100");
        row.createCell(5).setCellValue(exec.getTotalExec().getExecutions());
        cell = row.createCell(6);
        cell.setCellFormula("H" + rowi + "/Summary!B14*100");
        row.createCell(7).setCellValue(exec.getTotalExec().getClockCyclesMean());
        row.createCell(8).setCellValue(exec.getTotalExec().getClockCyclesVariance());
        cell = row.createCell(9);
        cell.setCellFormula("K" + rowi + "/Summary!E14*100");
        row.createCell(10).setCellValue(exec.getNotDeferrableExec().getExecutions());
        cell = row.createCell(11);
        cell.setCellFormula("M" + rowi + "/Summary!G14*100");
        row.createCell(12).setCellValue(exec.getNotDeferrableExec().getClockCyclesMean());
        row.createCell(13).setCellValue(exec.getNotDeferrableExec().getClockCyclesVariance());
        cell = row.createCell(14);
        cell.setCellFormula("P" + rowi + "/Summary!J14*100");
        row.createCell(15).setCellValue(exec.getCriticalExec().getExecutions());
        cell = row.createCell(16);
        cell.setCellFormula("R" + rowi + "/Summary!L14*100");
        row.createCell(17).setCellValue(exec.getCriticalExec().getClockCyclesMean());
        row.createCell(18).setCellValue(exec.getCriticalExec().getClockCyclesVariance());

    }

}