/*String sheetNames[] = wb.getSheetNames();
//读取一个excel里的全部sheet名称
for (int i = 0; i < sheetNames.length; i++) {
System.out.println("sheet name="+ i +sheetNames[i]);
}*/
int columns = sh1.getColumns();
for (int i = 0; i < sh1.getRows(); i++) {
//String[] nextLine = new String[columns];
System.out.println();
for (int j = 0; j < columns; j++) {
//注意不论什么一个cell(单元格)getContents()以后都会得到一个字符串(无论它原来是什么类型,eg:整形、浮点型、字符....)
String cellVal = sh1.getCell(j, i).getContents();
//System.out.print(sh1.getCell(j, i).getContents()+" || ");
System.out.println(cellVal+" || ");
}
}
//关闭
wb.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void getExcel(){
try {
File f = new File("d:/a.xls");
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableSheet sheet = workbook.createSheet("1", 0);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 1000; j++) {
Label label = new Label(i,j,"sdss"+i+"-"+j);
sheet.addCell(label);
}
}