List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle getDataFormat
@Override public short getDataFormat()
From source file:com.eryansky.core.excelTools.ExcelUtils.java
License:Apache License
public static String dumpCellStyle(HSSFCellStyle style) { StringBuffer sb = new StringBuffer(); sb.append(style.getHidden()).append(","); sb.append(style.getLocked()).append(","); sb.append(style.getWrapText()).append(","); sb.append(style.getAlignment()).append(","); sb.append(style.getBorderBottom()).append(","); sb.append(style.getBorderLeft()).append(","); sb.append(style.getBorderRight()).append(","); sb.append(style.getBorderTop()).append(","); sb.append(style.getBottomBorderColor()).append(","); sb.append(style.getDataFormat()).append(","); sb.append(style.getFillBackgroundColor()).append(","); sb.append(style.getFillForegroundColor()).append(","); sb.append(style.getFillPattern()).append(","); sb.append(style.getIndention()).append(","); sb.append(style.getLeftBorderColor()).append(","); sb.append(style.getRightBorderColor()).append(","); sb.append(style.getRotation()).append(","); sb.append(style.getTopBorderColor()).append(","); sb.append(style.getVerticalAlignment()); return sb.toString(); }
From source file:com.eryansky.core.excelTools.ExcelUtils.java
License:Apache License
public static HSSFCellStyle findStyle(HSSFCellStyle style, HSSFWorkbook srcwb, HSSFWorkbook destwb) { HSSFPalette srcpalette = srcwb.getCustomPalette(); HSSFPalette destpalette = destwb.getCustomPalette(); for (short i = 0; i < destwb.getNumCellStyles(); i++) { HSSFCellStyle old = destwb.getCellStyleAt(i); if (old == null) continue; if (style.getAlignment() == old.getAlignment() && style.getBorderBottom() == old.getBorderBottom() && style.getBorderLeft() == old.getBorderLeft() && style.getBorderRight() == old.getBorderRight() && style.getBorderTop() == old.getBorderTop() && isSameColor(style.getBottomBorderColor(), old.getBottomBorderColor(), srcpalette, destpalette)//from w w w.j av a 2 s . com && style.getDataFormat() == old.getDataFormat() && isSameColor(style.getFillBackgroundColor(), old.getFillBackgroundColor(), srcpalette, destpalette) && isSameColor(style.getFillForegroundColor(), old.getFillForegroundColor(), srcpalette, destpalette) && style.getFillPattern() == old.getFillPattern() && style.getHidden() == old.getHidden() && style.getIndention() == old.getIndention() && isSameColor(style.getLeftBorderColor(), old.getLeftBorderColor(), srcpalette, destpalette) && style.getLocked() == old.getLocked() && isSameColor(style.getRightBorderColor(), old.getRightBorderColor(), srcpalette, destpalette) && style.getRotation() == old.getRotation() && isSameColor(style.getTopBorderColor(), old.getTopBorderColor(), srcpalette, destpalette) && style.getVerticalAlignment() == old.getVerticalAlignment() && style.getWrapText() == old.getWrapText()) { HSSFFont oldfont = destwb.getFontAt(old.getFontIndex()); HSSFFont font = srcwb.getFontAt(style.getFontIndex()); if (oldfont.getBoldweight() == font.getBoldweight() && oldfont.getItalic() == font.getItalic() && oldfont.getStrikeout() == font.getStrikeout() && oldfont.getCharSet() == font.getCharSet() && isSameColor(oldfont.getColor(), font.getColor(), srcpalette, destpalette) && oldfont.getFontHeight() == font.getFontHeight() && oldfont.getFontName().equals(font.getFontName()) && oldfont.getTypeOffset() == font.getTypeOffset() && oldfont.getUnderline() == font.getUnderline()) { return old; } } } return null; }
From source file:com.eryansky.core.excelTools.ExcelUtils.java
License:Apache License
public static void copyCellStyle(HSSFWorkbook destwb, HSSFCellStyle dest, HSSFWorkbook srcwb, HSSFCellStyle src) { if (src == null || dest == null) return;//w w w . java 2 s . c o m dest.setAlignment(src.getAlignment()); dest.setBorderBottom(src.getBorderBottom()); dest.setBorderLeft(src.getBorderLeft()); dest.setBorderRight(src.getBorderRight()); dest.setBorderTop(src.getBorderTop()); dest.setBottomBorderColor(findColor(src.getBottomBorderColor(), srcwb, destwb)); dest.setDataFormat( destwb.createDataFormat().getFormat(srcwb.createDataFormat().getFormat(src.getDataFormat()))); dest.setFillPattern(src.getFillPattern()); dest.setFillForegroundColor(findColor(src.getFillForegroundColor(), srcwb, destwb)); dest.setFillBackgroundColor(findColor(src.getFillBackgroundColor(), srcwb, destwb)); dest.setHidden(src.getHidden()); dest.setIndention(src.getIndention()); dest.setLeftBorderColor(findColor(src.getLeftBorderColor(), srcwb, destwb)); dest.setLocked(src.getLocked()); dest.setRightBorderColor(findColor(src.getRightBorderColor(), srcwb, destwb)); dest.setRotation(src.getRotation()); dest.setTopBorderColor(findColor(src.getTopBorderColor(), srcwb, destwb)); dest.setVerticalAlignment(src.getVerticalAlignment()); dest.setWrapText(src.getWrapText()); HSSFFont f = srcwb.getFontAt(src.getFontIndex()); HSSFFont nf = findFont(f, srcwb, destwb); if (nf == null) { nf = destwb.createFont(); nf.setBoldweight(f.getBoldweight()); nf.setCharSet(f.getCharSet()); nf.setColor(findColor(f.getColor(), srcwb, destwb)); nf.setFontHeight(f.getFontHeight()); nf.setFontHeightInPoints(f.getFontHeightInPoints()); nf.setFontName(f.getFontName()); nf.setItalic(f.getItalic()); nf.setStrikeout(f.getStrikeout()); nf.setTypeOffset(f.getTypeOffset()); nf.setUnderline(f.getUnderline()); } dest.setFont(nf); }
From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java
/** * This is a helper method to retrieve the value of a cell regardles of its * type, which will be converted into a String. * // ww w . java 2s. co m * @param cell * @return */ private Object getCellValue(HSSFCell cell) { if (cell == null) { return null; } Object result = null; int cellType = cell.getCellType(); switch (cellType) { case HSSFCell.CELL_TYPE_BLANK: result = ""; break; case HSSFCell.CELL_TYPE_BOOLEAN: result = cell.getBooleanCellValue() ? Boolean.TRUE : Boolean.FALSE; break; case HSSFCell.CELL_TYPE_ERROR: result = "ERROR: " + cell.getErrorCellValue(); break; case HSSFCell.CELL_TYPE_FORMULA: result = cell.getCellFormula(); break; case HSSFCell.CELL_TYPE_NUMERIC: HSSFCellStyle cellStyle = cell.getCellStyle(); short dataFormat = cellStyle.getDataFormat(); // assumption is made that dataFormat = 14, // when cellType is HSSFCell.CELL_TYPE_NUMERIC // is equal to a DATE format. if (dataFormat == 164) { result = cell.getDateCellValue(); } else { result = cell.getNumericCellValue(); } break; case HSSFCell.CELL_TYPE_STRING: result = cell.getStringCellValue(); break; default: break; } if (result instanceof Double) { return String.valueOf(((Double) result).longValue()); } if (result instanceof Date) { return result; } return result.toString(); }
From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java
private Object getCellValue(HSSFCell cell, boolean resolveFormula) { if (cell == null) { return null; }/* w ww .ja v a 2 s . c om*/ Object result = null; int cellType = cell.getCellType(); switch (cellType) { case HSSFCell.CELL_TYPE_BLANK: result = ""; break; case HSSFCell.CELL_TYPE_BOOLEAN: result = cell.getBooleanCellValue() ? Boolean.TRUE : Boolean.FALSE; break; case HSSFCell.CELL_TYPE_ERROR: result = "ERROR: " + cell.getErrorCellValue(); break; case HSSFCell.CELL_TYPE_FORMULA: switch (cell.getCachedFormulaResultType()) { case HSSFCell.CELL_TYPE_NUMERIC: /*System.out.println("Last evaluated as: " + cell.getNumericCellValue()); result = cell.getNumericCellValue(); break;*/ if (DateUtil.isCellDateFormatted(cell)) { result = cell.getDateCellValue(); } else { result = cell.getNumericCellValue(); } System.out.println("Numeric cell value == " + result); break; case HSSFCell.CELL_TYPE_STRING: System.out.println("Last evaluated as \"" + cell.getRichStringCellValue() + "\""); result = cell.getRichStringCellValue(); break; } //result = cell.getCellFormula(); break; case HSSFCell.CELL_TYPE_NUMERIC: HSSFCellStyle cellStyle = cell.getCellStyle(); short dataFormat = cellStyle.getDataFormat(); System.out.println("Data format for " + cell.getColumnIndex() + " = " + dataFormat); // assumption is made that dataFormat = 14, // when cellType is HSSFCell.CELL_TYPE_NUMERIC // is equal to a DATE format. //if (dataFormat == 165 || dataFormat == 164 || dataFormat == 14) { if (DateUtil.isCellDateFormatted(cell)) { result = cell.getDateCellValue(); } else { result = cell.getNumericCellValue(); } if (dataFormat == 0) { // alternative way of getting value : can this be replaced for the entire block result = new HSSFDataFormatter().formatCellValue(cell); } System.out.println("Numeric cell value == " + result); break; case HSSFCell.CELL_TYPE_STRING: //result = cell.getStringCellValue(); result = cell.getRichStringCellValue(); System.out.println("String -> " + result); break; default: break; } if (result instanceof Integer) { return String.valueOf((Integer) result); } else if (result instanceof Double) { return String.valueOf(((Double) result)); //.longValue()); } if (result instanceof Date) { return result; } return result.toString(); }
From source file:com.report.excel.ExcelToHtmlConverter.java
License:Apache License
protected boolean processCell(HSSFCell cell, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt) { final HSSFCellStyle cellStyle = cell.getCellStyle(); String value;/*from w w w . ja v a 2 s .c om*/ switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_STRING: // XXX: enrich value = cell.getRichStringCellValue().getString(); break; case HSSFCell.CELL_TYPE_FORMULA: /*switch (evaluator.evaluateFormulaCell(cell)) { case Cell.CELL_TYPE_BOOLEAN: value = cell.getBooleanCellValue(); break; case Cell.CELL_TYPE_NUMERIC: value = cell.getNumericCellValue(); break; case Cell.CELL_TYPE_STRING: System.out.println(cell.getStringCellValue()); break; case Cell.CELL_TYPE_BLANK: break; case Cell.CELL_TYPE_ERROR: System.out.println(cell.getErrorCellValue()); break; case Cell.CELL_TYPE_FORMULA: break; }*/ switch (cell.getCachedFormulaResultType()) { case HSSFCell.CELL_TYPE_STRING: HSSFRichTextString str = cell.getRichStringCellValue(); if (str != null && str.length() > 0) { value = (str.toString()); } else { value = ExcelToHtmlUtils.EMPTY; } break; case HSSFCell.CELL_TYPE_NUMERIC: HSSFCellStyle style = cellStyle; if (style == null) { value = String.valueOf(cell.getNumericCellValue()); } else { value = (_formatter.formatRawCellContents(cell.getNumericCellValue(), style.getDataFormat(), style.getDataFormatString())); } break; case HSSFCell.CELL_TYPE_BOOLEAN: value = String.valueOf(cell.getBooleanCellValue()); break; case HSSFCell.CELL_TYPE_ERROR: value = ErrorEval.getText(cell.getErrorCellValue()); break; default: logger.log(POILogger.WARN, "Unexpected cell cachedFormulaResultType (" + cell.getCachedFormulaResultType() + ")"); value = ExcelToHtmlUtils.EMPTY; break; } break; case HSSFCell.CELL_TYPE_BLANK: value = ExcelToHtmlUtils.EMPTY; break; case HSSFCell.CELL_TYPE_NUMERIC: value = _formatter.formatCellValue(cell); break; case HSSFCell.CELL_TYPE_BOOLEAN: value = String.valueOf(cell.getBooleanCellValue()); break; case HSSFCell.CELL_TYPE_ERROR: value = ErrorEval.getText(cell.getErrorCellValue()); break; default: logger.log(POILogger.WARN, "Unexpected cell type (" + cell.getCellType() + ")"); return true; } final boolean noText = ExcelToHtmlUtils.isEmpty(value); final boolean wrapInDivs = !noText && isUseDivsToSpan() && !cellStyle.getWrapText(); final short cellStyleIndex = cellStyle.getIndex(); if (cellStyleIndex != 0) { HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook(); String mainCssClass = getStyleClassName(workbook, cellStyle); if (wrapInDivs) { tableCellElement.setAttribute("class", mainCssClass + " " + cssClassContainerCell); } else { tableCellElement.setAttribute("class", mainCssClass); } if (noText) { /* * if cell style is defined (like borders, etc.) but cell text * is empty, add " " to output, so browser won't collapse * and ignore cell */ value = "\u00A0"; } } if (isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) { StringBuilder builder = new StringBuilder(); for (int c = 0; c < value.length(); c++) { if (value.charAt(c) != ' ') break; builder.append('\u00a0'); } if (value.length() != builder.length()) builder.append(value.substring(builder.length())); value = builder.toString(); } Text text = htmlDocumentFacade.createText(value); if (wrapInDivs) { Element outerDiv = htmlDocumentFacade.createBlock(); outerDiv.setAttribute("class", this.cssClassContainerDiv); Element innerDiv = htmlDocumentFacade.createBlock(); StringBuilder innerDivStyle = new StringBuilder(); innerDivStyle.append("position:absolute;min-width:"); innerDivStyle.append(normalWidthPx); innerDivStyle.append("px;"); if (maxSpannedWidthPx != Integer.MAX_VALUE) { innerDivStyle.append("max-width:"); innerDivStyle.append(maxSpannedWidthPx); innerDivStyle.append("px;"); } innerDivStyle.append("overflow:hidden;max-height:"); innerDivStyle.append(normalHeightPt); innerDivStyle.append("pt;white-space:nowrap;"); ExcelToHtmlUtils.appendAlign(innerDivStyle, cellStyle.getAlignment()); htmlDocumentFacade.addStyleClass(outerDiv, cssClassPrefixDiv, innerDivStyle.toString()); innerDiv.appendChild(text); outerDiv.appendChild(innerDiv); tableCellElement.appendChild(outerDiv); } else { tableCellElement.appendChild(text); } return ExcelToHtmlUtils.isEmpty(value) && cellStyleIndex == 0; }
From source file:com.wangzhu.poi.ExcelToHtmlConverter.java
License:Apache License
protected boolean processCell(HSSFCell cell, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt) { final HSSFCellStyle cellStyle = cell.getCellStyle(); String value;/*from www. j a v a 2s.c o m*/ switch (cell.getCellType()) { case Cell.CELL_TYPE_STRING: // XXX: enrich value = cell.getRichStringCellValue().getString(); break; case Cell.CELL_TYPE_FORMULA: switch (cell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_STRING: HSSFRichTextString str = cell.getRichStringCellValue(); if ((str != null) && (str.length() > 0)) { value = (str.toString()); } else { value = ExcelToHtmlUtils.EMPTY; } break; case Cell.CELL_TYPE_NUMERIC: HSSFCellStyle style = cellStyle; if (style == null) { value = String.valueOf(cell.getNumericCellValue()); } else { value = (this._formatter.formatRawCellContents(cell.getNumericCellValue(), style.getDataFormat(), style.getDataFormatString())); } break; case Cell.CELL_TYPE_BOOLEAN: value = String.valueOf(cell.getBooleanCellValue()); break; case Cell.CELL_TYPE_ERROR: value = ErrorEval.getText(cell.getErrorCellValue()); break; default: ExcelToHtmlConverter.logger.log(POILogger.WARN, "Unexpected cell cachedFormulaResultType (" + cell.getCachedFormulaResultType() + ")"); value = ExcelToHtmlUtils.EMPTY; break; } break; case Cell.CELL_TYPE_BLANK: value = ExcelToHtmlUtils.EMPTY; break; case Cell.CELL_TYPE_NUMERIC: value = this._formatter.formatCellValue(cell); break; case Cell.CELL_TYPE_BOOLEAN: value = String.valueOf(cell.getBooleanCellValue()); break; case Cell.CELL_TYPE_ERROR: value = ErrorEval.getText(cell.getErrorCellValue()); break; default: ExcelToHtmlConverter.logger.log(POILogger.WARN, "Unexpected cell type (" + cell.getCellType() + ")"); return true; } final boolean noText = ExcelToHtmlUtils.isEmpty(value); final boolean wrapInDivs = !noText && this.isUseDivsToSpan() && !cellStyle.getWrapText(); final short cellStyleIndex = cellStyle.getIndex(); if (cellStyleIndex != 0) { HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook(); String mainCssClass = this.getStyleClassName(workbook, cellStyle); if (wrapInDivs) { tableCellElement.setAttribute("class", mainCssClass + " " + this.cssClassContainerCell); } else { tableCellElement.setAttribute("class", mainCssClass); } if (noText) { /* * if cell style is defined (like borders, etc.) but cell text * is empty, add " " to output, so browser won't collapse * and ignore cell */ value = "\u00A0"; } } if (this.isOutputLeadingSpacesAsNonBreaking() && value.startsWith(" ")) { StringBuffer builder = new StringBuffer(); for (int c = 0; c < value.length(); c++) { if (value.charAt(c) != ' ') { break; } builder.append('\u00a0'); } if (value.length() != builder.length()) { builder.append(value.substring(builder.length())); } value = builder.toString(); } Text text = this.htmlDocumentFacade.createText(value); if (wrapInDivs) { Element outerDiv = this.htmlDocumentFacade.createBlock(); outerDiv.setAttribute("class", this.cssClassContainerDiv); Element innerDiv = this.htmlDocumentFacade.createBlock(); StringBuffer innerDivStyle = new StringBuffer(); innerDivStyle.append("position:absolute;min-width:"); innerDivStyle.append(normalWidthPx); innerDivStyle.append("px;"); if (maxSpannedWidthPx != Integer.MAX_VALUE) { innerDivStyle.append("max-width:"); innerDivStyle.append(maxSpannedWidthPx); innerDivStyle.append("px;"); } innerDivStyle.append("overflow:hidden;max-height:"); innerDivStyle.append(normalHeightPt); innerDivStyle.append("pt;white-space:nowrap;"); ExcelToHtmlUtils.appendAlign(innerDivStyle, cellStyle.getAlignment()); this.htmlDocumentFacade.addStyleClass(outerDiv, this.cssClassPrefixDiv, innerDivStyle.toString()); innerDiv.appendChild(text); outerDiv.appendChild(innerDiv); tableCellElement.appendChild(outerDiv); } else { tableCellElement.appendChild(text); } return ExcelToHtmlUtils.isEmpty(value) && (cellStyleIndex == 0); }
From source file:com.xpn.xwiki.plugin.lucene.textextraction.MSExcelTextExtractor.java
License:Open Source License
/** * Extracts all text from each cell of the sheet *//* w w w . j a va 2 s.c om*/ private void parseCell(HSSFCell cell, StringBuffer cleanBuffer) { String cellValue = null; if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) { cellValue = cell.getRichStringCellValue().getString(); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { HSSFCellStyle style = cell.getCellStyle(); short formatId = style.getDataFormat(); String formatPattern = mDataFormat.getFormat(formatId); formatPattern = replace(formatPattern, "\\ ", " "); if (isCellDateFormatted(cell)) { // This is a date formatPattern = replace(formatPattern, "mmmm", "MMMM"); formatPattern = replace(formatPattern, "/", "."); SimpleDateFormat format; try { format = new SimpleDateFormat(formatPattern); } catch (Throwable thr) { if (LOG.isDebugEnabled()) { LOG.debug("Creating date format failed: '" + formatPattern + "'", thr); } format = new SimpleDateFormat(); } double numberValue = cell.getNumericCellValue(); Date date = HSSFDateUtil.getJavaDate(numberValue); cellValue = format.format(date); } else { // This is a Number DecimalFormat format; try { format = new DecimalFormat(formatPattern); } catch (Throwable thr) { if (LOG.isDebugEnabled()) { LOG.debug("Creating number format failed: '" + formatPattern + "'", thr); } format = new DecimalFormat(); } double numberValue = cell.getNumericCellValue(); cellValue = format.format(numberValue); } } if (cellValue != null) { cellValue = cellValue.trim(); if (cellValue.length() != 0) { cleanBuffer.append(cellValue); cleanBuffer.append(" "); } } }
From source file:include.excel_import.Outter.java
License:Open Source License
private String getCellType(HSSFCell hssfcell) { HSSFDataFormat hssfdataformat = wb.createDataFormat(); HSSFCellStyle hssfcellstyle = hssfcell.getCellStyle(); short word0 = hssfcellstyle.getDataFormat(); String s = hssfdataformat.getFormat(word0); String s1 = ""; switch (hssfcell.getCellType()) { case 0: // '\0' if (s.indexOf("0_") == 0 || s.indexOf("0;") == 0 || s.indexOf("#,##0_") == 0 || s.indexOf("#,##0;") == 0 || s.equals("0")) { s1 = "INT"; break; }//from w ww .ja v a 2 s .c om if (s.equals("yyyy\\-mm\\-dd") || s.equals("yyyy-mm-dd") || s.equals("yyyy/mm/dd") || s.equals("m/d/yy") || s.equals("0x1f")) { s1 = "DATE"; break; } if (s.indexOf("#,##0.") == 0 || s.indexOf("0.0") == 0) { s1 = "DOUBLE"; break; } if (s.equals("General")) s1 = "INT1"; else s1 = "NUMBERIC"; break; case 1: // '\001' if (s.equals("General")) { s1 = "STRING"; break; } if (s.equals("@")) { s1 = "STRING"; break; } if (s.indexOf("0_") == 0 || s.indexOf("0;") == 0 || s.indexOf("#,##0_") == 0 || s.indexOf("#,##0;") == 0 || s.equals("0")) { s1 = "INT"; break; } if (s.indexOf("#,##0.") == 0 || s.indexOf("0.0") == 0) s1 = "DOUBLE"; else System.out.println(s); break; case 3: // '\003' s1 = "BLANK"; break; case 2: // '\002' s1 = "FORMULA"; break; case 5: // '\005' s1 = "ERROR"; break; case 4: // '\004' default: s1 = "UNKNOWN"; break; } return s1; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
private String getCellDataType(HSSFCell cell) { String type = ""; HSSFCellStyle cellstyle = cell.getCellStyle(); short datatype = cellstyle.getDataFormat(); //STYLE?/*from w w w. j a v a 2 s. co m*/ if (df == null) System.err.println("df==null"); String dataFormatStr = df.getFormat(datatype); //System.out.println("DATATYPE="+dataFormatStr); //System.out.println("CellType+"+cell.getCellType()); switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: if (dataFormatStr.indexOf("0_") == 0 || dataFormatStr.indexOf("0;") == 0 || dataFormatStr.indexOf("#,##0_") == 0 || dataFormatStr.indexOf("#,##0;") == 0 || dataFormatStr.equals("0")) { type = "INT"; } else if (dataFormatStr.equals("yyyy\\-mm\\-dd") || dataFormatStr.equals("yyyy-mm-dd") || dataFormatStr.equals("yyyy/mm/dd") || dataFormatStr.equals("m/d/yy") || dataFormatStr.equals("0x1f")) {//?2004915 type = "DATE"; } else if (dataFormatStr.indexOf("#,##0.") == 0 || dataFormatStr.indexOf("0.0") == 0) { type = "DOUBLE"; } else if (dataFormatStr.equals("General")) { //INT??????? type = "INT1"; } else { type = "NUMBERIC"; } // end of else break; case HSSFCell.CELL_TYPE_STRING: if (dataFormatStr.equals("General")) { type = "STRING"; } else if (dataFormatStr.equals("@")) { type = "STRING"; } else if (dataFormatStr.indexOf("0_") == 0 || //HSSf??? dataFormatStr.indexOf("0;") == 0 || dataFormatStr.indexOf("#,##0_") == 0 || dataFormatStr.indexOf("#,##0;") == 0 || dataFormatStr.equals("0")) { type = "INT"; } else if (dataFormatStr.indexOf("#,##0.") == 0 || dataFormatStr.indexOf("0.0") == 0) { type = "DOUBLE"; } else { System.out.println(dataFormatStr); } // end of else break; case HSSFCell.CELL_TYPE_BLANK: type = "BLANK"; break; case HSSFCell.CELL_TYPE_FORMULA: type = "FORMULA"; break; case HSSFCell.CELL_TYPE_ERROR: type = "ERROR"; break; default: type = "UNKNOWN"; break; } cellstyle = null; dataFormatStr = null; //System.gc(); return type; }