Search in sources :

Example 1 with CellStyle

use of org.apache.poi.ss.usermodel.CellStyle in project Robot-Scouter by SUPERCILEX.

the class SpreadsheetCache method createColumnHeaderStyle.

private CellStyle createColumnHeaderStyle() {
    CellStyle style = createBaseStyle();
    style.setFont(createBaseHeaderFont());
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    return style;
}
Also used : CellStyle(org.apache.poi.ss.usermodel.CellStyle)

Example 2 with CellStyle

use of org.apache.poi.ss.usermodel.CellStyle in project Robot-Scouter by SUPERCILEX.

the class SpreadsheetCache method getHeaderMetricRowHeaderStyle.

@Nullable
public CellStyle getHeaderMetricRowHeaderStyle() {
    if (isUnsupportedDevice())
        return null;
    CellStyle rowHeaderStyle = createRowHeaderStyle();
    Font font = createBaseHeaderFont();
    font.setItalic(true);
    font.setFontHeightInPoints((short) 14);
    rowHeaderStyle.setFont(font);
    return rowHeaderStyle;
}
Also used : CellStyle(org.apache.poi.ss.usermodel.CellStyle) Font(org.apache.poi.ss.usermodel.Font) Nullable(android.support.annotation.Nullable)

Example 3 with CellStyle

use of org.apache.poi.ss.usermodel.CellStyle in project Robot-Scouter by SUPERCILEX.

the class SpreadsheetCache method setCellFormat.

public void setCellFormat(Cell cell, String format) {
    if (isUnsupportedDevice())
        return;
    Short cachedFormat = mFormatStyles.get(format);
    if (cachedFormat == null) {
        cachedFormat = mWorkbook.createDataFormat().getFormat(format);
        mFormatStyles.put(format, cachedFormat);
    }
    CellStyle style = mWorkbook.createCellStyle();
    style.setDataFormat(cachedFormat);
    cell.setCellStyle(style);
}
Also used : CellStyle(org.apache.poi.ss.usermodel.CellStyle)

Example 4 with CellStyle

use of org.apache.poi.ss.usermodel.CellStyle in project tdi-studio-se by Talend.

the class ExcelTool method getPreCellStyle.

private CellStyle getPreCellStyle() {
    if (preSheet != null && isAbsY && keepCellFormat) {
        CellStyle preCellStyle = null;
        if (preCell == null) {
            preCellStyle = preSheet.getColumnStyle(curCell.getColumnIndex());
        } else {
            preCellStyle = preCell.getCellStyle();
        }
        CellStyle targetCellStyle = wb.createCellStyle();
        targetCellStyle.cloneStyleFrom(preCellStyle);
        return targetCellStyle;
    } else {
        return null;
    }
}
Also used : CellStyle(org.apache.poi.ss.usermodel.CellStyle)

Example 5 with CellStyle

use of org.apache.poi.ss.usermodel.CellStyle in project tdi-studio-se by Talend.

the class ExcelTool method getDateCellStyle.

private CellStyle getDateCellStyle(String pattern) {
    CellStyle preCellStyle = getPreCellStyle();
    if (preCellStyle == null) {
        if (cellStylesMapping.get(pattern) != null) {
            return cellStylesMapping.get(pattern);
        } else {
            CellStyle style = wb.createCellStyle();
            if (font != null) {
                style.setFont(font);
            }
            if (pattern != null || !"".equals(pattern)) {
                style.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat(pattern));
            }
            cellStylesMapping.put(pattern, style);
            return style;
        }
    } else {
        return preCellStyle;
    }
}
Also used : CellStyle(org.apache.poi.ss.usermodel.CellStyle)

Aggregations

CellStyle (org.apache.poi.ss.usermodel.CellStyle)53 Cell (org.apache.poi.ss.usermodel.Cell)31 Row (org.apache.poi.ss.usermodel.Row)27 Sheet (org.apache.poi.ss.usermodel.Sheet)26 Workbook (org.apache.poi.ss.usermodel.Workbook)25 Test (org.junit.Test)16 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)14 Font (org.apache.poi.ss.usermodel.Font)13 FileOutputStream (java.io.FileOutputStream)8 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)7 CreationHelper (org.apache.poi.ss.usermodel.CreationHelper)7 CellReference (org.apache.poi.ss.util.CellReference)5 Date (java.util.Date)4 DataFormat (org.apache.poi.ss.usermodel.DataFormat)4 IOException (java.io.IOException)3 DecimalFormat (java.text.DecimalFormat)3 HashMap (java.util.HashMap)3 CellType (org.apache.poi.ss.usermodel.CellType)3 File (java.io.File)2 OutputStream (java.io.OutputStream)2