Hello Dave,
1) How do I determine what font and point size to use?
The definition of 'Width' tells us that column width is measured as the
number of characters of the maximum digit width of the numbers 0,1,2,¡Â,9
as rendered in the *normal style's font*. (Please notice the bold part). We
do not need to determine what font and point size to use. It is decided by
the Excel setting of 'Normal Font', namely, normal style's font. When Excel
renders width to pixel in runtime, it will read the setting for 'Normal
Font' and use the formula '=Truncate(((256 * {width} +
Truncate(128/{Maximum Digit Width}))/256)*{Maximum Digit Width})' to
calculate the pixel. 'Normal Font' can be set at Format->Styles¡Â->Choose
'Normal' in the style name list.
2) Does it always use the character 0 at that width?
No, it uses the maximum character width of the normal font among 0,1,2,¡Â,9.
3) What is the correct formula to get the exact full width?
As we discussed in the post "XLSX cell width - in twips?",
The correct method to convert width to pixel is:
Pixel =Truncate(((256 * {width} + Truncate(128/{Maximum Digit
Width}))/256)*{Maximum Digit Width})
The correct method to convert pixel to width is:
1. use the formula =Truncate(({pixels}-5)/{Maximum Digit Width} *
100+0.5)/100 to convert pixel to character number.
2. use the formula width = Truncate([{Number of Characters} * {Maximum
Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256 to convert
the character number to width.
If you have any other questions or concerns, please feel free to let me
know.
Happy New Year!
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document:
http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.