返回顶部

收藏

JAVA JXL方式解析excel,简单代码片段

更多
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://outofmemory.cn

标签:java,Excel

收藏

0人收藏

支持

0

反对

0

发表评论