【发布时间】:2017-01-19 01:06:13
【问题描述】:
Java 1.7、Apache-poi-3.8、JDBC
要求: 1) 创建一个包含完整数据(来自数据库)的工作簿对象。无需在服务器上创建任何文件。
HSSFWorkbook wb = new HSSFWorkbook(); // this object I want to store in DB blob column, without any file creation at server.
insertDataToCells(wb, "output", data); // this method will insert data in cells of workbook.
**//TODO code to store wb in blob column.** // How to store ?
2) 从 blob 中检索数据(工作簿)并将其转换为 excel 并发送到邮件附件中
// TODO How to retrive
以下方法:
byte[] byteArray = wb.getBytes();
InputStream is = new ByteArrayInputStream(byteArray);
ps.setBinaryStream(1, is, 1000000); // Here i am having some confusion
ps.execute // Successfully stored in blob column.
检索时出错文件已损坏。
【问题讨论】:
标签: java jdbc apache-poi