Calculate pixel width/height for row/col width/height?

I'm trying to write an AutoFit function to automatically set the height of a row or the width of a column.

For instance, if I call AutoFitWidth on column 3, it will loop through all the cells in column 3 and set the column width to the maximum necessary width to avoid spillover.

To do this, I need to calculate the pixel width of the strings in each cell, and font/font size/actual string come into play. Any suggestions? By the way, I need this to be pretty fast, so I can't instantiate any expensive objects, and this is running on a high-concurrency server. Thanks for any and all replies!

[719 byte] By [CompMan86] at [2008-2-5]
# 1

Checkout http://www.codeproject.com/useritems/text_in_color.asp. This should lead you in the right direction.

s.c.gardner at 2007-9-28 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...