一个简单的导出EXCEL文件的程序

import java.io.FileOutputStream; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public class TestMain { public static void main(String[] args) throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new sheet"); HSSFRow row = sheet.createRow(0); HSSFCell cell1 = row.createCell(0); cell1.setCellValue("X"); HSSFCell cell2 = row.createCell(1); cell2.setCellValue("Y"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("d:/test.xls"); wb.write(fileOut); fileOut.close(); } }

你可能感兴趣的:(apache,Excel)