Files
docx-js/src/file/table/grid.ts

23 lines
656 B
TypeScript
Raw Normal View History

2018-09-12 21:01:52 +01:00
// http://officeopenxml.com/WPtableGrid.php
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
2017-03-07 19:22:10 +01:00
export class TableGrid extends XmlComponent {
constructor(cols: number[]) {
super("w:tblGrid");
cols.forEach((col) => this.root.push(new GridCol(col)));
2017-03-07 19:22:10 +01:00
}
}
class GridColAttributes extends XmlAttributeComponent<{ readonly w: number }> {
protected readonly xmlKeys = { w: "w:w" };
}
2017-03-07 19:22:10 +01:00
export class GridCol extends XmlComponent {
constructor(width?: number) {
super("w:gridCol");
if (width !== undefined) {
2018-01-23 01:33:12 +00:00
this.root.push(new GridColAttributes({ w: width }));
}
2017-03-07 19:22:10 +01:00
}
}