package com.bestpay.bpbp.bill.init; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import java.io.File; import java.io.IOException; public class ReadExcelDataForTestNG { private static String parementFile = "E:/test-xiaozhangException.xls"; private File file; public static String getParementFile() { return parementFile; } public static String getParementFileNext() { return parementFile; } public ReadExcelDataForTestNG(File file){ this.file = file; } public String[][] str(int sNO) { String[][] str = null; try { Workbook book = Workbook.getWorkbook(file); // 获得第一个工作表对象 Sheet sheet = book.getSheet(sNO); // 得到第一列第一行的单元格 int col = sheet.getColumns();// 得到列数 int row = sheet.getRows();// 得到行数 str = new String[row-1][col]; for (int i = 0; i < row-1; i++)// 循环进行读写 { for (int j = 0; j < col; j++) { Cell c = sheet.getCell(j, i+1); str[i][j]= c.getContents(); } } book.close(); } catch (BiffException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return str; } }
JAVA读取Excel中sheet页内容
原创laiwenhuajava 博主文章分类:技术博客 ©著作权
文章标签 JAVA读取Excel中sheet页内容 文章分类 办公效率
上一篇:JAVA修改excel的内容
-
java获取当月最大日
java获取当月最大日
System java 字段 -
Java socket 获取gps定位
本文详细介绍了Java socket 获取gps定位的方法,并给出了详细的代码示例。
服务器 数据 客户端 Java