public static void main(String[] args) throws Exception{
redExcel();
}
private static void redExcel() throws Exception{
File file = new File("F://a.xls");
InputStream is = new FileInputStream(file);
jxl.Workbook rwb = Workbook.getWorkbook(is);
//Excel中sheet的个数int sheets = rwb.getNumberOfSheets();
Sheet st = rwb.getSheet(0);
jxl.Cell c00 = st.getCell(0,0);
String strc00 = c00.getContents();
//获取得一行第二列的值
jxl.Cell c10 = st.getCell(1,0);
String strc10 = c10.getContents();
//获取第二行第二列的值
jxl.Cell c11 = st.getCell(1,1);
String strc11 = c11.getContents();
System.out.println(strc00);
System.out.println(strc10);
System.out.println(strc11);
}
redExcel();
}
private static void redExcel() throws Exception{
File file = new File("F://a.xls");
InputStream is = new FileInputStream(file);
jxl.Workbook rwb = Workbook.getWorkbook(is);
//Excel中sheet的个数int sheets = rwb.getNumberOfSheets();
Sheet st = rwb.getSheet(0);
jxl.Cell c00 = st.getCell(0,0);
String strc00 = c00.getContents();
//获取得一行第二列的值
jxl.Cell c10 = st.getCell(1,0);
String strc10 = c10.getContents();
//获取第二行第二列的值
jxl.Cell c11 = st.getCell(1,1);
String strc11 = c11.getContents();
System.out.println(strc00);
System.out.println(strc10);
System.out.println(strc11);
}
本文提供了一个使用Java jxl库读取Excel (.xls) 文件的简单示例。该示例展示了如何打开指定路径下的Excel文件,获取第一个工作表,并读取其中的单元格数据。
575

被折叠的 条评论
为什么被折叠?



