@@ -11,6 +11,8 @@ class SpreadsheetMLEngine implements EngineInterface {
11
11
12
12
protected $ autoIndex = 1 ;
13
13
14
+ protected ?int $ createdTime = null ;
15
+
14
16
public function processSheet ( DataSheet $ sheet ) : void {
15
17
$ outputStream = fopen ("php://temp " , "r+ " );
16
18
foreach ( $ sheet as $ dataRow ) {
@@ -89,12 +91,12 @@ protected function generateBaseXmlDocument() : string {
89
91
$ workbook ->setAttribute ('xmlns:o ' , 'urn:schemas-microsoft-com:office:office ' );
90
92
$ workbook ->setAttribute ('xmlns:x ' , 'urn:schemas-microsoft-com:office:excel ' );
91
93
$ workbook ->setAttribute ('xmlns:ss ' , 'urn:schemas-microsoft-com:office:spreadsheet ' );
92
- $ workbook ->setAttribute ('xmlns:html ' , 'http://www.w3.org/TR/REC-html40 ' );
94
+ // $workbook->setAttribute('xmlns:html', 'http://www.w3.org/TR/REC-html40');
93
95
$ doc ->appendChild ($ workbook );
94
96
95
97
$ documentProperties = $ doc ->createElement ('DocumentProperties ' );
96
98
$ documentProperties ->setAttribute ('xmlns ' , 'urn:schemas-microsoft-com:office:office ' );
97
- $ documentProperties ->appendChild ($ doc ->createElement ('Created ' , date ('c ' )));
99
+ $ documentProperties ->appendChild ($ doc ->createElement ('Created ' , date ('c ' , $ this -> createdTime ?: time () )));
98
100
$ workbook ->appendChild ($ documentProperties );
99
101
100
102
$ styles = $ doc ->createElement ('Styles ' );
@@ -152,4 +154,11 @@ protected function generateBaseXmlDocument() : string {
152
154
return $ doc ->saveXML ();
153
155
}
154
156
157
+ /**
158
+ * @param int|null $createdTime The timestamp to use for the created time. If null, the current time will be used.
159
+ */
160
+ public function setCreatedTime ( ?int $ createdTime ) : void {
161
+ $ this ->createdTime = $ createdTime ;
162
+ }
163
+
155
164
}
0 commit comments