Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/doc/workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Workbook.prototype = {
return {
creator: this.creator || 'Unknown',
lastModifiedBy: this.lastModifiedBy || 'Unknown',
lastPrinted: this.lastPrinted,
created: this.created,
modified: this.modified,
worksheets: this._worksheets.map(function(worksheet) { return worksheet.model; }),
Expand All @@ -156,6 +157,7 @@ Workbook.prototype = {

this.creator = value.creator;
this.lastModifiedBy = value.lastModifiedBy;
this.lastPrinted = value.lastPrinted;
this.created = value.created;
this.modified = value.modified;
this.company = value.company;
Expand Down
1 change: 1 addition & 0 deletions lib/stream/xlsx/workbook-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var WorkbookWriter = module.exports = function(options) {
this.modified = options.modified || this.created;
this.creator = options.creator || 'ExcelJS';
this.lastModifiedBy = options.lastModifiedBy || 'ExcelJS';
this.lastPrinted = options.lastPrinted;

// using shared strings creates a smaller xlsx file but may use more memory
this.useSharedStrings = options.useSharedStrings || false;
Expand Down
3 changes: 3 additions & 0 deletions lib/xlsx/xform/core/core-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var CoreXform = module.exports = function() {
'cp:keywords': new StringXform({tag: 'cp:keywords'}),
'cp:category': new StringXform({tag: 'cp:category'}),
'cp:lastModifiedBy': new StringXform({tag: 'cp:lastModifiedBy'}),
'cp:lastPrinted': new DateXform({tag: 'cp:lastPrinted', format: CoreXform.DateFormat}),
'dcterms:created': new DateXform({tag: 'dcterms:created', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat}),
'dcterms:modified': new DateXform({tag: 'dcterms:modified', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat})
}
Expand Down Expand Up @@ -77,6 +78,7 @@ utils.inherits(CoreXform, BaseXform, {
this.map['cp:keywords'].render(xmlStream, model.keywords);
this.map['cp:category'].render(xmlStream, model.category);
this.map['cp:lastModifiedBy'].render(xmlStream, model.lastModifiedBy);
this.map['cp:lastPrinted'].render(xmlStream, model.lastPrinted);
this.map['dcterms:created'].render(xmlStream, model.created);
this.map['dcterms:modified'].render(xmlStream, model.modified);

Expand Down Expand Up @@ -123,6 +125,7 @@ utils.inherits(CoreXform, BaseXform, {
keywords: this.map['cp:keywords'].model,
category: this.map['cp:category'].model,
lastModifiedBy: this.map['cp:lastModifiedBy'].model,
lastPrinted: this.map['cp:lastPrinted'].model,
created: this.map['dcterms:created'].model,
modified: this.map['dcterms:modified'].model
};
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/xlsx/xform/core/core-xform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ var expectations = [
xml: fs.readFileSync(__dirname + '/data/core.02.xml').toString().replace(/\r\n/g, '\n'),
get parsedModel() { return this.preparedModel; },
tests: ['render', 'renderIn', 'parse']
},
{
title: 'core.xml - with cp:lastPrinted',
create: function() { return new CoreXform()},
preparedModel: { creator: 'Guyon Roche', lastModifiedBy: 'Guyon Roche', lastPrinted: new Date('2016-08-16T19:56:07Z'), created: new Date('2016-04-20T16:26:46Z'), modified: new Date('2016-05-12T06:52:49Z')},
xml: fs.readFileSync(__dirname + '/data/core.03.xml').toString().replace(/\r\n/g, '\n'),
get parsedModel() { return this.preparedModel; },
tests: ['render', 'renderIn', 'parse']
}
];

Expand Down
10 changes: 10 additions & 0 deletions spec/unit/xlsx/xform/core/data/core.03.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:creator>Guyon Roche</dc:creator>
<cp:lastModifiedBy>Guyon Roche</cp:lastModifiedBy>
<cp:lastPrinted>2016-08-16T19:56:07Z</cp:lastPrinted>
<dcterms:created xsi:type="dcterms:W3CDTF">2016-04-20T16:26:46Z</dcterms:created>
<dcterms:modified xsi:type="dcterms:W3CDTF">2016-05-12T06:52:49Z</dcterms:modified>
</cp:coreProperties>