只能读取97-2003的文件格式xls, 不支持xlsx格式
import java.io.File; import jxl.*; public class ExcelUtils { public static void main(String[] args) { try { Workbook book = Workbook.getWorkbook(new File("c:\\Book1.xls")); // 获得第一个工作表对象 Sheet sheet = book.getSheet(0); // 得到单元格 for (int i = 0; i < sheet.getRows(); i++) { for (int j = 0; j < sheet.getColumns(); j++) { Cell cell = sheet.getCell(j,i); System.out.print(cell.getContents() + " "); } System.out.println(); } book.close(); } catch (Exception e) { System.out.println(e); } } }
本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1700060
时间: 2024-12-31 02:57:39