2018-09-12 21:01:52 +01:00
|
|
|
// http://officeopenxml.com/WPtableGrid.php
|
2021-05-24 11:28:10 +03:00
|
|
|
|
|
|
|
// <xsd:complexType name="CT_TblGridCol">
|
|
|
|
// <xsd:attribute name="w" type="s:ST_TwipsMeasure"/>
|
|
|
|
// </xsd:complexType>
|
|
|
|
// <xsd:complexType name="CT_TblGridBase">
|
|
|
|
// <xsd:sequence>
|
|
|
|
// <xsd:element name="gridCol" type="CT_TblGridCol" minOccurs="0" maxOccurs="unbounded"/>
|
|
|
|
// </xsd:sequence>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
|
|
import { twipsMeasureValue } from "@util/values";
|
2017-03-07 19:22:10 +01:00
|
|
|
|
|
|
|
export class TableGrid extends XmlComponent {
|
2021-05-24 11:28:10 +03:00
|
|
|
constructor(widths: number[] | string[]) {
|
2017-03-10 16:51:19 +01:00
|
|
|
super("w:tblGrid");
|
2019-09-13 00:51:20 +01:00
|
|
|
for (const width of widths) {
|
|
|
|
this.root.push(new GridCol(width));
|
|
|
|
}
|
2017-03-07 19:22:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 11:28:10 +03:00
|
|
|
class GridColAttributes extends XmlAttributeComponent<{ readonly w: number | string }> {
|
2018-11-02 02:51:57 +00:00
|
|
|
protected readonly xmlKeys = { w: "w:w" };
|
2017-03-10 16:51:19 +01:00
|
|
|
}
|
|
|
|
|
2017-03-07 19:22:10 +01:00
|
|
|
export class GridCol extends XmlComponent {
|
2021-05-24 11:28:10 +03:00
|
|
|
constructor(width?: number | string) {
|
2017-03-10 16:51:19 +01:00
|
|
|
super("w:gridCol");
|
2017-03-10 17:45:16 +01:00
|
|
|
if (width !== undefined) {
|
2021-05-24 11:28:10 +03:00
|
|
|
this.root.push(new GridColAttributes({ w: twipsMeasureValue(width) }));
|
2017-03-10 17:45:16 +01:00
|
|
|
}
|
2017-03-07 19:22:10 +01:00
|
|
|
}
|
|
|
|
}
|