当前位置: 技术问答>java相关
给一个简单的使用POI例子和使用步骤好吗?
来源: 互联网 发布时间:2017-03-28
本文导语: 我刚下载了poi,不知道如何使用 请高手帮忙 另外问一句:poi可是使excel嵌入到ie里面吗? | HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new sheet"); HSSFRo...
我刚下载了poi,不知道如何使用
请高手帮忙
另外问一句:poi可是使excel嵌入到ie里面吗?
请高手帮忙
另外问一句:poi可是使excel嵌入到ie里面吗?
|
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(new Date());
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));
cell = row.createCell((short)1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(new Date());
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));
cell = row.createCell((short)1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
|
I assume you are using HSSF of POI to generate spreadsheet file(excel)
Check the link below, it contains all basic code you need
http://jakarta.apache.org/poi/hssf/quick-guide.html
Check the link below, it contains all basic code you need
http://jakarta.apache.org/poi/hssf/quick-guide.html