Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #877: table columns defaulting to small/unusable sizes in some word processors #943

Closed
wants to merge 1 commit into from

Conversation

devoidfury
Copy link
Contributor

Fixes #877 - don't add w:tblGrid to table when columnWidths argument isn't provided. Fixed the Table tests to account for this, and added one additional test with columnWidths set to make sure it's added in that case.

@devoidfury devoidfury changed the title Fixes #877: table columns defaulting to small/unuable sizes in some word processors Fixes #877: table columns defaulting to small/unusable sizes in some word processors May 17, 2021
@dolanmiu
Copy link
Owner

What happens if no column width is provided? Does the document still look good?

@devoidfury
Copy link
Contributor Author

devoidfury commented May 17, 2021

Yes, it automatically grows based on content and space, tested in Word Online.

Screenshots of demo/25-table-xml-styles.ts below.

Before:
Before screenshot

After:
After screenshot

@devoidfury
Copy link
Contributor Author

Hm, from what I can tell, in older versions of the standard it was a required element, but in the newer versions it's optional. So this may cause an issue with word 2007 or older -- worth a test there first.

@devoidfury
Copy link
Contributor Author

Looking at the ooxml wml.xsd, it looks like it's required; so probably shouldn't remove it.

  <xsd:complexType name="CT_Tbl">
    <xsd:sequence>
      <xsd:group ref="EG_RangeMarkupElements" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="tblPr" type="CT_TblPr"/>
      <xsd:element name="tblGrid" type="CT_TblGrid"/>
      <xsd:group ref="EG_ContentRowContent" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

@devoidfury
Copy link
Contributor Author

Also it says in the accompanying spec,

If the table grid is omitted, then a new grid shall be constructed from the actual contents of the table assuming
that all grid columns have a width of 0.

So the spec says one thing, but the schema says another. Fun. The schema is what's used by tooling though, so should probably stick to that.

@@ -85,7 +85,9 @@ export class Table extends XmlComponent {
}),
);

this.root.push(new TableGrid(columnWidths));
if (columnWidths) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test here?

And a test without columnWidths?

@devoidfury
Copy link
Contributor Author

As of now, I don't think this is a good approach because in the xsd schema, it appears w:tblGrid is a required element in w:tbl.

@dolanmiu
Copy link
Owner

@devoidfury Ok, if so, can this be closed?

@devoidfury devoidfury closed this May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table styles don't work in online word
2 participants