Apache POI setPrintArea 到 A4 页面大小 [英] Apache POI setPrintArea to A4 page size

查看:46
本文介绍了Apache POI setPrintArea 到 A4 页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Apache POI API 来生成 .xls 文件,我想设置我的文件的打印区域.

I'm working with the Apache POI API to generate .xls files, and I want to set the printArea of my file.

我知道有一个名为 setPrintArea() 的函数,但是这个函数接收我的打印区域的开始和结束行和列作为参数.

I know there is a funcion called setPrintArea() but this one receive as parameters start and end row and column of my print area.

我想知道,是否有办法为每张 A4 纸(210mmx290mm)的尺寸设置打印区域

I want to know, if there is a way to set my print area for each sheet with the size of an A4 paper (210mmx290mm)

谢谢.

推荐答案

对于工作簿中的每个 Sheet,获取其 PrintSetup 对象并调用 setPaperSize 就可以了, 传递适当的 PrintSetup 常量:A4_PAPERSIZE.

For each Sheet in the workbook, get its PrintSetup object and call setPaperSize on it, passing the appropriate PrintSetup constant: A4_PAPERSIZE.

mySheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);

这篇关于Apache POI setPrintArea 到 A4 页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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