您好,欢迎光临本网站![请登录][注册会员]  
文件名称: PoI帮助文档
  所属分类: Java
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2013-07-20
  提 供 者: jilon******
 详细说明: 1.创建工作簿 (WORKBOOK)    HSSFWorkbook wb = new HSSFWorkbook();    FileOutputStream fileOut = new FileOutputStream("workbook.xls");    wb.write(fileOut);    fileOut.close();2.创建工作表(SHEET)    HSSFWorkbook wb = new HSSFWorkbook();    HSSFSheet sheet1 = wb.createSheet("new sheet");    HSSFSheet sheet2 = wb.createSheet("second sheet");    FileOutputStream fileOut = new FileOutputStream("workbook.xls");    wb.write(fileOut);    fileOut.close();3.创建单元格(CELL)    HSSFWorkbook wb = new HSSFWorkbook();     HSSFSheet sheet = wb.createSheet("new sheet");    // Create a row and put some cells in it. Rows are 0 based.    HSSFRow row = sheet.createRow((short)0);    // Create a cell and put a value in it.    HSSFCell cell = row.createCell((short)0);    cell.setCellValue(1);    // Or do it on one line.    row.createCell((short)1).setCellValue(1.2);    row.createCell((short)2).setCellValue("This is a string");    row.createCell((short)3).setCellValue(true);    // Write the output to a file    FileOutputStream fileOut = new FileOutputStream("workbook.xls");    wb.write(fileOut);    fileOut.close();4.创建指定单元格式的单元格    HSSFWorkbook wb = new HSSFWorkbook();    HSSFSheet sheet = wb.createSheet("new sheet");    // Create a row and put some cells in it. Rows are 0 based.    HSSFRow row = sheet.createRow((short)0);    // Create a cell and put a date value in it.  The first cell is not styled    // as a date.    HSSFCell cell = row.createCell((short)0);    cell.setCellValue(new Date());    // we style the second cell as a date (and time).  It is important to    // create a new cell style from the workbook otherwise you can end up    // modifying the built in style and effecting not only this cell but other cells.    HSSFCellStyle cellStyle = wb.createCellStyle();    cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));    cell = row.createCell((short)1);    cell.setCellValue(new Date());    cell.setCellStyle(cellStyle);    // Write the output to a file    FileOutputStream fileOut = new FileOutputStream("workbook.xls");    wb.write(fileOut);    fileOut.close();5. 单元格的不同格式    HSSFWorkbook wb = new HSSFWorkbook();    HSSFSheet sheet = wb.createSheet("new sheet");    HSSFRow row = sheet.createRow((short)2);    row.createCell((short) 0).setCellValue(1.1);    row.createCell((short) 1).setCellValue(new Date());    row.createCell((short) 2).setCellValue("a string");    row.createCell((short) 3).setCellValue(true);    row.createCell((short) 4).setCellType(HSSFCell.CELL_TYPE_ERROR);    // Write the output to a file    FileOutputStream fileOut = new FileOutputStream("workbook.xls");    wb.write(fileOut);    fileOut.close();6.单元格的不通对齐方式    public static void main(String[] args)            throws IOException    {        HSSFWorkbook wb = new HSSFWorkbook();        HSSFSheet sheet = wb.createSheet("new sheet");        HSSFRow row = sheet.createRow((short) 2);        createCell(wb, row, (short) 0, HSSFCellStyle.ALIGN_CENTER);        createCell(wb, row, (short) 1, HSSFCellStyle.ALIGN_CENTER_SELECTION);        createCell(wb, row, (short) 2, HSSFCellStyle.ALIGN_FILL);        createCell(wb, row, (short) 3, HSSFCellStyle.ALIGN_GENERAL);        createCell(wb, row, (short) 4, HSSFCellStyle.ALIGN_JUSTIFY);        createCell(wb, row, (short) 5, HSSFCellStyle.ALIGN_LEFT);        createCell(wb, row, (short) 6, HSSFCellStyle.ALIGN_RIGHT);        // Write the output to a file        FileOutputStream fileOut = new FileOutputStream("workbook.xls");        wb.write(fileOut);        fileOut.close();    }    /** ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: PoI
 输入关键字,在本站1000多万海量源码库中尽情搜索: