Jxl的Excel导入导出 不支持2007

Jxl的导出 

mport java.io.File;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class jxlExpExcel {
/** * 
 * jxl excel导入
 */
public static void main(String[] args) {
String[] title={"id","name","sex"};
File file=new File("d:/bool.xls");
try {
file.createNewFile();
WritableWorkbook  workbook=Workbook.createWorkbook(file);
WritableSheet Sheet = workbook.createSheet("sheet1",0);

Label label=null;
for (int i = 0; i < title.length; i++) {
label=new Label(i,0,title[i]);
Sheet.addCell(label);

}
for (int i = 1; i <10; i++) {
label=new Label(0,i,"a"+i);
Sheet.addCell(label);
label=new Label(1,i,"user"+i);
Sheet.addCell(label);
label=new Label(2,i,"nan");
Sheet.addCell(label);

}
workbook.write();//别忘了输出流
workbook.close();
} catch (Exception e) {

e.printStackTrace();
}
}
}

Excel的导出

import java.io.File;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
public class JxlReadExcel {
public static void main(String[] args) {
try {
Workbook workbook =Workbook.getWorkbook(new File("d:/bool.xls"));
Sheet sheet=workbook.getSheet(0);
for (int i = 0; i for (int j = 0; j Cell cell=sheet.getCell(j, i);
System.out.print(cell.getContents()+"");

System.out.println();
workbook.close();
}
} catch (Exception e) {

e.printStackTrace();
}

}
}

你可能感兴趣的:(Jxl的Excel导入导出 不支持2007)