1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package com.xiaoye.demo;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/** * 遍历excel文本
* @author 小夜的传说
* 2014-2-22 下午4:26:55
*/
public class ThrText {
public static void main(String[] args) throws Exception {
InputStream in= new FileInputStream( "d://测试文件.xls" );
POIFSFileSystem fs= new POIFSFileSystem(in);
HSSFWorkbook wb= new HSSFWorkbook(fs);
ExcelExtractor excelExtractor= new ExcelExtractor(wb);
excelExtractor.setIncludeSheetNames( false ); //这个意思是不需要Sheet页的名字
System.out.println(excelExtractor.getText());
}
} |
效果图:
本文转自 小夜的传说 51CTO博客,原文链接:http://blog.51cto.com/1936625305/1362156,如需转载请自行联系原作者