Apache POI(8):数据库
来源:互联网 发布:淘宝不支持花呗 编辑:程序博客网 时间:2024/06/05 10:39
package com.hthk.iisz.util;import java.io.File;import java.io.FileOutputStream;import java.sql.Connection;import java.sql.ResultSet;import java.sql.Statement;import org.apache.poi.xssf.usermodel.XSSFCell;import org.apache.poi.xssf.usermodel.XSSFRow;import org.apache.poi.xssf.usermodel.XSSFSheet;import org.apache.poi.xssf.usermodel.XSSFWorkbook;public class DBTest {public static void main(String[] args) throws Exception { excelDatabase();} public static void excelDatabase() throws Exception{Connection conn = JdbcConn.getConn();Statement stmt = conn.createStatement();ResultSet rs = stmt.executeQuery("select customer, title from reg_form");XSSFWorkbook workbook = new XSSFWorkbook();XSSFSheet sheet = workbook.createSheet("reg_form db");XSSFRow row = sheet.createRow(1);XSSFCell cell;cell = row.createCell(1);cell.setCellValue("customer");cell = row.createCell(2);cell.setCellValue("title");int i=2;while(rs.next()){row = sheet.createRow(i++);cell = row.createCell(1);cell.setCellValue(rs.getString("customer"));cell = row.createCell(2);cell.setCellValue(rs.getString("title"));}FileOutputStream fos = new FileOutputStream(new File("reg_form.xlsx"));workbook.write(fos);fos.close();System.out.println("reg_form.xlsx written successfully");}}
0 0
- Apache POI(8):数据库
- Apache POI 连接数据库生成excel
- POI (Apache POI)
- 【POI】Apache POI
- Apache POI
- apache poi
- Apache POI
- Apache -poi
- Apache POI
- Apache POI
- Apache POI
- Apache POI
- Apache POI
- Apache POI
- apache poi
- Apache POI
- Apache POI
- Apache POI
- updateViewConstraints和updateConstraints
- NOIP 2011 - 提高组 聪明的质检员 二分+前缀和 重庆一中高2018级竞赛班第六次测试 2016.7.31 Problem 2
- java多线程基础(1)
- Java五个最常用的集合类之间的区别和联系
- 很好的分页实例代码(JSP)
- Apache POI(8):数据库
- Tcp/Ip详解 读书笔记 第1到4章
- 【Redis】Redis的介绍与安装部署
- cocopods
- Picasso源码的简单解析(二)
- Hedonic Game Related Research
- pl/sql编码集问题
- 网站页面性能优化的34条黄金守则
- C#控制台基础 控制台使用console.read读入一个字符