/
column.ts
24 lines (21 loc) · 951 Bytes
/
column.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
import { PositiveUniversalMeasure, twipsMeasureValue } from "@util/values";
// <xsd:complexType name="CT_Column">
// <xsd:attribute name="w" type="s:ST_TwipsMeasure" use="optional" />
// <xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional" default="0" />
// </xsd:complexType>
type IColumnAttributes = {
readonly width: number | PositiveUniversalMeasure;
readonly space?: number | PositiveUniversalMeasure;
};
export class Column extends XmlComponent {
public constructor({ width, space }: IColumnAttributes) {
super("w:col");
this.root.push(
new NextAttributeComponent<IColumnAttributes>({
width: { key: "w:w", value: twipsMeasureValue(width) },
space: { key: "w:space", value: space === undefined ? undefined : twipsMeasureValue(space) },
}),
);
}
}