/** * Get the cell style object at the given index * * @param idx index within the set of styles * @return XSSFCellStyle object at the index */ @Override public XSSFCellStyle getCellStyleAt(int idx) { return stylesSource.getStyleAt(idx); }
/** * 设置单元格的类型 * * @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; } } }
/** * Return the cell's style. * * @return the cell's style. */ @Override public XSSFCellStyle getCellStyle() { XSSFCellStyle style = null; if(_stylesSource.getNumCellStyles() > 0){ long idx = _cell.isSetS() ? _cell.getS() : 0; style = _stylesSource.getStyleAt((int)idx); } return style; }
/** * 设置单元格的类型 * * @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; } } }
/** * Returns the whole-row cell style. Most rows won't * have one of these, so will return null. Call * {@link #isFormatted()} to check first. */ @Override public XSSFCellStyle getRowStyle() { if(!isFormatted()) { return null; } StylesTable stylesSource = getSheet().getWorkbook().getStylesSource(); if(stylesSource.getNumCellStyles() > 0) { return stylesSource.getStyleAt((int)_row.getS()); } else { return null; } }
/** * gGet the cell style object at the given index * * @param idx index within the set of styles * @return XSSFCellStyle object at the index */ public XSSFCellStyle getCellStyleAt(short idx) { return stylesSource.getStyleAt(idx); }
/** * Get the cell style object at the given index * * @param idx index within the set of styles * @return XSSFCellStyle object at the index */ @Override public XSSFCellStyle getCellStyleAt(int idx) { return stylesSource.getStyleAt(idx); }
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); } } }
@Override public ICellStyle getStyle(int row, int column) { int index = cellIndexes[row - region.getTop()][column - region.getLeft()]; // For XSSF workbook isn't needed return new XlsCellStyle(stylesTable.getStyleAt(index), null); }
/** * Return the cell's style. * * @return the cell's style.</code> */ public XSSFCellStyle getCellStyle() { XSSFCellStyle style = null; if(_stylesSource.getNumCellStyles() > 0){ long idx = _cell.isSetS() ? _cell.getS() : 0; style = _stylesSource.getStyleAt((int)idx); } return style; }
/** * Return the cell's style. * * @return the cell's style. */ @Override public XSSFCellStyle getCellStyle() { XSSFCellStyle style = null; if(_stylesSource.getNumCellStyles() > 0){ long idx = _cell.isSetS() ? _cell.getS() : 0; style = _stylesSource.getStyleAt((int)idx); } return style; }
/** * 设置单元格的类型 * * @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; } } }
@Override public ICellFont getFont(int row, int column) { int index = cellIndexes[row - region.getTop()][column - region.getLeft()]; // For XSSF workbook isn't needed return new XlsCellFont(stylesTable.getStyleAt(index).getFont(), 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); } }
/** * 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); } }
/** * Returns the whole-row cell style. Most rows won't * have one of these, so will return null. Call * {@link #isFormatted()} to check first. */ public XSSFCellStyle getRowStyle() { if(!isFormatted()) return null; StylesTable stylesSource = getSheet().getWorkbook().getStylesSource(); if(stylesSource.getNumCellStyles() > 0) { return stylesSource.getStyleAt((int)_row.getS()); } else { return null; } }
/** * Returns the whole-row cell style. Most rows won't * have one of these, so will return null. Call * {@link #isFormatted()} to check first. */ @Override public XSSFCellStyle getRowStyle() { if(!isFormatted()) { return null; } StylesTable stylesSource = getSheet().getWorkbook().getStylesSource(); if(stylesSource.getNumCellStyles() > 0) { return stylesSource.getStyleAt((int)_row.getS()); } else { return null; } }
private static XSSFColor getThemeOrStyleColor(XSSFCell cell) { long style = cell.getCTCell().getS(); StylesTable stylesSource = cell.getSheet().getWorkbook().getStylesSource(); int fillId = (int) stylesSource.getStyleAt((int) style).getStyleXf().getFillId(); return stylesSource.getFillAt(fillId).getFillForegroundColor(); } }
final XSSFFont stdFont = _stylesTable.getStyleAt(0).getFont(); final short fontHeight = style.getFont().getFontHeightInPoints(); if (stdFont.getFontHeightInPoints() != fontHeight) {