Example usage for org.apache.poi.ss.usermodel Row setHeight

List of usage examples for org.apache.poi.ss.usermodel Row setHeight

Introduction

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

Prototype

void setHeight(short height);

Source Link

Document

Set the row's height or set to ff (-1) for undefined/default-height.

Usage

From source file:com.sec.ose.osi.report.standard.IdentifiedFilesSheetTemplate.java

License:Open Source License

protected void createTable() {

    short subItemThickness = (short) (35 * BASE_HEIGHT);
    CellStyle styleSubItem = getCellStyle(ROYAL_BLUE, getFont(FONT_WHITE, (short) 10, true));

    //  ROW_2//w  ww  .jav  a 2 s. c om
    Row row = sheet.createRow(ROW_2);
    row.setHeight(subItemThickness);

    Cell cell = row.createCell(COL_A);
    cell.setCellValue("ProjectName");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_B);
    cell.setCellValue("FullPath");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_C);
    cell.setCellValue("Component");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_D);
    cell.setCellValue("License");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_E);
    cell.setCellValue("DiscoveryType");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_F);
    cell.setCellValue("CodeMatch URL");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_G);
    cell.setCellValue("Comment");
    cell.setCellStyle(styleSubItem);

}

From source file:com.sec.ose.osi.report.standard.SummarySheetTemplate.java

License:Open Source License

protected void createTitle() {
    // Title/*from  ww  w  . ja  v  a 2 s .  c  o m*/
    Row row = sheet.createRow(ROW_1);
    row.setHeight((short) (43 * BASE_HEIGHT));

    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:K1"));

    Cell cell = row.createCell(COL_A);
    cell.setCellValue("Summary");
    cell.setCellStyle(titleStyle);
}

From source file:com.sec.ose.osi.report.standard.SummarySheetTemplate.java

License:Open Source License

protected void createTable() {

    short mainItemBorderThickness = (short) (24 * BASE_HEIGHT);
    short subItemBorderThickness = (short) (45 * BASE_HEIGHT);
    CellStyle styleMainItem = getCellStyle(ROYAL_BLUE, getFont(FONT_WHITE, (short) 12, true));
    CellStyle styleSubItem = getCellStyle(ROYAL_BLUE, getFont(FONT_WHITE, (short) 10, false));

    //  ROW_2//from   w  w  w.  j av a  2s.c  o  m
    Row row = sheet.createRow(ROW_2);
    row.setHeight(mainItemBorderThickness);

    sheet.addMergedRegion(CellRangeAddress.valueOf("A2:A3"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("B2:B3"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("C2:I2"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("J2:K2"));

    Cell cell = row.createCell(COL_A);
    cell.setCellValue("Classification");
    cell.setCellStyle(styleMainItem);

    cell = row.createCell(COL_B);
    cell.setCellValue("Project Name");
    cell.setCellStyle(styleMainItem);

    cell = row.createCell(COL_C);
    cell.setCellValue("Source Code Scan Result");
    cell.setCellStyle(styleMainItem);

    row.createCell(COL_D).setCellStyle(styleMainItem);
    row.createCell(COL_E).setCellStyle(styleMainItem);
    row.createCell(COL_F).setCellStyle(styleMainItem);
    row.createCell(COL_G).setCellStyle(styleMainItem);
    row.createCell(COL_H).setCellStyle(styleMainItem);
    row.createCell(COL_I).setCellStyle(styleMainItem);

    // Identify Result

    CellStyle style = getCellStyle(LIGHT_RED, getFont(DARK_RED, (short) 12, true));

    cell = row.createCell(COL_J);
    cell.setCellValue("Identify Result");
    cell.setCellStyle(style);

    row.createCell(COL_K).setCellStyle(style);

    //  ROW_3
    row = sheet.createRow(ROW_3);
    row.setHeight(subItemBorderThickness);

    cell = row.createCell(COL_A);
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_B);
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_C);
    cell.setCellValue("Scan Date");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_D);
    cell.setCellValue("Scan time\n(HH:MM:SS)");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_E);
    cell.setCellValue("Pending Files");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_F);
    cell.setCellValue("Pending\n(%)");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_G);
    cell.setCellValue("Total Files");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_H);
    cell.setCellValue("Exceptional Files");
    cell.setCellStyle(styleSubItem);

    cell = row.createCell(COL_I);
    cell.setCellValue("Bytes");
    cell.setCellStyle(styleSubItem);

    // Identify Result

    style = getCellStyle(LIGHT_RED, getFont(DARK_RED, (short) 10, true));

    cell = row.createCell(COL_J);
    cell.setCellValue("Total Identified Files");
    cell.setCellStyle(style);

    cell = row.createCell(COL_K);
    cell.setCellValue("Current Pending Files");
    cell.setCellStyle(style);

}

From source file:com.vincestyling.apkinfoextractor.core.export.ExportToExcel.java

License:Apache License

@Override
public void export() throws Exception {
    Workbook wb = new HSSFWorkbook();

    Map<String, CellStyle> styles = createStyles(wb);

    Sheet sheet = wb.createSheet(Constancts.APP_NAME);
    sheet.setHorizontallyCenter(true);/*w  w w.  j a v a  2  s .com*/
    sheet.setFitToPage(true);

    Row titleRow = sheet.createRow(0);
    titleRow.setHeightInPoints(45);
    Cell titleCell = titleRow.createCell(0);
    titleCell.setCellValue(
            "  File generated by ApkInfoExtractor (https://github.com/vince-styling/ApkInfoExtractor), Copyright (C) 2014 Vince Styling");
    titleCell.setCellStyle(styles.get("title"));

    Row headerRow = sheet.createRow(1);
    headerRow.setHeightInPoints(40);

    int cellNum = 0;
    String[] fields = solution.getExtractFields().split(",");
    for (String field : fields) {
        if (field.equals(Constancts.ICON))
            continue;
        Cell headerCell = headerRow.createCell(cellNum);
        headerCell.setCellValue(field);
        headerCell.setCellStyle(styles.get("header"));
        sheet.setColumnWidth(cellNum, ApkInfo.getFieldCharacterCount(field) * 256);
        cellNum++;
    }

    int rowNum = 2;
    for (int i = 0; i < solution.getResultCount(); i++) {
        ResultDataProvider provider = solution.getResultList().get(i);
        postProgress(i + 1);

        cellNum = 0;
        Row row = sheet.createRow(rowNum++);
        for (String field : fields) {
            if (field.equals(Constancts.ICON))
                continue;
            Cell cell = row.createCell(cellNum);
            cell.setCellStyle(styles.get("cell"));
            String value = getFieldValue(provider.getApkInfo(), field);
            cell.setCellValue(value);
            cellNum++;
        }
        row.setHeight((short) (5 * 256));
    }

    File outputFile = new File(solution.getWorkingFolder(), solution.generateOutputFileName() + ".xls");
    FileOutputStream out = new FileOutputStream(outputFile);
    wb.write(out);
    out.close();

    callback.onProcessSuccess(outputFile);
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.timeseriesExcel.exporter.TimeseriesExcelTemplateGenerator.java

License:Open Source License

private void addBuildingBlockType(TimeseriesSheetContext sheetContext, Map<IteraExcelStyle, CellStyle> styles) {
    Sheet sheet = sheetContext.getSheet();

    Row bbTypeRow = sheet.getRow(TimeseriesExcelImporter.BB_TYPE_CELL_REF.getRow());
    bbTypeRow.setHeight((short) 0);
    Cell bbTypeCell = bbTypeRow.getCell(TimeseriesExcelImporter.BB_TYPE_CELL_REF.getCol());
    bbTypeCell.setCellStyle(styles.get(IteraExcelStyle.DATA_HIDDEN));
    bbTypeCell.setCellValue(sheetContext.getTobb().getAssociatedClass().getSimpleName());
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.timeseriesExcel.exporter.TimeseriesExcelTemplateGenerator.java

License:Open Source License

private void addAttributeType(TimeseriesSheetContext sheetContext, Map<IteraExcelStyle, CellStyle> styles) {
    Sheet sheet = sheetContext.getSheet();

    Row atRow = sheet.getRow(TimeseriesExcelImporter.AT_CELL_REF.getRow());
    atRow.setHeight((short) 0);
    Cell atCell = atRow.getCell(TimeseriesExcelImporter.AT_CELL_REF.getCol());
    atCell.setCellStyle(styles.get(IteraExcelStyle.DATA_HIDDEN));
    atCell.setCellValue(sheetContext.getAt().getName());
}

From source file:egovframework.rte.fdl.excel.EgovExcelServiceTest.java

License:Apache License

/**
 * [Flow #-2]  ?  : ? ?  ? ?    ?//from  w  ww. j ava2  s.c  o m
 */
@Test
public void testModifyCellContents() throws Exception {

    try {
        String content = "Use \n with word wrap on to create a new line";
        short rownum = 2;
        int cellnum = 2;

        LOGGER.debug("testModifyCellContents start....");

        StringBuffer sb = new StringBuffer();
        sb.append(fileLocation).append("/").append("testModifyCellContents.xls");

        if (!EgovFileUtil.isExistsFile(sb.toString())) {
            Workbook wbT = new HSSFWorkbook();
            wbT.createSheet();

            //  ? ?
            excelService.createWorkbook(wbT, sb.toString());
        }

        //  ? 
        Workbook wb = excelService.loadWorkbook(sb.toString());
        LOGGER.debug("testModifyCellContents after loadWorkbook....");

        Sheet sheet = wb.getSheetAt(0);
        Font f2 = wb.createFont();
        CellStyle cs = wb.createCellStyle();
        cs = wb.createCellStyle();

        cs.setFont(f2);
        //Word Wrap MUST be turned on
        cs.setWrapText(true);

        Row row = sheet.createRow(rownum);
        row.setHeight((short) 0x349);
        Cell cell = row.createCell(cellnum);
        cell.setCellType(Cell.CELL_TYPE_STRING);
        cell.setCellValue(new HSSFRichTextString(content));
        cell.setCellStyle(cs);

        sheet.setColumnWidth(20, (int) ((50 * 8) / ((double) 1 / 20)));

        //excelService.writeWorkbook(wb);

        FileOutputStream out = new FileOutputStream(sb.toString());
        wb.write(out);
        out.close();

        //  ? 
        Workbook wb1 = excelService.loadWorkbook(sb.toString());

        Sheet sheet1 = wb1.getSheetAt(0);
        Row row1 = sheet1.getRow(rownum);
        Cell cell1 = row1.getCell(cellnum);

        // ? ?  ?
        LOGGER.debug("cell ###{}###", cell1.getRichStringCellValue());
        LOGGER.debug("cont ###{}###", content);

        assertNotSame("TEST", cell1.getRichStringCellValue().toString());
        assertEquals(content, cell1.getRichStringCellValue().toString());

    } catch (Exception e) {
        LOGGER.error(e.toString());
        throw new Exception(e);
    } finally {
        LOGGER.debug("testModifyCellContents end....");
    }
}

From source file:egovframework.rte.fdl.excel.EgovExcelXSSFServiceTest.java

License:Apache License

/**
 * [Flow #-2]  ?  : ? ?  ? ?    ?//from   www.j  a  v  a 2 s  .c  o  m
 */
@Test
public void testModifyCellContents() throws Exception {

    try {
        String content = "Use \n with word wrap on to create a new line";
        short rownum = 2;
        int cellnum = 2;

        LOGGER.debug("testModifyCellContents start....");

        StringBuffer sb = new StringBuffer();
        sb.append(fileLocation).append("/").append("testModifyCellContents.xlsx");

        if (!EgovFileUtil.isExistsFile(sb.toString())) {
            Workbook wbT = new XSSFWorkbook();
            wbT.createSheet();

            //  ? ?
            excelService.createWorkbook(wbT, sb.toString());
        }

        //  ? 
        XSSFWorkbook wb = null;
        wb = excelService.loadWorkbook(sb.toString(), wb);
        LOGGER.debug("testModifyCellContents after loadWorkbook....");

        Sheet sheet = wb.getSheetAt(0);
        Font f2 = wb.createFont();
        CellStyle cs = wb.createCellStyle();
        cs = wb.createCellStyle();

        cs.setFont(f2);
        //Word Wrap MUST be turned on
        cs.setWrapText(true);

        Row row = sheet.createRow(rownum);
        row.setHeight((short) 0x349);
        Cell cellx = row.createCell(cellnum);
        cellx.setCellType(XSSFCell.CELL_TYPE_STRING);
        cellx.setCellValue(new XSSFRichTextString(content));
        cellx.setCellStyle(cs);

        sheet.setColumnWidth(20, (int) ((50 * 8) / ((double) 1 / 20)));

        //excelService.writeWorkbook(wb);

        FileOutputStream outx = new FileOutputStream(sb.toString());
        wb.write(outx);
        outx.close();

        //  ? 
        Workbook wb1 = excelService.loadWorkbook(sb.toString(), new XSSFWorkbook());

        Sheet sheet1 = wb1.getSheetAt(0);
        Row row1 = sheet1.getRow(rownum);
        Cell cell1 = row1.getCell(cellnum);

        // ? ?  ?
        LOGGER.debug("cell ###{}###", cell1.getRichStringCellValue());
        LOGGER.debug("cont ###{}###", content);

        assertNotSame("TEST", cell1.getRichStringCellValue().toString());
        assertEquals(content, cell1.getRichStringCellValue().toString());

    } catch (Exception e) {
        LOGGER.error(e.toString());
        throw new Exception(e);
    } finally {
        LOGGER.debug("testModifyCellContents end....");
    }
}

From source file:egovframework.rte.fdl.excel.EgovExcelXSSFServiceTest.java

License:Apache License

/**
 * [Flow #-6]  ?  :  ? ?(?, ? )? /* w  w  w .  j  a va 2  s .c  o  m*/
 */
@Test
public void testModifyCellAttribute() throws Exception {

    try {
        LOGGER.debug("testModifyCellAttribute start....");

        StringBuffer sb = new StringBuffer();
        sb.append(fileLocation).append("/").append("testModifyCellAttribute.xlsx");

        if (EgovFileUtil.isExistsFile(sb.toString())) {
            EgovFileUtil.delete(new File(sb.toString()));

            LOGGER.debug("Delete file....{}", sb.toString());
        }

        Workbook wbTmp = new XSSFWorkbook();
        wbTmp.createSheet();

        //  ? ?
        excelService.createWorkbook(wbTmp, sb.toString());

        //  ? 
        XSSFWorkbook wb = excelService.loadWorkbook(sb.toString(), new XSSFWorkbook());
        LOGGER.debug("testModifyCellAttribute after loadWorkbook....");

        Sheet sheet = wb.createSheet("cell test sheet2");
        sheet.setColumnWidth((short) 3, (short) 200); // column Width

        CellStyle cs = wb.createCellStyle();
        XSSFFont font = wb.createFont();
        font.setFontHeight(16);
        font.setBoldweight((short) 3);
        font.setFontName("fixedsys");

        cs.setFont(font);
        cs.setAlignment(XSSFCellStyle.ALIGN_RIGHT); // cell 
        cs.setWrapText(true);

        for (int i = 0; i < 100; i++) {
            Row row = sheet.createRow(i);
            row.setHeight((short) 300); // row? height 

            for (int j = 0; j < 5; j++) {
                Cell cell = row.createCell(j);
                cell.setCellValue(new XSSFRichTextString("row " + i + ", cell " + j));
                cell.setCellStyle(cs);
            }
        }

        //  ? 
        FileOutputStream out = new FileOutputStream(sb.toString());
        wb.write(out);
        out.close();

        //////////////////////////////////////////////////////////////////////////
        // ?
        XSSFWorkbook wbT = excelService.loadWorkbook(sb.toString(), new XSSFWorkbook());
        Sheet sheetT = wbT.getSheet("cell test sheet2");
        LOGGER.debug("getNumCellStyles : {}", wbT.getNumCellStyles());

        XSSFCellStyle cs1 = (XSSFCellStyle) wbT.getCellStyleAt((short) (wbT.getNumCellStyles() - 1));

        XSSFFont fontT = cs1.getFont();
        LOGGER.debug("font getFontHeight : {}", fontT.getFontHeight());
        LOGGER.debug("font getBoldweight : {}", fontT.getBoldweight());
        LOGGER.debug("font getFontName : {}", fontT.getFontName());
        LOGGER.debug("getAlignment : {}", cs1.getAlignment());
        LOGGER.debug("getWrapText : {}", cs1.getWrapText());

        for (int i = 0; i < 100; i++) {
            Row row1 = sheetT.getRow(i);
            for (int j = 0; j < 5; j++) {
                Cell cell1 = row1.getCell(j);
                LOGGER.debug("row {}, cell {} : {}", i, j, cell1.getRichStringCellValue());
                assertEquals(320, fontT.getFontHeight());
                assertEquals(400, fontT.getBoldweight());
                LOGGER.debug("fontT.getBoldweight()? ? 400? ?");

                assertEquals(XSSFCellStyle.ALIGN_RIGHT, cs1.getAlignment());
                assertTrue(cs1.getWrapText());
            }
        }

    } catch (Exception e) {
        LOGGER.error(e.toString());
        throw new Exception(e);
    } finally {
        LOGGER.debug("testModifyCellAttribute end....");
    }
}

From source file:fr.amapj.service.engine.generator.excel.ExcelCellAutoSize.java

License:Open Source License

public void autosize(Row currentRow) {
    // Contient la hauteur de la ligne en point
    // le minimum de hauteur est de une ligne fonte 10
    double height = getRealHeight(10);

    for (ExcelSize cell : cells) {
        double currentHeight = getLineCount(cell) * getRealHeight(cell.fontSize);

        height = Math.max(height, currentHeight);
    }/*  w ww.j  av a 2 s  .  c  o m*/

    currentRow.setHeight((short) (20 * (height + additionalSpace)));
}