Demo POI 博客分类: JavaPOI excelJavaPOI
程序员文章站
2024-03-24 10:20:40
...
import java.io.FileOutputStream; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class book { public static void main(String[] args) throws Exception { //HSSFWorkbook HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet hssfSheet = wb.createSheet("Excel Template"); Row row = hssfSheet.createRow(0); Cell cell1 = row.createCell(0); cell1.setCellType(Cell.CELL_TYPE_STRING); cell1.setCellValue("HSSFWorkbook"); FileOutputStream out = new FileOutputStream(args[0]+"HSSFWorkbook.xls"); wb.write(out); out.flush(); out.close(); // SXSSFWorkbook hwb = new SXSSFWorkbook(1000); hwb.setCompressTempFiles(true); SXSSFSheet sheet = (SXSSFSheet) hwb.createSheet("Excel Template"); SXSSFRow rowhead = (SXSSFRow) sheet.createRow(0); Cell xssfCell = rowhead.createCell(0); xssfCell.setCellType(Cell.CELL_TYPE_STRING); xssfCell.setCellValue("SXSSFWorkbook"); FileOutputStream fileOut = new FileOutputStream(args[0]+"SXSSFWorkbook.xlsx"); hwb.write(fileOut); fileOut.flush(); fileOut.close(); Workbook hwb1 = new XSSFWorkbook(); XSSFSheet xssfsheet = (XSSFSheet) hwb1.createSheet("Excel Template"); Row r = xssfsheet.createRow(0); Cell ce = r.createCell(0); ce.setCellType(Cell.CELL_TYPE_STRING); ce.setCellValue("XSSFWorkbook"); FileOutputStream fileOut1 = new FileOutputStream(args[0]+"XSSFWorkbook.xlsx"); hwb1.write(fileOut1); fileOut1.flush(); fileOut1.close(); } }
上一篇: pycurl连接基库处理方法
下一篇: 知识点二
推荐阅读
-
Demo POI 博客分类: JavaPOI excelJavaPOI
-
非poi实现word中导入pic图片代码示例 博客分类: word操作
-
非poi实现word中导入pic图片代码示例 博客分类: word操作
-
Exttld demo 博客分类: 页面展现 框架
-
Instagram的实时图片Demo:Node.js, Redis 加 Web Sockets 博客分类: kv存储nosql RedisWebMongoDB
-
mondrian + oracle 部署foodmart demo 博客分类: 门户.Bi OracleJDBCJSPTomcatDerby
-
用POI HSSF处理EXCEL表格 博客分类: J2SE ExcelApacheServletJSPBean
-
ext的几种常用类demo 博客分类: extJse
-
ext的几种常用类demo 博客分类: extJse
-
Hadoop2.7.1-WordCount Demo 博客分类: Hadoop MRHadoopWordCount