How do i autofit text in an Excel doucment using the Open Xml Format SDKv2 RRS feed

  • Question

  • I have been searching for a way to get Excel to autofit a column using C# and the Open Xml Format SDKv2. I have yet to find a way to do this.  I am generating server side Excel documents with information pulled from a database and everything works but you have to open the document and manually autofit  the columns. There has to be a way to do this automatically.

    • Edited by rolland_b Monday, October 13, 2008 4:54 PM
    Monday, October 13, 2008 4:53 PM

All replies

  • Hi Rolland,

    Did you find any way to do this? This is something i am trying to do at the moment.

    Wednesday, May 27, 2009 9:42 AM
  • Hi guys,

    I think "autofit" is sort of runtime layout function, which SDK is not capable of.
    You may notice that there's an attribute "bestfit" of element "col" in sheet part, but the attribute "bestfit" only works when the attribute "width" has specified value, which means "autofit" function cannot be implemented without knowing the "width" value.
    Further more, "autofit" is not only related the text length, but also related to the font size... so you need to calculate the width yourself.
    • Edited by goodol Sunday, May 31, 2009 8:20 AM
    Sunday, May 31, 2009 7:40 AM
  • Hi guys,

    Did you find a solution to solve this problem ?


    Tuesday, April 6, 2010 11:25 AM
  • Sorry I didn't manage to get it to work. I don't think the  Open Xml Format supports it.
    Tuesday, April 6, 2010 1:29 PM