java 讀取excel內容詳細代碼。本站提示廣大學習愛好者:(java 讀取excel內容詳細代碼)文章只能為提供參考,不一定能成為您想要的結果。以下是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();
}
}