none
Computing the width and height of characters in Excel RRS feed

  • Question

  • Is there any way?

    precise column widths.

    use c# or other

    input:

     font,fontSize,bold

    output:

    width,height

    help me,please. thk.

    Monday, March 18, 2019 1:16 AM

All replies

  • 杨相移

    Thank you for your question.  An engineer from the protocols team will contact you soon.

    B.


    Bryan S. Burgin Senior Escalation Engineer Microsoft Protocol Open Specifications Team

    Monday, March 18, 2019 7:03 AM
    Moderator
  • Hi 杨相移,

    Can you describe why you need to calculate column widths and/or character width and height? The information used by Excel to render column widths and characters is included in the file format but the actual rendering is an implementation detail left to applications and can depend on a variety of factors including device metrics and other things. 

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications

    Monday, March 18, 2019 4:14 PM
    Moderator
  • Hi Tom Jebo !

    thk reply.

    I need cut big table to lot of page like A4 or A3 size for print.

    column width need full paper.

    like follow this.

    name   age  gender height weight    to     page1  [name   agegender]      page2 [name  height weight ]

    ignore '[' or ']'


    column[name] not truncate and column[name] need width equals this character width.

    sorry ,i can't english ,google translate help me do this.

    thk again.

    Tuesday, March 19, 2019 1:30 AM
  • Hi 杨相移, 

    If I understand your goal correctly, you would like to extract part of a worksheet from Excel (a table) and then print it with your application (c# or something), trying to match the same widths for the columns and making sure the text fits within those columns. 

    If this is correct, then there are parts of the file format (SpreadsheetML in ISO 29500-1) that can be used to determine the width of columns in a table. See ISO 29500-1 18.3.1.81 "sheetFormatPr (Sheet Format Properties)" for determining column widths and how to calculate them. Also, see 18.3.1.13 "col (Column Width & Formatting)" for custom widths. 

    If you're looking for a library for extracting data from Excel sheets, there are multiple libraries available. One that you might consider is the OpenXML SDK on github: 

    https://github.com/OfficeDev/Open-XML-SDK

    I hope this information helps.

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications



    Thursday, March 21, 2019 10:02 PM
    Moderator
  • Hi Tom Jebo

    thk you .

    I found the answer.

    But not good, can calculation only font for "宋体"

    everyone if you see this and need me help.

    contact me, my email: 1249492252@qq.com






    • Edited by 杨相移 Friday, March 22, 2019 6:44 AM the word wrong
    Friday, March 22, 2019 6:42 AM