poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Álvaro Póliz <alvpo...@gmail.com>
Subject Re: Help with long Strings in small cells
Date Tue, 26 Feb 2008 12:19:21 GMT
Thank you very much Josh. I will have to implement my own algorithm to 
fix the height of the row depending on the number of chars and words of 
my String (my font won´t change).

Same as you, I fixed manually the height on the second sheet, I also 
couldn´t find an option in Excel to do it automatically.

Thanks again for your help.
Álvaro.

Josh Micich escribió:
> So you have merged cells within which you want the text to wrap.
> I understand that with single cells and wrapped text, the row height
> adjusts automatically.
>
> Did you *manually* adjust the row height on the second sheet? (I
> couldn't get Excel to do it automatically).
>
> I'm guessing that for your problem, the text length is variable, the
> column widths are fixed, and the row height must adjust to fit the
> text nicely.  If I have got that wrong, please ignore this posting.
>
>
> Some java code that makes the first sheet look like the second is as follows:
> 		File fIn =new File("c:/temp/Álvaro-Excel_test.xls");
> 		InputStream is = new FileInputStream(fIn);
> 		HSSFWorkbook wb = new HSSFWorkbook(is);
> 		
> 		HSSFSheet sht = wb.getSheetAt(0);
> 		sht.getRow(8).setHeight((short)1624);
> 		for(int i=1; i< 9; i++) {
> 			sht.setColumnWidth((short)i, (short)2950);
> 		}
> 		
> 		File fOut = new File("c:/temp/Álvaro-Excel_test2.xls");
> 		FileOutputStream os = new FileOutputStream(fOut);
> 		wb.write(os);
> 		os.close();
> 		
>
> Of course, this leaves a big question: how many lines will the text
> wrap over, and therefore how high should the row be set to?
>
> It would be nice to have a function like the win api
> GetTextExtentPoint32() or iText BaseFont.getWidthPoint() to for
> measuring text, but from what I understand there is no way to exactly
> determine how Excel will render text of a particular font.
>
> It might be easiest to go for an approximate and simplistic algorithm.
>  If the text is always the same font, and if the content varies
> predictably, this might be a viable approach.
>
>
> Hope that helps.
> -josh
>
>
> On Tue, Feb 26, 2008 at 1:36 AM, Álvaro Póliz <alvpoliz@gmail.com> wrote:
>   
>> Sorry for my bad explanation. I attach the excel as you asked.
>>
>> Thanks - Álvaro.
>>
>> Josh Micich escribió:
>>
>>     
>>> I'm having a little trouble understanding exactly what you would like to do.
>>>
>>> Could you please attach an excel workbook with 2 sheets?
>>>  - on the first sheet put whatever POI generates, the way you are using it
>>>  - for the second sheet, make a copy of the first, but manually
>>> manipulate it to be way you would like.
>>>
>>> -josh
>>>
>>>
>>> On Tue, Feb 26, 2008 at 12:36 AM, Álvaro Póliz <alvpoliz@gmail.com> wrote:
>>>
>>>       
>>>> Hello.
>>>>
>>>> I just need some help with my generated Excels with POI.
>>>> I have a predefined size in all my columns and I have a long String I
>>>> need to set in a group in 4 cells. My problem is that it is still long
>>>> enough to make the fourth cell very very big. I would like to find a way
>>>> to justify the String to fill the lines needed in that row without
>>>> changing column width.
>>>>
>>>> Thanks for your help.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
>>>> For additional commands, e-mail: dev-help@poi.apache.org
>>>>
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: dev-help@poi.apache.org
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
>> For additional commands, e-mail: dev-help@poi.apache.org
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>
>   

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


Mime
View raw message