标签:
/**
* 读取xls文件内容
*
* @return List<Dto>对象
* @throws IOException
* 输入/输出(i/o)异常
* @throws SQLException
*/
public void readXls(Dto dt) throws Exception {
String attachFilePath=dt.getAsString("filepath");
//String FilePath="F:/cxm/workspace/labsystem/WebRoot/uploaddata/2015-05-04/aaa.xls";
InputStream is = new FileInputStream(attachFilePath);
ExcelReader excelReader = new ExcelReader(null, is);
Sheet sheet = excelReader.getSheet();
int rows = sheet.getRows();
for (int i = 0; i < rows; i++) {
Cell[] cells = sheet.getRow(i);
String exceldata=cells[i].getContents();
}
}
package org.eredlab.g4.rif.report.excel;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.eredlab.g4.ccl.datastructure.Dto;
import org.eredlab.g4.ccl.datastructure.impl.BaseDto;
import org.eredlab.g4.ccl.util.G4Utils;
/**
* Excel数据读取器
*
* @author XiongChun
* @since 2010-08-12
*/
public class ExcelReader {
private String metaData = null;
private InputStream is = null;
public ExcelReader(){};
/**
* 构造函数
* @param pMetaData 元数据
* @param pIs Excel数据流
* @throws IOException
* @throws BiffException
*/
public ExcelReader(String pMetaData, InputStream pIs){
setIs(pIs);
setMetaData(pMetaData);
}
public InputStream getIs() {
return is;
}
public void setIs(InputStream is) {
this.is = is;
}
public String getMetaData() {
return metaData;
}
public void setMetaData(String metaData) {
this.metaData = metaData;
};
}
标签:
原文地址:http://www.cnblogs.com/wei-java/p/4540065.html