@jsreport/exceljs
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
44 lines (39 loc) • 1.13 kB
JavaScript
class CacheField {
constructor({name, sharedItems}) {
// string type
//
// {
// 'name': 'A',
// 'sharedItems': ['a1', 'a2', 'a3']
// }
//
// or
//
// integer type
//
// {
// 'name': 'D',
// 'sharedItems': null
// }
this.name = name;
this.sharedItems = sharedItems;
}
render() {
// PivotCache Field: http://www.datypic.com/sc/ooxml/e-ssml_cacheField-1.html
// Shared Items: http://www.datypic.com/sc/ooxml/e-ssml_sharedItems-1.html
// integer types
if (this.sharedItems === null) {
// TK(2023-07-18): left out attributes... minValue="5" maxValue="45"
return `<cacheField name="${this.name}" numFmtId="0">
<sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1" />
</cacheField>`;
}
// string types
return `<cacheField name="${this.name}" numFmtId="0">
<sharedItems count="${this.sharedItems.length}">
${this.sharedItems.map(item => `<s v="${item}" />`).join('')}
</sharedItems>
</cacheField>`;
}
}
module.exports = CacheField;