Apache的POI:为Excel工作表更改页面格式 [英] Apache POI: change page format for Excel worksheet

查看:190
本文介绍了Apache的POI:为Excel工作表更改页面格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在创建使用Apache POI Excel文档更改页面大小和布局?默认的是A4垂直的,而我需要A6-水平(横向)。

我不认为这个问题需要code样品,按照手册中描述的刚刚建立的Excel文档:

 工作簿WB =新HSSFWorkbook();
苫布苫布= wb.createSheet(新表);


解决方案

  sheet.getPrintSetup()setLandscape(真)。
。sheet.getPrintSetup()setPaperSize(HSSFPrintSetup.A5_PAPERSIZE);

<一个href=\"http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPrintSetup.html\">HSSFPrinterSetup的Javadoc

Is there a way to change the page size and layout while creating the Excel document using Apache POI? The default one is A4-vertical, while I need A6-horizontal (landscape).

I don't think that this question requires code sample, the Excel document is created just as described in the manual:

Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");

解决方案

sheet.getPrintSetup().setLandscape(true);
sheet.getPrintSetup().setPaperSize(HSSFPrintSetup.A5_PAPERSIZE); 

HSSFPrinterSetup Javadoc

这篇关于Apache的POI:为Excel工作表更改页面格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆