poi Excel写数据
2016-03-03 16:47
204 查看
public static void writeExcel(List<String[]> list,String[] format,String fileName){ HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Sheet1"); //获取第一行 HSSFRow row = sheet.createRow(0); //第一行为的标题 for(int i = 0 ; i < format.length ; i++){ row.createCell(i).setCellValue(format[i]); } //将list中的数据添加到Excel中 for(int j = 0 ; j < list.size() ; j++ ){ HSSFRow row2 = sheet.createRow(j+1); String[] temp = list.get(j); for(int k = 0 ; k < temp.length ; k++){ row2.createCell(k).setCellValue(temp[k]); } } try { //保存到指定的文件中 FileOutputStream outStream = new FileOutputStream(fileName); workbook.write(outStream); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
相关文章推荐
- 内存泄漏解决方案
- BZOJ2738: 矩阵乘法
- 兰州大学2016年初试成绩基本要求
- LinearLayout 组件居中显示
- PHP file_get_contents 设置超时时间
- 老李秘技:loadrunner回放脚本错误提示Error: "HTTP Status-Code 500"
- Android日常知识收集之通过一个按钮来控制密码是明文还是暗文显示
- 老李说事:性能测试服务日记
- 基于Android中实现定时器的3种解决方法
- 构造器的调用顺序
- 大数据量文件的上传下载技巧
- 零基础搭建单机Mahout、简单程序的运行
- 开始学习SOUI.
- Mahout学习之Mahout简介、安装、配置、入门程序测试
- 【bzoj】 - 2242 计算器 【BSGS】
- C语言#line预处理
- Android开发&测试工具
- 公钥私钥加密详解
- Splay POJ3468(老题新做)
- 四川大学2016年硕士研究生入学考试初试合格线