How to set Excel default row height in Apache POI

I am using Apache POI 3.7 with Spring MVC 3.1.

How to set excel default line height in apache POI?

I tried sheet.setDefaultRowHeight((short) 100) and sheet.setDefaultRowHeightInPoints(100)

but it does not work.

Any suggestion on this issue?

Thanks.

+4
source share
4 answers

I posted this issue on the Apache POI tracker issue, and someone confirmed that this is a bug.

https://issues.apache.org/bugzilla/show_bug.cgi?id=52626

It is fixed on r1243240

+3
source

Create a style with the desired height and apply it to the cells that you want to display in this way. Documentation can help you. For a moment I thought that there was a way to set the height by styles ...

The documentation for the method you specify ... "set the default row height for the sheet (if the rows do not define their own height) to twips (1/20 point)." Be sure to enter input in Short

 setDefaultRowHeight( (Short) 100) 

You can also set the height for the row with row.setHeight (Short)

+3
source

I remember that I had this problem, I just finished with one of two approaches:

  • with width and height on individual cells to get around this problem.
  • using the excel file as a template and writing it.
+2
source

I use

  row.setHeightInPoints((2 * sheet.getDefaultRowHeightInPoints())); 

to set it (for example) to 2 characters.

+1
source

Source: https://habr.com/ru/post/1395344/


All Articles