Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set sheet zoom% to 120 using apache POI

Tags:

apache-poi

How can I set sheet zoom% to 120 using Apache POI ?

I tried with sheet.setZoom(5,4) but its outputs to 125% zoom. Also this method accepts only integers.

Any help would be appreciated.

like image 698
Viraj Udeg Avatar asked Mar 10 '23 04:03

Viraj Udeg


1 Answers

The API docs for the Sheet interface in Apache POI state:

setZoom(int scale) - Window zoom magnification for current view representing percent values.

and

setZoom(int numerator, int denominator) Deprecated. 2015-11-23 (circa POI 3.14beta1). Use setZoom(int) instead.

So try:

sheet.setZoom(120);

Or to use the deprecated method on an older version of the API:

sheet.setZoom(12, 10);

Note, 5/4=1.25 which is the reason you get zoomed to 125%

like image 95
Finbarr O'B Avatar answered Apr 25 '23 09:04

Finbarr O'B