用了APACHE的POI 生成EXCEL文件 如何将一个PAGE对象存放在EXCEL当中,请教高手啊!!

love_alizee 2006-11-10 04:19:59
代码 如下:::
public ActionForward creat_Excel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
final String CONTENT_TYPE = "application/vnd.ms-excel";
response.setContentType(CONTENT_TYPE);
ActionErrors errors = new ActionErrors();

this.writeLog("进行通信统计分析生成EXCEL格式保存", "系统运行维护", "216", request);
if (log.isDebugEnabled()) {
log.debug("Entering 'edit' queryCommunicationAnalyse");
}

Map map = request.getParameterMap();
int pageNumber = Integer.parseInt(request.getParameter("pageNum"));
int pageSize = Integer.parseInt(request.getParameter("size"));
OriginalMessageManager originalMessageManager = (OriginalMessageManager) getBean("originalMessageManager");
Page page =originalMessageManager.getCommunicationAnalyse(map,
getUnitCode(request), pageNumber, pageSize);
try {
try {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFHeader header = sheet.getHeader();
header.setCenter("终端通信流量");
HSSFRow row1 = sheet.createRow((short) 0);
HSSFCell cell11 = row1.createCell((short) 0);
cell11.setEncoding(HSSFCell.ENCODING_UTF_16);
cell11.setCellValue("户号");
HSSFCell cell12 = row1.createCell((short) 1);
cell12.setEncoding(HSSFCell.ENCODING_UTF_16);
cell12.setCellValue("户名");
HSSFCell cell13 = row1.createCell((short) 2);
cell13.setEncoding(HSSFCell.ENCODING_UTF_16);
cell13.setCellValue("单位代码");
HSSFCell cell14 = row1.createCell((short) 3);
cell14.setEncoding(HSSFCell.ENCODING_UTF_16);
cell14.setCellValue("终端局号");
HSSFCell cell15 = row1.createCell((short) 4);
cell15.setEncoding(HSSFCell.ENCODING_UTF_16);
cell15.setCellValue("日期");
HSSFCell cell16 = row1.createCell((short) 5);
cell16.setEncoding(HSSFCell.ENCODING_UTF_16);
cell16.setCellValue("终端型号");
HSSFCell cell17 = row1.createCell((short) 6);
cell17.setEncoding(HSSFCell.ENCODING_UTF_16);
cell17.setCellValue("上行SMS条数");
HSSFCell cell18 = row1.createCell((short) 7);
cell18.setEncoding(HSSFCell.ENCODING_UTF_16);
cell18.setCellValue("下行SMS条数");
HSSFCell cell19 = row1.createCell((short) 8);
cell19.setEncoding(HSSFCell.ENCODING_UTF_16);
cell19.setCellValue("通讯流量(byte)");
HSSFCell cell20 = row1.createCell((short) 9);
cell20.setEncoding(HSSFCell.ENCODING_UTF_16);
cell20.setCellValue("通讯类型");



《〈〈〈〈request.setAttribute("page",page);》》》》》》》
请教如何把PAGE对象存放在 HSSFWorkbook wb 这个对象里面,
点页面按钮以后直接下载保存到本地PC????


sheet.setGridsPrinted(true);
HSSFFooter footer = sheet.getFooter();
footer.setRight("Page " + HSSFFooter.page() + " of "
+ HSSFFooter.numPages());

ServletOutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
} catch (Exception e) {
System.out.println("error in JSP");
}
return null;
} catch (Throwable e) {
e.printStackTrace();
ActionError error = new ActionError(e.getMessage());
errors.add(ActionErrors.GLOBAL_ERROR, error);
}
saveErrors(request, errors);
return new ActionForward(mapping.getInput());
}
...全文
241 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
buan 2006-11-10
  • 打赏
  • 举报
回复
关注...

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧