[moving to dev list] FOP has done a lot of the work you suggest below (particularly the metric calculation for fonts). The font metrics for basic fonts in FOP are stored in XML files : http://cvs.apache.org/viewcvs.cgi/xml-fop/src/codegen/
Further there is a set of tools that can be run on any font file (pfm or ttf) to produce xml like the ones above. http://cvs.apache.org/viewcvs.cgi/xml-fop/src/org/apache/fop/fonts/apps/ These xml files are then used to generate code which provides the following info for each font http://cvs.apache.org/viewcvs.cgi/xml-fop/src/org/apache/fop/layout/FontMetric.java http://cvs.apache.org/viewcvs.cgi/xml-fop/src/org/apache/fop/layout/FontDescriptor.java Now this should theorerically give us all the info we want -- basically the width of a charachter. However, at first glance it did not seem easy to remove all FOP dependencies. Maybe some discussion with the FOP folks is in order? I dont particularly want to reuse the metric generation code, but more the metric usage code (that which gives us an easy interface to char widths, given the xml) Regards - Avik On Thu, 2002-12-19 at 20:24, Laubach Shawn Contr OC-ALC/PSB wrote: > The relationship between the font size and the width isn't very good (I > know). I tried this very path and couldn't figure out the math because if > you used a different font but at the same font size, you got different > results. Something I didn't try at the time, but that would probably help > would be to: > > 1. Create a sheet with different font sizes, fonts, and a few different > strings across the first row of a sheet (in some orderly fashion). > 2. Open up the sheet in excel and select all columns and hit autofit and > then save. > 3. Open it up in hssf and get the widths for each column. > 4. Compare data and look for patterns. > 5. Post any findings because it would probably be useful in multiple places > (like a function that took the width in the same units that excel does). > 6. Implement the code to do the calculations. > > Shawn > > -----Original Message----- > From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 18, 2002 10:14 AM > To: POI Users List > Subject: Re: Autofit > > > OOOps! you're right! > > Okay here is the alternative: > > Implement the Pure Java (awt/swingless) font metrics. Ken has posted > some time back > a source for the data that could probably be run through the record > generator with a style sheet. > > Figure out the mathematical relationship between the unit of measure and > the font size/etc. (I think its based on the font size though I might > be wrong). > > All in all I don't think its hard, just I'm not that in to math. > > -Andy > > Laubach Shawn Contr OC-ALC/PSB wrote: > > >Are you talking about autofit under row and column of formats? If so, > >that's not a property, it's an action. Nothing is saved and nothing > >autofits again unless you select again. > > > >Shawn > > > >-----Original Message----- > >From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]] > >Sent: Tuesday, December 17, 2002 1:38 PM > >To: POI Users List > >Subject: Re: Autofit > > > > > >First, Grab a copy of the Excel 97 Developers' kit from amazon.com ( out > >of print but ~$15(US) used or from surplus sellers). This documents the > >format. > > > >Create a blank sheet with text in the upper right hand cell (or some > >other cell) > >save it > >copy it to another file as well > >open it > >assign the autofit property > > > >java org.apache.poi.hssf.dev.BiffViewer noautofit.xml > output.1 > >java org.apache.poi.hssf.dev.BiffViewer yesautofit.xml > output.2 > >diff output.1 output.2 > > > >That gives you the differences between an autofitted cell and a non > >autofitted cell. You merely need to interperate them (using the book) > >and make the appropriate changes to HSSF. (should be simple). > > Shouldn't take long once you get the source material. > > > >We should move this conversation to poi-dev. > > > >-Andy > > > >Charlat, Simon (Exchange) wrote: > > > > > > > >>Let me know what needs to be done. > >>I need to estimate it for the users and maybe they will pay for my time to > >>do this. > >>I defaulted all the cells width to the longest data value. > >>It doesn't look good. > >> > >>-----Original Message----- > >>From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]] > >>Sent: Tuesday, December 17, 2002 12:54 PM > >>To: [EMAIL PROTECTED] > >>Subject: Re: Autofit > >> > >>No thats not it. Autofit is a seperate issue. Just we have like 4 > >>people actively working on HSSF and they are all working on other things > >>at current. Autofit is just a style issue (you say "yes autofit this > >>cell"). If someone would like to volunteer to implement it, I can > >>explain how. I just don't have time to do it currently. > >> > >>-Andy > >> > >>Brian Glick wrote: > >> > >> > >> > >> > >>>There has been frequent discussion on this list about implementing an > >>>Autofit feature, but, thus far, it has not been done. So far, no one > >>> > >>> > >>> > >>> > >>seems > >> > >> > >> > >> > >>>to have come up with a foolproof formula for calculating the appropriate > >>>widths. > >>> > >>>Brian Glick > >>>Freightek, Inc. > >>>(215) 887-6100 > >>>[EMAIL PROTECTED] > >>> > >>>-----Original Message----- > >>>From: Charlat, Simon (Exchange) [mailto:[EMAIL PROTECTED]] > >>>Sent: Tuesday, December 17, 2002 10:30 AM > >>>To: 'POI Users List' > >>>Subject: RE: Autofit > >>> > >>>I went through all the docs and I didn't find anything besides > >>>setDefaultColumnWidth or setColumnWidth. > >>>That's what you refering to? > >>>I am using it already and I am not happy with it. > >>>I have to calculate the width and it is not perfect. > >>>Can I use anything else? > >>> > >>> > >>>Thank you, > >>>Simon Charlat > >>>ITG - Mutual Funds > >>>973-793-7506 > >>>Bearnet 8-226-7506 > >>>Fax 973-793-7389 > >>> > >>>-----Original Message----- > >>>From: Vikas Pathak [mailto:[EMAIL PROTECTED]] > >>>Sent: Tuesday, December 17, 2002 5:42 AM > >>>To: POI Users List > >>>Subject: Re: Autofit > >>> > >>>Hi, > >>> > >>>Go to the Apache Excel Sheet docs for POI.U will get the FUll API for the > >>>HSSF -POI docs. > >>>If any clarification please let me nkow. > >>>Thanks & regards > >>>Kalpana Kanniappan > >>> > >>>"Charlat, Simon (Exchange)" wrote: > >>> > >>> > >>> > >>> > >>> > >>>>I need to execute Autofit command on excel file created using HSSF. > >>>>I could not find any reference in HSSF support document. > >>>>Please, help. > >>>> > >>>>Thank you, > >>>>Simon > >>>> > >>>>**************************************************************** > >>>>Bear Stearns is not responsible for any recommendation, solicitation, > >>>>offer or agreement or any information about any transaction, customer > >>>>account or account activity contained in this communication. > >>>>*********************************************************************** > >>>> > >>>>-- > >>>>To unsubscribe, e-mail: > >>>> > >>>> > ><mailto:[EMAIL PROTECTED]> > > > > > >>>>For additional commands, e-mail: > >>>> > >>>> > ><mailto:[EMAIL PROTECTED]> > > > > > >>>> > >>>> > >>>> > >>>> > >>>-- > >>>To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > >>>For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > >>> > >>> > >>>**************************************************************** > >>>Bear Stearns is not responsible for any recommendation, solicitation, > >>>offer or agreement or any information about any transaction, customer > >>>account or account activity contained in this communication. > >>>*********************************************************************** > >>> > >>> > >>>-- > >>>To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > >>>For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > >>> > >>> > >>> > >>> > >> > >> > >>-- > >>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > >>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > >> > >> > >>**************************************************************** > >>Bear Stearns is not responsible for any recommendation, solicitation, > >>offer or agreement or any information about any transaction, customer > >>account or account activity contained in this communication. > >>*********************************************************************** > >> > >> > >>-- > >>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > >>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > >> > >> > >> > >> > >> > >> > > > > > > > > > >-- > >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > >-- > >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > > > > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
