Using open xml sdk code, how to resize a table (in ms word document) to fit into page margins?

StackOverflow https://stackoverflow.com/questions/8150048

質問

I am using Microsoft Open XML SDK to generate a word document. I have used Open XML SDK 2.0 Productivity Tool for converting the word document into C# code, and thus I have created a wrapper class by encapsulating the table creation code. I have successfully generated word document.

But the issue is, some tables are expanding in their width beyondpage margins. I searched in google, and found that GrowAutoFit class allows Tables to AutoFit into page margins, but I couldn't find the exact usage of this class to implement the functionality.

I searched a lot for many days before asking a question here, as i have read the terms of asking a question on this forum. I got tired of searching, and i'm putting forward this query here. So please suggest me the solution.

役に立ちましたか?

解決

I found the answer for my own question.

The reason for the tables extending out of page was that i had set page margins as zero in the code. So, after i set the page margins as 1 inch on all sides, the tables are not extending out of margins.

Thanks to the Office Open XML SDK Productivity tool, which shows the native XML code, and also the C# code when a word document is opened in it. And becuase of this tool, i was able to figure out the issue.

Thanks for your suggestions Maximilian :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top