【poi第三节】poi提取excel文本信息

x33g5p2x  于2021-12-28 转载在 其他  
字(0.7k)|赞(0)|评价(0)|浏览(221)

poi提取excel文本信息

import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.FileInputStream;
import java.io.InputStream;

/**
 * @ClassName 类名:ExcelDemo3
 * @Author作者: hzh
 * @Date时间:2018/12/4 10:56
 * 文本提取
 **/
public class ExcelDemo3 {

    public static void main(String[] args) throws Exception{
        InputStream inputStream = new FileInputStream("D:\\file\\工作薄.xls");
        POIFSFileSystem poifsFileSystem = new POIFSFileSystem(inputStream);
        HSSFWorkbook wb = new HSSFWorkbook(poifsFileSystem);
        ExcelExtractor excelExtractor = new ExcelExtractor(wb);
        excelExtractor.setIncludeSheetNames(false);//不需要sheet页的名字
        System.out.println(excelExtractor.getText());
    }
}

相关文章