Skip to content

Commit 5a169e0

Browse files
committed
fix(table): exclude tcPr; fix mimeType for DOMParser
1 parent f5d7756 commit 5a169e0

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/helper/xml-elements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ export default class XmlElements {
296296
}
297297

298298
dataPointLabel() {
299-
const doc = new DOMParser().parseFromString(dLblXml, 'application/ xml');
299+
const doc = new DOMParser().parseFromString(dLblXml, 'application/xml');
300300
const ele = doc.getElementsByTagName('c:dLbl')[0] as unknown as Node;
301301
const firstChild = this.element.firstChild;
302302
this.element.insertBefore(ele.cloneNode(true), firstChild);
303303
}
304304

305305
tableCellBorder(tag: 'a:lnL' | 'a:lnR' | 'a:lnT' | 'a:lnB') {
306-
const doc = new DOMParser().parseFromString(lnLRTB, 'application/ xml');
306+
const doc = new DOMParser().parseFromString(lnLRTB, 'application/xml');
307307
const ele = doc.getElementsByTagName(tag)[0] as unknown as Node;
308308
const firstChild = this.element.firstChild;
309309
this.element.insertBefore(ele.cloneNode(true), firstChild);

src/modify/modify-table.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,17 @@ export class ModifyTable {
4949
);
5050

5151
this.data.body.forEach((row: TableRow, r: number) => {
52-
this.table.modify({
53-
'a16:rowId': {
54-
index: r,
55-
modify: ModifyXmlHelper.attribute('val', r),
56-
},
57-
});
58-
5952
row.values.forEach((cell, c: number) => {
6053
const rowStyles = row.styles && row.styles[c] ? row.styles[c] : {};
6154
this.table.modify(
6255
this.row(r, this.column(c, this.cell(cell, rowStyles))),
6356
);
57+
this.table.modify({
58+
'a16:rowId': {
59+
index: r,
60+
modify: ModifyXmlHelper.attribute('val', r),
61+
},
62+
});
6463
if (!alreadyExpanded) {
6564
this.expandOtherMergedCellsInColumn(c, r);
6665
}
@@ -119,33 +118,33 @@ export class ModifyTable {
119118
column = (index: number, children: ModificationTags): ModificationTags => {
120119
return {
121120
'a:tc': {
122-
children: {
123-
'a:txBody': {
124-
index: index,
125-
children: children,
126-
fromPrevious: true,
127-
},
128-
},
121+
index: index,
122+
children: children,
123+
fromPrevious: true,
129124
},
130125
};
131126
};
132127

133128
cell = (value: number | string, style?: TableRowStyle): ModificationTags => {
134129
return {
135-
'a:t': {
136-
modify: ModifyTextHelper.content(value),
137-
},
138-
'a:rPr': {
139-
modify: ModifyTextHelper.style(style),
130+
'a:txBody': {
131+
children: {
132+
'a:t': {
133+
modify: ModifyTextHelper.content(value),
134+
},
135+
'a:rPr': {
136+
modify: ModifyTextHelper.style(style),
137+
},
138+
'a:r': {
139+
collection: (collection: HTMLCollectionOf<Element>) => {
140+
XmlHelper.sliceCollection(collection, 1);
141+
},
142+
},
143+
},
140144
},
141145
'a:tcPr': {
142146
...this.setCellStyle(style),
143147
},
144-
'a:r': {
145-
collection: (collection: HTMLCollectionOf<Element>) => {
146-
XmlHelper.sliceCollection(collection, 1);
147-
},
148-
},
149148
};
150149
};
151150

0 commit comments

Comments
 (0)