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

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

问题描述

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

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).

我认为这个问题不需要代码示例,Excel文档是按照手册中的描述创建的:

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天全站免登陆