62,254
社区成员
发帖
与我相关
我的任务
分享public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream(new File("d:/1.xls"));
Workbook rwb = Workbook.getWorkbook(fis);
Sheet rs = rwb.getSheet(0);
int rows = rs.getRows();
int columns = rs.getColumns();
int n = 0; // 定义几列,这里有三列
int c = 1;
int t = 2;
for (int i = 1; i < rows; i++) {
String name = rs.getCell(n, i).getContents().trim();
String city = rs.getCell(c, i).getContents().trim();
String address = rs.getCell(t, i).getContents().trim();
CouponBean coupon = new CouponBean();
coupon.setCity(city);
coupon.setName(name);
coupon.setAddress(address);
System.out.println(coupon.getName() + "\t" + coupon.getCity()
+ "\t" + coupon.getAddress());
}
} 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();
}
}