Example usage for org.apache.poi.xssf.model StylesTable getStyleAt

List of usage examples for org.apache.poi.xssf.model StylesTable getStyleAt

Introduction

In this page you can find the example usage for org.apache.poi.xssf.model StylesTable getStyleAt.

Prototype

@Override
public XSSFCellStyle getStyleAt(int idx) 

Source Link

Usage

From source file:org.addition.epanet.network.io.input.ExcelParser.java

License:Open Source License

private void findTimeStyle(XSSFWorkbook workbook) {
    final List<Short> validTimeFormats = Arrays.asList(new Short[] { 0x12, // "h:mm AM/PM"
            0x13, // "h:mm:ss AM/PM"
            0x14, // "h:mm"
            0x15, // "h:mm:ss"
            0x16, // "m/d/yy h:mm"
            0x2d, // "mm:ss"
            0x2e, // "[h]:mm:ss"
            0x2f, // "mm:ss.0"
    });//  www.  j  av a  2 s.  c om

    StylesTable styleTable = workbook.getStylesSource();
    int stylesCount = styleTable.getNumCellStyles();
    for (int i = 0; i < stylesCount; i++) {
        XSSFCellStyle style = styleTable.getStyleAt(i);

        //if(org.apache.poi.ss.usermodel.DateUtil.isInternalDateFormat(style.getDataFormat()))
        if (validTimeFormats.contains(style.getDataFormat()))
            timeStyles.add(style);
        else if (style.getDataFormatString().toLowerCase().contains("[h]:mm")
                || style.getDataFormatString().toLowerCase().contains("[hh]:mm"))
            timeStyles.add(style);
    }
}