You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Coppola Mirko <mi...@PITAGORA.IT> on 2011/03/11 13:44:44 UTC

getHeightInPoints()

Hi,

in a for like this

for (int i = startRow; i <= endRow; i++) {
                              HSSFRow r = sheet.getRow(i);
                              System.out.println(r. getHeightInPoints());
                        }

I've printed the heights of my rows as multiple of DefaultRowHeightInPoints (15) NOT what I view on the xls file. Why?
I attach a example of table. I use poi-3.0.2.

Thanks a lot for the help
Bye Mirco


RE: getHeightInPoints()

Posted by Mirco Coppola <mi...@hotmail.com>.
Thanks,

i'll try your suggestion. 

I would renderer my Excel in PDF using FOP. I must know the width  of a column and the height of a row in centimeter respect to A4-sized sheet.
I noticed that it's possible get information  width in pixels of a column or  height of a row  in pixels, but the number of pixels varies depending on screen resolution and its size in inches and then render a table on a PC is different from another.... I need a unique reference to the measures of A4 sheet .

How do i get width ahd heigth of a cell in centimeter respect A4  using POI 3.0.2? 


> From: dfisher@jmlafferty.com
> Subject: Re: getHeightInPoints()
> Date: Sat, 12 Mar 2011 13:28:16 -0800
> To: user@poi.apache.org
> 
> Hi Mirco,
> > in a for like this
> > 
> > 
> >  
> > 
> > for (int i = startRow; i <= endRow; i++) { 
> > 
> >                               HSSFRow r = sheet.getRow(i); 
> > 
> >                               System.out.println(r. getHeightInPoints());
> > 
> >                         }        
> > 
> >  
> > 
> > I’ve printed the heights of my rows as multiple of DefaultRowHeightInPoints (15) NOT what I view on the xls file. Why?
> > 
> > I attach a example of table. I use poi-3.0.2.
> > 
> > 
> 
> The rows in your sheet are set to the default row height. The actual height is expanded because columns A and D have Text Wrap turned on and some cells have text that need to wrap.
> 
> HSSFRow will return the value that the Excel file is set to, yours is set to the default. It is not measuring and guessing the layout with wrapping. To do so is difficult and might not be consistent across different versions of Excel like between Mac and Windows or OpenOffice.
> 
> If knowing the "Auto-sized" height is important then you could follow the pattern of autosizing columns in the worksheet class.
> 
> Regards,
> Dave
> 
> >  
> > 
> > Thanks a lot for the help
> > 
> > Bye Mirco
> > 
> >  
> > 
> > <example.xls>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> 
 		 	   		  

Re: getHeightInPoints()

Posted by David Fisher <df...@jmlafferty.com>.
Hi Mirco,

POI 3.0.2 is very old. I would very much recommend that you update to either POI 3.7 or 3.8 beta 1.

Also look into the recent thread "Reading superscript from data-cell" to understand how to read the RichText and appreciate the difficulty of your task.

Also take a look at the list archives, others have worked on similar transformations.

> Thanks,
> 
> i'll try your suggestion. 
> 
> I would renderer my Excel in PDF using FOP. I must know the width  of a column and the height of a row in centimeter respect to A4-sized sheet.
> I noticed that it's possible get information  width in pixels of a column or  height of a row  in pixels, but the number of pixels varies depending on screen resolution and its size in inches and then render a table on a PC is different from another.... I need a unique reference to the measures of A4 sheet .

To say nothing of Mac vs. Windows.

> 
> How do i get width ahd heigth of a cell in centimeter respect A4  using POI 3.0.2? 

Given what you want to do, have you looked into Open Office or Libre Office?

Regards,
Dave

> 
> 
>> From: dfisher@jmlafferty.com
>> Subject: Re: getHeightInPoints()
>> Date: Sat, 12 Mar 2011 13:28:16 -0800
>> To: user@poi.apache.org
>> 
>> Hi Mirco,
>>> in a for like this
>>> 
>>> 
>>> 
>>> 
>>> for (int i = startRow; i <= endRow; i++) { 
>>> 
>>>                              HSSFRow r = sheet.getRow(i); 
>>> 
>>>                              System.out.println(r. getHeightInPoints());
>>> 
>>>                        }        
>>> 
>>> 
>>> 
>>> I’ve printed the heights of my rows as multiple of DefaultRowHeightInPoints (15) NOT what I view on the xls file. Why?
>>> 
>>> I attach a example of table. I use poi-3.0.2.
>>> 
>>> 
>> 
>> The rows in your sheet are set to the default row height. The actual height is expanded because columns A and D have Text Wrap turned on and some cells have text that need to wrap.
>> 
>> HSSFRow will return the value that the Excel file is set to, yours is set to the default. It is not measuring and guessing the layout with wrapping. To do so is difficult and might not be consistent across different versions of Excel like between Mac and Windows or OpenOffice.
>> 
>> If knowing the "Auto-sized" height is important then you could follow the pattern of autosizing columns in the worksheet class.
>> 
>> Regards,
>> Dave
>> 
>>> 
>>> 
>>> Thanks a lot for the help
>>> 
>>> Bye Mirco
>>> 
>>> 
>>> 
>>> <example.xls>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>> 
> 		 	   		  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


RE: getHeightInPoints()

Posted by Mirco Coppola <mi...@hotmail.com>.
Thanks,

i'll try your suggestion. 

I would renderer my Excel in PDF using FOP. I must know the width  of a column and the height of a row in centimeter respect to A4-sized sheet.
I noticed that it's possible get information  width in pixels of a column or  height of a row  in pixels, but the number of pixels varies depending on screen resolution and its size in inches and then render a table on a PC is different from another.... I need a unique reference to the measures of A4 sheet .

How do i get width ahd heigth of a cell in centimeter respect A4  using POI 3.0.2? 


> From: dfisher@jmlafferty.com
> Subject: Re: getHeightInPoints()
> Date: Sat, 12 Mar 2011 13:28:16 -0800
> To: user@poi.apache.org
> 
> Hi Mirco,
> > in a for like this
> > 
> > 
> >  
> > 
> > for (int i = startRow; i <= endRow; i++) { 
> > 
> >                               HSSFRow r = sheet.getRow(i); 
> > 
> >                               System.out.println(r. getHeightInPoints());
> > 
> >                         }        
> > 
> >  
> > 
> > I’ve printed the heights of my rows as multiple of DefaultRowHeightInPoints (15) NOT what I view on the xls file. Why?
> > 
> > I attach a example of table. I use poi-3.0.2.
> > 
> > 
> 
> The rows in your sheet are set to the default row height. The actual height is expanded because columns A and D have Text Wrap turned on and some cells have text that need to wrap.
> 
> HSSFRow will return the value that the Excel file is set to, yours is set to the default. It is not measuring and guessing the layout with wrapping. To do so is difficult and might not be consistent across different versions of Excel like between Mac and Windows or OpenOffice.
> 
> If knowing the "Auto-sized" height is important then you could follow the pattern of autosizing columns in the worksheet class.
> 
> Regards,
> Dave
> 
> >  
> > 
> > Thanks a lot for the help
> > 
> > Bye Mirco
> > 
> >  
> > 
> > <example.xls>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> 
 		 	   		  

Re: getHeightInPoints()

Posted by David Fisher <df...@jmlafferty.com>.
Hi Mirco,
> in a for like this
> 
> 
>  
> 
> for (int i = startRow; i <= endRow; i++) { 
> 
>                               HSSFRow r = sheet.getRow(i); 
> 
>                               System.out.println(r. getHeightInPoints());
> 
>                         }        
> 
>  
> 
> I’ve printed the heights of my rows as multiple of DefaultRowHeightInPoints (15) NOT what I view on the xls file. Why?
> 
> I attach a example of table. I use poi-3.0.2.
> 
> 

The rows in your sheet are set to the default row height. The actual height is expanded because columns A and D have Text Wrap turned on and some cells have text that need to wrap.

HSSFRow will return the value that the Excel file is set to, yours is set to the default. It is not measuring and guessing the layout with wrapping. To do so is difficult and might not be consistent across different versions of Excel like between Mac and Windows or OpenOffice.

If knowing the "Auto-sized" height is important then you could follow the pattern of autosizing columns in the worksheet class.

Regards,
Dave

>  
> 
> Thanks a lot for the help
> 
> Bye Mirco
> 
>  
> 
> <example.xls>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org