java 读取excel内容具体代码
1. 需要下载jxl.jar包,自己研究了一下,代码如下
package file;
import java.io.file;
import java.io.ioexception;
import java.util.arraylist;
import java.util.hashmap;
import java.util.map;
import jxl.workbook;
import jxl.read.biff.biffexception;
import jxl.write.*;
import jxl.sheet;
import jxl.cell;
import jxl.workbook;
public class excel {
/**
* @param args
* @throws ioexception
* @throws biffexception
*/
public static void main(string[] args) throws biffexception, ioexception {
// todo auto-generated method stub
workbook book = workbook.getworkbook(new file("f://center20130902update.xls"));
sheet sheet=book.getsheet(0);
arraylist list = new arraylist();
for(int k=2;k<96;k++){
map rowdata = new hashmap();
for(int j=2;j<5;j++){
cell cell = sheet.getcell(j,k);//列,行
cell keycell = sheet.getcell(j,1);
string key = keycell.getcontents();
string content = cell.getcontents();
rowdata.put(key, content);
}
list.add(rowdata);
}
system.out.println(list);
book.close();
}
}