码迷,mamicode.com
首页 > 其他好文 > 详细

xls读取

时间:2015-05-30 11:56:27      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

/**
* 读取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;
};
}

xls读取

标签:

原文地址:http://www.cnblogs.com/wei-java/p/4540065.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!