Table AutoFit To Content
See original GitHub issueInitially, I thought about implementing Table AutoFitType, but it seems that AutoFit.ToContent is not something that is automatic but is something that Word does automatically, as in set it to fixes size and then using TabelGrid sizes sets the rest.
I don’t know the magic numbers to count this - but maybe someone does to fix this in future.
public enum AutoFitType {
ToContent,
ToWindow,
Fixed
}
public AutoFitType? AutoFit {
get {
if (this.Width == 0 && WidthType == TableWidthUnitValues.Auto) {
return AutoFitType.ToContent;
} else if (this.Width == 5000 && WidthType == TableWidthUnitValues.Pct) {
return AutoFitType.ToWindow;
} else if (this.LayoutType == TableLayoutValues.Fixed) {
return AutoFitType.Fixed;
}
return null;
}
set {
if (value == AutoFitType.ToContent) {
this.Width = 0;
this.WidthType = TableWidthUnitValues.Auto;
//this.LayoutType = TableLayoutValues.Autofit;
} else if (value == AutoFitType.ToWindow) {
this.Width = 5000;
this.WidthType = TableWidthUnitValues.Pct;
} else if (value == AutoFitType.Fixed) {
this.LayoutType = TableLayoutValues.Fixed;
} else {
throw new ArgumentException("Invalid value for AutoFitType. Probably should add null handling");
}
}
}
public TableGrid GenerateTableGrid()
{
TableGrid tableGrid1 = new TableGrid();
GridColumn gridColumn1 = new GridColumn(){ Width = "3116" };
GridColumn gridColumn2 = new GridColumn(){ Width = "3117" };
GridColumn gridColumn3 = new GridColumn(){ Width = "3117" };
tableGrid1.Append(gridColumn1);
tableGrid1.Append(gridColumn2);
tableGrid1.Append(gridColumn3);
return tableGrid1;
}
Issue Analytics
- State:
- Created a year ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to Adjust Table Columns in Word (AutoFit)
To adjust the column width, click the up and down arrows within the "Width" field. To make all columns the same width, click...
Read more >Fixing AutoFit Table Columns in Word
Word will automatically adjust or Autofit the width of table columns and the space within cells to fit the content that you are...
Read more >2 Quick Ways to Auto Fit Tables to Contents or Page in ...
Method 1: Alter Manually · First and foremost, click to select the whole table. · Then, click “Layout” tab under “Table Tools”. ·...
Read more >AutoFitting Tables (Microsoft Word)
If your table contains information, you can use the mouse to quickly do an AutoFit. You do that by simply double-clicking the mouse...
Read more >How to Automatically Resize a Table in Microsoft Word
Right-click and move your cursor to AutoFit in the shortcut menu. Then, pick either "AutoFit to Contents" or "AutoFit to Window" in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i’ve seen it when reading XML files created by Word. The width/height of different things in OfficeIMO is a mess
Then we need to change an API and accept both numbers and strings with percentages or another property