Java Code Examples for org.apache.poi.xssf.usermodel.XSSFCell#CELL_TYPE_STRING
The following examples show how to use
org.apache.poi.xssf.usermodel.XSSFCell#CELL_TYPE_STRING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExcelDataProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( ( int ) cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 2
Source File: ExcelCloudProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 3
Source File: ExcelApplicationProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 4
Source File: ExcelContentProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 5
Source File: ExcelElementProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 6
Source File: ExcelPageDataProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
/** * Gets the cell value. * * @param cell the cell * @return the cell value */ private String getCellValue( XSSFCell cell ) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: { String useValue = String.valueOf( cell.getNumericCellValue() ); if ( useValue.endsWith( ".0" ) ) return useValue.split( "\\." )[0]; else return useValue; } case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 7
Source File: ExcelKeyWordProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
private String getCellValue( XSSFCell cell ) { if (cell != null ) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf( cell.getBooleanCellValue() ); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf( cell.getNumericCellValue() ); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
Example 8
Source File: ExcelUtil.java From springboot-learn with MIT License | 5 votes |
private Object getCellValue(Cell cell) { Object value; DecimalFormat df = new DecimalFormat("0");// 格式化 number String // 字符 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化日期字符串 DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字 switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_STRING: value = cell.getStringCellValue(); break; case XSSFCell.CELL_TYPE_NUMERIC: if ("@".equals(cell.getCellStyle().getDataFormatString())) { value = df.format(cell.getNumericCellValue()); } else if ("General".equals(cell.getCellStyle().getDataFormatString())) { value = nf.format(cell.getNumericCellValue()); } else { value = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue())); } break; case XSSFCell.CELL_TYPE_BOOLEAN: value = cell.getBooleanCellValue(); break; case XSSFCell.CELL_TYPE_BLANK: value = ""; break; default: value = cell.toString(); } return value; }
Example 9
Source File: QbeXLSXExporter.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
protected int getCellTypeString () { return XSSFCell.CELL_TYPE_STRING; }
Example 10
Source File: CrosstabXLSXExporter.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override protected int getCellTypeString () { return XSSFCell.CELL_TYPE_STRING; }
Example 11
Source File: ExcelServiceImpl.java From poi with Apache License 2.0 | 4 votes |
/** * 读取 office 2003 excel */ private List<List<Object>> readExcel2003(File file) throws IOException { List<List<Object>> list = new LinkedList<List<Object>>(); HSSFWorkbook hwb = new HSSFWorkbook(new FileInputStream(file)); HSSFSheet sheet = hwb.getSheetAt(0); Object value = null; HSSFRow row = null; HSSFCell cell = null; int counter = 0; for (int i = sheet.getFirstRowNum(); counter < sheet .getPhysicalNumberOfRows(); i++) { row = sheet.getRow(i); if (row == null) { continue; } else { counter++; } List<Object> linked = new LinkedList<Object>(); for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) { cell = row.getCell(j); if (cell == null) { continue; } DecimalFormat df = new DecimalFormat("0");// 格式化 number String // 字符 SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");// 格式化日期字符串 DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字 switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_STRING: value = cell.getStringCellValue(); System.out.println(i + "行" + j + " 列 is String type" + "\tValue:" + value); break; case XSSFCell.CELL_TYPE_NUMERIC: if ("@".equals(cell.getCellStyle().getDataFormatString())) { value = df.format(cell.getNumericCellValue()); } else if ("General".equals(cell.getCellStyle() .getDataFormatString())) { value = nf.format(cell.getNumericCellValue()); } else { value = sdf.format(HSSFDateUtil.getJavaDate(cell .getNumericCellValue())); } System.out.println(i + "行" + j + " 列 is Number type ; DateFormt:" + cell.getCellStyle().getDataFormatString() + "\tValue:" + value); break; case XSSFCell.CELL_TYPE_BOOLEAN: value = cell.getBooleanCellValue(); System.out.println(i + "行" + j + " 列 is Boolean type" + "\tValue:" + value); break; case XSSFCell.CELL_TYPE_BLANK: value = ""; System.out.println(i + "行" + j + " 列 is Blank type" + "\tValue:" + value); break; default: value = cell.toString(); System.out.println(i + "行" + j + " 列 is default type" + "\tValue:" + value); } if (value == null || "".equals(value)) { continue; } linked.add(value); } list.add(linked); } return list; }
Example 12
Source File: ExcelServiceImpl.java From poi with Apache License 2.0 | 4 votes |
/** * 读取Office 2007 excel */ private List<List<Object>> readExcel2007(File file) throws IOException { List<List<Object>> list = new LinkedList<List<Object>>(); // 构造 XSSFWorkbook 对象,strPath 传入文件路径 XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); // 读取第一章表格内容 XSSFSheet sheet = xwb.getSheetAt(0); Object value = null; XSSFRow row = null; XSSFCell cell = null; int counter = 0; for (int i = sheet.getFirstRowNum(); counter < sheet .getPhysicalNumberOfRows(); i++) { row = sheet.getRow(i); if (row == null) { continue; } else { counter++; } List<Object> linked = new LinkedList<Object>(); for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) { cell = row.getCell(j); if (cell == null) { continue; } DecimalFormat df = new DecimalFormat("0");// 格式化 number String // 字符 SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");// 格式化日期字符串 DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字 switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_STRING: System.out.println(i + "行" + j + " 列 is String type"); value = cell.getStringCellValue(); break; case XSSFCell.CELL_TYPE_NUMERIC: System.out.println(i + "行" + j + " 列 is Number type ; DateFormt:" + cell.getCellStyle().getDataFormatString()); if ("@".equals(cell.getCellStyle().getDataFormatString())) { value = df.format(cell.getNumericCellValue()); } else if ("General".equals(cell.getCellStyle() .getDataFormatString())) { value = nf.format(cell.getNumericCellValue()); } else { value = sdf.format(HSSFDateUtil.getJavaDate(cell .getNumericCellValue())); } break; case XSSFCell.CELL_TYPE_BOOLEAN: System.out.println(i + "行" + j + " 列 is Boolean type"); value = cell.getBooleanCellValue(); break; case XSSFCell.CELL_TYPE_BLANK: System.out.println(i + "行" + j + " 列 is Blank type"); value = ""; break; default: System.out.println(i + "行" + j + " 列 is default type"); value = cell.toString(); } if (value == null || "".equals(value)) { continue; } linked.add(value); } list.add(linked); } return list; }