/** * 设置单元格的类型 * * @param attribute */ private void setCellType(Attributes attribute) { // 重置numFmtIndex,numFmtString的值 numFmtIndex = 0; numFmtString = ""; this.cellDataType = CellDataType.of(attribute.getValue(T_ATTR_VALUE)); // 获取单元格的xf索引,对应style.xml中cellXfs的子元素xf final String xfIndexStr = attribute.getValue(S_ATTR_VALUE); if (xfIndexStr != null) { int xfIndex = Integer.parseInt(xfIndexStr); XSSFCellStyle xssfCellStyle = stylesTable.getStyleAt(xfIndex); numFmtIndex = xssfCellStyle.getDataFormat(); numFmtString = xssfCellStyle.getDataFormatString(); if (numFmtString == null) { cellDataType = CellDataType.NULL; numFmtString = BuiltinFormats.getBuiltinFormat(numFmtIndex); } else if (org.apache.poi.ss.usermodel.DateUtil.isADateFormat(numFmtIndex, numFmtString)) { cellDataType = CellDataType.DATE; } } }
/** * 设置单元格的类型 * * @param attribute */ private void setCellType(Attributes attribute) { // 重置numFmtIndex,numFmtString的值 numFmtIndex = 0; numFmtString = ""; this.cellDataType = CellDataType.of(attribute.getValue(T_ATTR_VALUE)); // 获取单元格的xf索引,对应style.xml中cellXfs的子元素xf final String xfIndexStr = attribute.getValue(S_ATTR_VALUE); if (xfIndexStr != null) { int xfIndex = Integer.parseInt(xfIndexStr); XSSFCellStyle xssfCellStyle = stylesTable.getStyleAt(xfIndex); numFmtIndex = xssfCellStyle.getDataFormat(); numFmtString = xssfCellStyle.getDataFormatString(); if (numFmtString == null) { cellDataType = CellDataType.NULL; numFmtString = BuiltinFormats.getBuiltinFormat(numFmtIndex); } else if (org.apache.poi.ss.usermodel.DateUtil.isADateFormat(numFmtIndex, numFmtString)) { cellDataType = CellDataType.DATE; } } }
this.formatString = style.getDataFormatString(); if (this.formatString == null) this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
String fmt = src.getDataFormatString(); setDataFormat( (new XSSFDataFormat(_stylesSource)).getFormat(fmt)
private void setNextCellType(String cellType, String cellStyleStr) { mNextCellType = ExcelCellType.STRING; mFormatIndex = -1; mFormatString = null; if ("b".equals(cellType)) { mNextCellType = ExcelCellType.BOOL; } else if ("e".equals(cellType)) { mNextCellType = ExcelCellType.ERROR; } else if ("inlineStr".equals(cellType)) { mNextCellType = ExcelCellType.INLINESTR; } else if ("s".equals(cellType)) { mNextCellType = ExcelCellType.STRING; } else if ("str".equals(cellType)) { mNextCellType = ExcelCellType.FORMULA; } if (null != cellStyleStr) { int styleIndex = Integer.parseInt(cellStyleStr); XSSFCellStyle style = mStylesTable.getStyleAt(styleIndex); mFormatIndex = style.getDataFormat(); mFormatString = style.getDataFormatString(); if (null == mFormatString) { mNextCellType = mNextCellType.NULL; mFormatString = BuiltinFormats.getBuiltinFormat(mFormatIndex); } } }
XSSFCellStyle style = stylesTable.getStyleAt(styleIndex); this.formatIndex = style.getDataFormat(); this.formatString = style.getDataFormatString(); if (this.formatString == null) this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
this._formatString = style.getDataFormatString(); if (this._formatString == null) { this._formatString = BuiltinFormats.getBuiltinFormat(this._formatIndex);
this._formatString = style.getDataFormatString(); if (this._formatString == null) { this._formatString = BuiltinFormats.getBuiltinFormat(this._formatIndex);
this._formatString = style.getDataFormatString(); if (this._formatString == null) { this._formatString = BuiltinFormats
/** * 设置单元格的类型 * * @param attribute */ private void setCellType(Attributes attribute) { // 重置numFmtIndex,numFmtString的值 numFmtIndex = 0; numFmtString = ""; this.cellDataType = CellDataType.of(attribute.getValue(T_ATTR_VALUE)); // 获取单元格的xf索引,对应style.xml中cellXfs的子元素xf final String xfIndexStr = attribute.getValue(S_ATTR_VALUE); if (xfIndexStr != null) { int xfIndex = Integer.parseInt(xfIndexStr); XSSFCellStyle xssfCellStyle = stylesTable.getStyleAt(xfIndex); numFmtIndex = xssfCellStyle.getDataFormat(); numFmtString = xssfCellStyle.getDataFormatString(); if (numFmtString == null) { cellDataType = CellDataType.NULL; numFmtString = BuiltinFormats.getBuiltinFormat(numFmtIndex); } else if (org.apache.poi.ss.usermodel.DateUtil.isADateFormat(numFmtIndex, numFmtString)) { cellDataType = CellDataType.DATE; } } }
this.formatString = style.getDataFormatString(); if (this.formatString == null) this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
cellFormattedValue = this.dataFormatter.formatRawCellContents( Double.valueOf(cellFormattedValue), cellStyle.getDataFormat(), cellStyle.getDataFormatString(), this.isDate1904);
/** * Read the numeric format string out of the styles table for this cell. Stores * the result in the Cell. * * @param startElement * @param cell */ void setFormatString(StartElement startElement, StreamingCell cell) { Attribute cellStyle = startElement.getAttributeByName(new QName("s")); String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null; XSSFCellStyle style = null; if(cellStyleString != null) { style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString)); } else if(stylesTable.getNumCellStyles() > 0) { style = stylesTable.getStyleAt(0); } if(style != null) { cell.setNumericFormatIndex(style.getDataFormat()); String formatString = style.getDataFormatString(); if(formatString != null) { cell.setNumericFormat(formatString); } else { cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex())); } } else { cell.setNumericFormatIndex(null); cell.setNumericFormat(null); } }
XSSFCellStyle cellStyle = cell.getCellStyle(); if (cellStyle!=null) { String format=cellStyle.getDataFormatString(); if ("0".equals(format)) { Double d=(Double) cellValue;
/** * Read the numeric format string out of the styles table for this cell. Stores the result in the Cell. * * @param startElement * @param cell */ void setFormatString(StartElement startElement, StreamingCell cell) { Attribute cellStyle = startElement.getAttributeByName(new QName("s")); String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null; XSSFCellStyle style = null; if (cellStyleString != null) { style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString)); } else if (stylesTable.getNumCellStyles() > 0) { style = stylesTable.getStyleAt(0); } if (style != null) { cell.setNumericFormatIndex(style.getDataFormat()); String formatString = style.getDataFormatString(); if (formatString != null) { cell.setNumericFormat(formatString); } else { cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex())); } } else { cell.setNumericFormatIndex(null); cell.setNumericFormat(null); } }
/** * Read the numeric format string out of the styles table for this cell. Stores the result in the Cell. * * @param startElement * @param cell */ void setFormatString(StartElement startElement, StreamingCell cell) { Attribute cellStyle = startElement.getAttributeByName(new QName("s")); String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null; XSSFCellStyle style = null; if (cellStyleString != null) { style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString)); } else if (stylesTable.getNumCellStyles() > 0) { style = stylesTable.getStyleAt(0); } if (style != null) { cell.setNumericFormatIndex(style.getDataFormat()); String formatString = style.getDataFormatString(); if (formatString != null) { cell.setNumericFormat(formatString); } else { cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex())); } } else { cell.setNumericFormatIndex(null); cell.setNumericFormat(null); } }
String fmt = src.getDataFormatString(); setDataFormat( (new XSSFDataFormat(_stylesSource)).getFormat(fmt)
String fmt = src.getDataFormatString(); setDataFormat( (new XSSFDataFormat(_stylesSource)).getFormat(fmt)