读取excel
来源:互联网 发布:苹方字体ttf windows 编辑:程序博客网 时间:2024/06/06 03:14
public static void readExcel() throws IOException {
int totalRows;// 获取excel总行数
int totalCols;// 获取excel总列数
String readPath = “C:/Users/lc/Desktop/1.xlsx”;
File file = new File(readPath);
FileInputStream is = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(is);
Sheet sheet = wb.getSheetAt(0);
totalRows = sheet.getPhysicalNumberOfRows();
totalCols = sheet.getRow(0).getPhysicalNumberOfCells();
for (int i = 0; i < totalRows; i++) {
Row row = sheet.getRow(i);
for (int j = 0; j < totalCols; j++) {
String cellValue = “”;
Cell cell = row.getCell(j);
if (null != cell) {
// 以下是判断数据的类型
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC: // 数字
cellValue = cell.getNumericCellValue() + “”;
break;
case HSSFCell.CELL_TYPE_STRING: // 字符串 cellValue = cell.getStringCellValue(); break; case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean cellValue = cell.getBooleanCellValue() + ""; break; case HSSFCell.CELL_TYPE_FORMULA: // 公式 cellValue = cell.getCellFormula() + ""; break; case HSSFCell.CELL_TYPE_BLANK: // 空值 cellValue = ""; break; case HSSFCell.CELL_TYPE_ERROR: // 故障 cellValue = "非法字符"; break; default: cellValue = "未知类型"; break; } } System.out.println(cellValue + " "); } System.out.println(); }}
- 读取excel
- EXCEL读取
- 读取excel
- 读取excel
- 读取Excel
- 读取Excel
- 读取excel
- 读取excel
- excel读取
- 读取Excel
- 读取excel
- 读取excel
- excel读取
- excel读取
- Excel 读取
- 读取excel
- Excel读取
- 读取excel
- 全志A64 android6.0系统允许第三方应用读写U盘外置sd卡修改
- 安卓 触屏旋转、缩放、拖拽
- TEC1304.值集和弹性域相关技术总结 - 第三章 键弹性域详解
- Git 命令集
- Undefined symbols for architecture x86_64:和"_OBJC_CLASS_$_xx", referenced from:问题解决方法
- 读取excel
- 微信小程序之我见
- 自己训练SVM分类器进行HOG行人检测
- GREENPLUM中使用脚本导出非外部表的表结构
- Oracle 触发器中修改字段值
- 关于ORACLE的GROUP BY基数的探索
- CSS实现响应式全屏背景图
- Java双向链表实现
- 利用wireshake暴力破解密码