Word changing table cell width on load

Home Forums Open-Xml-PowerTools Word changing table cell width on load

This topic contains 2 replies, has 2 voices, and was last updated by  gamartin 8 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4171

    Eric White
    Keymaster

    Hi Garth,

    Yes, you are absolutely correct, Word is being “smart” when opening the file. The issue is that the actual layout of the table is sometimes just a set of desired configurations, and Word will do whatever it wants to.

    The genesis of this issue is that it is quite possible to set up a table with invalid column widths with regards to content, and Word then does whatever it wants with the table.

    I have seen this, but it has never become important to me to fully understand the algorithm that Word uses. Further, I think it likely that different versions of Word behave differently, but I don’t know.

    Best, Eric

    #4178

    gamartin
    Participant

    Thanks again Eric. I was able to get it to do what I needed by changing the call to GetTableProperties, passing in the settings. I added a setting to respect the column widths (since I know they are going to be valid – 50% each) and if set then the GetTableProperties adds a w:tblLayout type="fixed" element to the TableProperties element. In playing around with it, I found that Word added that element if I went into the table options and de-selected the “Automatically resize to fit contents” option.

    A bit of a hack, but it works for me. I was initially thinking that I could do it in the GetTableGrid method if the width properties had the important declaration, but it appears to be too late in the game…

    Thanks again.

    Garth

    • This reply was modified 8 years, 3 months ago by  gamartin.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.