Dagnon, Chris wrote: >Some questions: > >1. HSSFFont: Are the font's IDs the same for every machine? If so, is it >just a matter of someone putting in all the fonts other than Arial as >constants in this class? > > Nope. The font ID refers to the font record added. These are sequential identifiers. The string Font Name "Arial" is NOT guaranteed to be rendered as such. Meaning if you create an instance of HSSFFont on your workbook (which will be assigned a new id -- where id = last id + 1) and assign it the name "Arial" and I bring up Excel on my Unix box and don't install Arial, chances are it will be rendered in Helvetica or some other font instead. Same thing happens in Excel if you just assign a font on one machine and the next doesn't have it. Perhaps HSSFFont should be HSSFTypeStyle as it equals a Font + its styling, but we shan't because Microsoft doesn't. It would be more confusing to invent a new name. In short, HSSFFont's ID is assigned in the same manner as HSSFSheet's.
>HSSFCellStyle: The javadoc gives a couple examples with colors; > cs.setFillBackgroundColor(HSSFCellStyle.RED); > cs.setFillForgroundColor(HSSFSeCellStyle.RED); // Typo! >But the colors aren't listed in the javadoc as they are for many other >settings like setFillPattern(). Fortunately they come up in VAJ using >auto-complete. > This example is no longer valid either. (at least not in > 1.5) You must now use org.apache.poi.hssf.util.HSSFColor.RED, etc. Please submit your corrections in "patch" format. Meaning correct them and then submit a patch (use cvs diff -u) and I shall apply it. VAJ...eeew yucky. >My questions are: >2. Are the colors constant across all machine settings? > Yes and No. HSSF does not yet support custom pallettes. The Default pallette (that it supports) is constant accross all Excels and compatible apps. Custom pallette support is a furture requirement. >3. Are the colors listed the only choices? > answered above. >4. There wouldn't happen to be a short-cut/macro to set all cells in a row >to a certain partial HSSFCellStyle? For example I want to alternate row >colors but have all with the same font and yet keep the columns' number >styles the same :) Hmm, yeah, I suppose that would lead to more confusion >than clarity having it possible to specify at more than the cell's level 8) > You should create 1 HSSFCellStyle for EACH type of style and assign it to each row. As for some kind of conditional well that sounds like a good place for a utility class in your application rather than HSSF. Example (in my personal pseudocode style): Font1 = create HSSFFont... font1.set ... Font2 = create HSSFFont... font2.set ... Style1 = create HSSFCellStyle... style1.set.. style1.setFont(Font1) Style2 = create HSSFCellStyle... style2.set.. style2.setFont(Font2) for (int k = 0; k < 10; k++) { if (k mod 2 != 0) { set cell style to style 1 } else { set cell style to style 2 } } > >HSSFSheet.setColumnWidth(): I've tried using this a little, and I thought >the javadoc said that the width parameter was to represent 1/256th of a >character's width. It's not showing up in that manner (ie. 5*256 shows a >little more than 4 question mark characters) and I'm wondering if this is >due to 2 different factors: >5. That Excel shows some extra space on both sides of a given string inside >a cell >6. If the 1/256th is based on a font different from the default. > > This is basically a "Dunno" -- we read the docs, but the docs are wrong so in the past I've just created "majik equations" -- equations that work most of the time but probably only work by coincidence. I think you'd need to use the awt.fontmetrics to calculate this size and then advance the cell width based on that. The catch is that "character width" is not constant. W is bigger than I in most fonts. So basically its either an opportunity for someone to nail this down and figure out how to do it "right" or just play with it until you come up with an equation that works for your font. > >And if I didn't say it before: Thanks for this product! > > No problem man. We enjoy doing it. Thanks for helping make it better. -Andy >-Chris > >-- >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]>