- package com.using.test;
- import java.io.File;
- import jxl.Cell;
- import jxl.Sheet;
- import jxl.Workbook;
- import jxl.WorkbookSettings;
- public class TestExcel {
- public static void main(String[] args) {
- Workbook book;
- try {
- File file = new File("F:\\\\temp\\\\111.xls");
- WorkbookSettings workbookSettings = new WorkbookSettings();
- workbookSettings.setEncoding("UTF-8");
- book = Workbook.getWorkbook(file, workbookSettings);
- Sheet sheet = book.getSheet(0);
- for (int i = 1; i < sheet.getRows(); i++) {
- for (int j = 0; j < sheet.getColumns(); j++) {
- Cell cell = sheet.getCell(j, i);
- String result = cell.getContents();
- System.out.println(result);
- }
- }
- book.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/241020136665.html
来源: http://www.codesnippet.cn/detail/241020136665.html