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

查看:279
本文介绍了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天全站免登陆