private static void WriteExcel2010() throws IOException {
String path="C:\\poi2.xlsx";
XSSFWorkbook workbook=new XSSFWorkbook();
XSSFSheet sheet=workbook.createSheet("我的Sheet");
XSSFRow row=sheet.createRow(0);
XSSFCell cell=row.createCell(0);
cell.setCellValue("我是POI写入的");
XSSFRow row1=sheet.createRow(1);
XSSFCell cell1=row1.createCell(0);
cell1.setCellValue("2010");
FileOutputStream outputStream=new FileOutputStream(path);
workbook.write(outputStream);
outputStream.close();
}
private static void WriteExcel2003() throws IOException {
String path="C:\\poi2.xls";
HSSFWorkbook workbook=new HSSFWorkbook();
HSSFSheet sheet=workbook.createSheet("我的Excel");
HSSFRow row=sheet.createRow(0);
HSSFCell cell=row.createCell(0);
cell.setCellValue("我是POI写入的");
FileOutputStream outputStream=new FileOutputStream(path);
workbook.write(outputStream);
outputStream.close();
}
必须用poi么?? 我有个jxl的