Other Usage Notes

Formats are associated with cell data at the time the cell is written. Either you specify an explicit format handle at that time, or a default format will be used. The SetCol and SetRow functions establish default formats, but will not change the formats for data already written. The only way to change the format of a cell already written is with the SheetSetCellFormat() function, or by rewriting it.

Since the format information is associated with each cell by means of a handle, changing the attributes of the format itself will affect the cells already written using that format handle.

Setting column widths to automatic (width = -1) appears to work best if done after all the data is written. (It seems to calculate the size at the time of the SetCol function based on the data available.) So you may want to use SetCol to assign a default column format prior to writing column data, and then use it again to set auto-width after writing all the data.

When setting cell colors, note that the text color is an attribute of the font (not of the format), and that a solid background color is set via fillpattern=FILLPATTERN_SOLID and patternfgc=COLOR_XXX. Yes, that's the pattern FOREGROUND color. (Pattennbgc values only apply to striped patterns.)

To add a format attribute, such as a background color, to an existing cell of unknown attributes, use SheetGetCellFormat() to retrieve the existing format, then use AddFormat'SetAttrbutes() to create a new format, specifying the existing format as the hinitformat param, along with any new attributes. Then use SheetSetCellFormat() to update the cell with the new format, e.g.:

hformat = Fn'LibXL'SheetGetCellFormat(sheet1,row,col)

hnewformat = Fn'LibXL'AddFormat'SetAttributes(alignh=ALIGHN_CENTER, hinitformat=hformat)

call LibXL'SheetSetCellFormat(sheet1,row,col,hnewformat)