- 博客(0)
- 资源 (3)
- 收藏
- 关注
java处理execl表格源码
本作品为一个公司出路考勤表的程序
JFileChooser chooser1 = new JFileChooser();
int state = chooser1.showOpenDialog(null);
chooser1.show();
String filepath=null;
boolean flag = true;
if (chooser1.getSelectedFile() != null
&& state == JFileChooser.APPROVE_OPTION) {
filepath = chooser1.getSelectedFile().getAbsolutePath();
WritableWorkbook info = null;
WritableSheet sheet = null;
Label c = null;
try {
File f = new File(filepath+".xls");
f.exists();
info = Workbook.createWorkbook(f);
sheet = info.createSheet("ok", 0);
int size = l.size();
for (int i = 0; i < size; i++) {
String[] msg = l.get(i).toString().split(",");
c = new Label(0, i, msg[0]);
sheet.addCell(c);
c = new Label(1, i, msg[1]);
sheet.addCell(c);
c = new Label(2, i, msg[2]);
sheet.addCell(c);
c = new Label(3, i, msg[4]);
sheet.addCell(c);
c = new Label(4, i, msg[5]);
sheet.addCell(c);
System.out.println(i+1);
if(i+2>size)
{
break;
}
String[] msg1 = l.get(i+1).toString().split(",");
c = new Label(5, i++,msg1[5]);
sheet.addCell(c);
}
info.write();
} catch (Exception ex) {
flag = false;
ex.printStackTrace();
} finally {
try {
if (info != null) {
info.close();
}
} catch (Exception exx) {
}
2009-08-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人