检测所需的打印方向与Apache POI [英] Detect needed print orientation with Apache POI

查看:144
本文介绍了检测所需的打印方向与Apache POI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache POI创建XLS US preadsheets。有没有一种方式,如果在纵向模式,或者如果我必须设置表为横向模式下的数据符合检测?我知道如何设置的模式,但我不知道怎么找出来,如果​​数据符合当前的打印方向。

I'm using Apache POI to create xls spreadsheets. Is there a way to detect if the data fits in portrait mode or if I have to set the sheet to landscape mode? I know how to set the modes, but I don't know how to find out if the data fits the current print orientation.

推荐答案

我试过,但不能看到的方式来得到这个工作。

I've tried but cant see a way to get this working.

在创建工作簿,POI默认飞度高度和宽度各1。

When you create the workbook, poi defaults the Fit Height and Width to 1 each.

适合高度是高页数
  在适合板材

Fit Height is the number of pages high to fit sheet in

适合宽度是宽的页数
  在适合板材

Fit Width is the number of pages wide to fit sheet in

除非您在打印纸的高度和宽度设置为像这样一个较高的值,

Unless you set the sheet print height and width to a higher value like so,

sheet.getPrintSetup().setFitHeight((short)10);

System.out.println (sheet.getPrintSetup().getFitWidth());
System.out.println (sheet.getPrintSetup().getFitHeight());

总是返回1和1

always return 1 and 1

问题是Excel将始终COM preSS的数据(缩放大小)下调至10%,以适应1×1页面布局。 [在MS_Excel,这显示为打印preVIEW>页面设置>缩放>下到实际大小的X%]

The problem is Excel will always compress the data (in zoom size) down to 10% to fit the 1 x 1 page layout. [In MS_Excel, this shows up as Print Preview > Page Setup > Scaling > Down to X% of actual size ]

在变焦在10%,那么它的数据溢出到第2页等

Once the zoom is at 10%, it then overflows the data onto page 2 and so on.

我试过用板材大量的数据,甚至派出了大量printArea中

I've tried a sheet with lots of data and even sent a large PrintArea

workBook.setPrintArea(
                    0, //sheet index
                    0, //start column
                    50, //end column
                    0, //start row
                    520  //end row
            );

在多种打印尺寸。

on a variety of print sizes.

sheet.getPrintSetup().setPaperSize((short)11); // A5 

所以默认可打印区域/方向不会改变,除非你覆盖它们,所以我不认为该数据可以检测到比可打印区域 - 这就是你想获得什么

So the default printable area / orientation are not changed unless you override them, so I dont think the data can be detected to be larger than the printable area - which is what you're trying to obtain.

这可能是一个用于POI邮件列表。

This might be one for the POI mailing lists.

更新以包括链接到POI邮件列表中讨论,因为已经被OP问。

Updated to include link to this discussion on POI mailing lists as already asked by OP.

<一个href=\"http://mail-archives.apache.org/mod_mbox/poi-user/201010.mbox/%3c4CBDD258.80407@openforce.com%3e\" rel=\"nofollow\">http://mail-archives.apache.org/mod_mbox/poi-user/201010.mbox/%3c4CBDD258.80407@openforce.com%3e

这篇关于检测所需的打印方向与Apache POI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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