List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle getDataFormatString
@Override
public String getDataFormatString()
From source file:service.XSSFSheetHandler.java
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if ("inlineStr".equals(name) || "v".equals(name)) { vIsOpen = true;//from w w w . ja v a 2 s. c o m // Clear contents cache value.setLength(0); } // c => cell else if ("c".equals(name)) { // Get the cell reference String r = attributes.getValue("r"); int firstDigit = -1; for (int c = 0; c < r.length(); ++c) { if (Character.isDigit(r.charAt(c))) { firstDigit = c; break; } } thisColumn = nameToColumn(r.substring(0, firstDigit)); // Set up defaults. this.nextDataType = ReadExcelFile.xssfDataType.NUMBER; this.formatIndex = -1; this.formatString = null; String cellType = attributes.getValue("t"); String cellStyleStr = attributes.getValue("s"); if ("b".equals(cellType)) nextDataType = ReadExcelFile.xssfDataType.BOOL; else if ("e".equals(cellType)) nextDataType = ReadExcelFile.xssfDataType.ERROR; else if ("inlineStr".equals(cellType)) nextDataType = ReadExcelFile.xssfDataType.INLINESTR; else if ("s".equals(cellType)) nextDataType = ReadExcelFile.xssfDataType.SSTINDEX; else if ("str".equals(cellType)) nextDataType = ReadExcelFile.xssfDataType.FORMULA; else if (cellStyleStr != null) { // It's a number, but almost certainly one // with a special style or format int styleIndex = Integer.parseInt(cellStyleStr); XSSFCellStyle style = stylesTable.getStyleAt(styleIndex); this.formatIndex = style.getDataFormat(); this.formatString = style.getDataFormatString(); if (this.formatString == null) this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex); } } }