java cellvalue_Java Cell.getErrorCellValue方法代码示例
import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
* 获取单元格值
*
* @param row 获取的行
* @param column 获取单元格列号
* @return 单元格值
*/
public Object getCellValue(Row row, int column) {
Object val = "";
try {
Cell cell = row.getCell(column);
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
// val = cell.getNumericCellValue();
// 当excel 中的数据为数值或日期是需要特殊处理
if (HSSFDateUtil.isCellDateFormatted(cell)) {
double d = cell.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(d);
SimpleDateFormat dformat = new SimpleDateFormat(
"yyyy-MM-dd");
val = dformat.format(date);
} else {
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);// true时的格式:1,234,567,890
val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
val = cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
val = cell.getErrorCellValue();
}
}
} catch (Exception e) {
return val;
}
return val;
}
java cellvalue_Java Cell.getErrorCellValue方法代码示例相关推荐
- setcellvalue 格式_Java Cell.setCellValue方法代码示例
本文整理汇总了Java中org.apache.poi.ss.usermodel.Cell.setCellValue方法的典型用法代码示例.如果您正苦于以下问题:Java Cell.setCellVal ...
- java kryo_Kryo框架使用方法代码示例
Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...
- java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例
import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...
- java invalidate_Java Component.invalidate方法代码示例
import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...
- java hasmoreelements_Java IOException.hasMoreElements方法代码示例
import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...
- java methode_Java Method.getTypeParameters方法代码示例
import java.lang.reflect.Method; //导入方法依赖的package包/类 private void validateRuleMethod(MethodRuleDefin ...
- java setmethod_Java Operation.setJavaMethod方法代码示例
import com.sun.tools.internal.ws.processor.model.Operation; //导入方法依赖的package包/类 private void createJ ...
- java cancel_Java RunnableFuture.cancel方法代码示例
import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类 @Test public void testSnapshotAsyncC ...
- java setcolumnwidth_Java XSSFSheet.setColumnWidth方法代码示例
import org.apache.poi.xssf.usermodel.XSSFSheet; //导入方法依赖的package包/类 @SuppressWarnings("unchecke ...
最新文章
- 保存一下dedecms数据库表和字段说明,方便日后查询
- cannot use throw with exceptions disabled
- windows XP系统下oracle完整卸载过程
- 获取淘宝开发平台的sessionKey
- linux ns机制,Linux内核API ns_to_timespec
- linux下安装mysql5.5_Linux下安装mysql-5.5
- “工业4.0”下的可视化工厂建设方案 1
- mongodb 查多个不等于_MongoDB增删查
- java开源项目-SpringBoot在线教育平台
- yar php使用,php的轻量级rpc框架yar
- 小程序引入第三方字体
- 嗨格式数据恢复的 10 种最佳替代方法
- OSI七层参考模型及其协议和各层设备详解
- vue echart地图划分大区
- 怕研究生碌碌无为?那应该好好看看这篇文章
- 大数据培训出来好就业吗
- 安利一下,简单云笔记
- UML详解之基本元素-关系
- 简单两步, 搭建全平台私有同步网盘
- 【实战】RockMongo和RoboMongo初体验