mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
* escape strings
* use fluid interface and ' + Add LastModifiedBy + author, company, manager, LastModifiedBy set email
This commit is contained in:
parent
c449813bb1
commit
3646e702ae
19
README.md
19
README.md
@ -144,15 +144,16 @@ $xlsx->rightToLeft();
|
|||||||
|
|
||||||
// Set Meta Data Files
|
// Set Meta Data Files
|
||||||
// this data in propertis Files and Info file in Office
|
// this data in propertis Files and Info file in Office
|
||||||
$xlsx->setAuthor("Sergey Shuchkin")
|
$xlsx->setAuthor('Sergey Shuchkin <sergey.shuchkin@gmail.com>')
|
||||||
$xlsx->setCompany("Sergey Shuchkin Company")
|
->setCompany('Microsoft <info@microsoft.com>')
|
||||||
$xlsx->setManager("Sergey Shuchkin Manager")
|
->setManager('Bill Gates <bill.gates@microsoft.com>')
|
||||||
$xlsx->setTitle("This is Title")
|
->setLastModifiedBy("Sergey Shuchkin <sergey.shuchkin@gmail.com>")
|
||||||
$xlsx->setSubject("This is Subject")
|
->setTitle('This is Title')
|
||||||
$xlsx->setKeywords("Keywords1, Keywords2, Keywords3, KeywordsN")
|
->setSubject('This is Subject')
|
||||||
$xlsx->setDescription("This is Description")
|
->setKeywords('Keywords1, Keywords2, Keywords3, KeywordsN')
|
||||||
$xlsx->setCategory("This is Сategory")
|
->setDescription('This is Description')
|
||||||
$xlsx->setApplication("This Is Best Application For Generate")
|
->setCategory('This is Сategory')
|
||||||
|
->setApplication('Shuchkin\SimpleXLSXGen')
|
||||||
```
|
```
|
||||||
### JS array to Excel (AJAX)
|
### JS array to Excel (AJAX)
|
||||||
```php
|
```php
|
||||||
|
@ -39,6 +39,7 @@ class SimpleXLSXGen
|
|||||||
protected $application;
|
protected $application;
|
||||||
protected $keywords;
|
protected $keywords;
|
||||||
protected $category;
|
protected $category;
|
||||||
|
protected $lastModifiedBy;
|
||||||
const N_NORMAL = 0; // General
|
const N_NORMAL = 0; // General
|
||||||
const N_INT = 1; // 0
|
const N_INT = 1; // 0
|
||||||
const N_DEC = 2; // 0.00
|
const N_DEC = 2; // 0.00
|
||||||
@ -92,12 +93,13 @@ class SimpleXLSXGen
|
|||||||
{
|
{
|
||||||
$this->subject = '';
|
$this->subject = '';
|
||||||
$this->title = '';
|
$this->title = '';
|
||||||
$this->author = 'Sergey Shuchkin';
|
$this->author = 'Sergey Shuchkin <sergey.shuchkin@gmail.com>';
|
||||||
$this->company = 'Sergey Shuchkin';
|
$this->company = 'Sergey Shuchkin <sergey.shuchkin@gmail.com>';
|
||||||
$this->manager = 'Sergey Shuchkin';
|
$this->manager = 'Sergey Shuchkin <sergey.shuchkin@gmail.com>';
|
||||||
$this->description = '';
|
$this->description = '';
|
||||||
$this->keywords = '';
|
$this->keywords = '';
|
||||||
$this->category = '';
|
$this->category = '';
|
||||||
|
$this->lastModifiedBy = 'Sergey Shuchkin <sergey.shuchkin@gmail.com>';
|
||||||
$this->application = __CLASS__;
|
$this->application = __CLASS__;
|
||||||
|
|
||||||
$this->curSheet = -1;
|
$this->curSheet = -1;
|
||||||
@ -160,6 +162,7 @@ class SimpleXLSXGen
|
|||||||
<dc:title>{TITLE}</dc:title>
|
<dc:title>{TITLE}</dc:title>
|
||||||
<dc:subject>{SUBJECT}</dc:subject>
|
<dc:subject>{SUBJECT}</dc:subject>
|
||||||
<dc:creator>{AUTHOR}</dc:creator>
|
<dc:creator>{AUTHOR}</dc:creator>
|
||||||
|
<cp:lastModifiedBy>{LAST_MODIFY_BY}</cp:lastModifiedBy>
|
||||||
<cp:keywords>{KEYWORD}</cp:keywords>
|
<cp:keywords>{KEYWORD}</cp:keywords>
|
||||||
<dc:description>{DESCRIPTION}</dc:description>
|
<dc:description>{DESCRIPTION}</dc:description>
|
||||||
<cp:category>{CATEGORY}</cp:category>
|
<cp:category>{CATEGORY}</cp:category>
|
||||||
@ -342,19 +345,19 @@ class SimpleXLSXGen
|
|||||||
$s .= '<sheet name="' . $this->esc($v['name']) . '" sheetId="' . ($k + 1) . '" r:id="rId' . ($k + 1) . '"/>';
|
$s .= '<sheet name="' . $this->esc($v['name']) . '" sheetId="' . ($k + 1) . '" r:id="rId' . ($k + 1) . '"/>';
|
||||||
}
|
}
|
||||||
$search = ['{SHEETS}', '{APP}'];
|
$search = ['{SHEETS}', '{APP}'];
|
||||||
$replace = [$s, $this->application];
|
$replace = [$s, $this->esc($this->application)];
|
||||||
$template = str_replace($search, $replace, $template);
|
$template = str_replace($search, $replace, $template);
|
||||||
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
||||||
$entries++;
|
$entries++;
|
||||||
} elseif ($cfilename === 'docProps/app.xml') {
|
} elseif ($cfilename === 'docProps/app.xml') {
|
||||||
$search = ['{APP}', '{COMPANY}', '{MANAGER}'];
|
$search = ['{APP}', '{COMPANY}', '{MANAGER}'];
|
||||||
$replace = [$this->application, $this->company, $this->manager];
|
$replace = [$this->esc($this->application), $this->esc($this->company), $this->esc($this->manager)];
|
||||||
$template = str_replace($search, $replace, $template);
|
$template = str_replace($search, $replace, $template);
|
||||||
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
||||||
$entries++;
|
$entries++;
|
||||||
} elseif ($cfilename === 'docProps/core.xml') {
|
} elseif ($cfilename === 'docProps/core.xml') {
|
||||||
$search = ['{DATE}', '{AUTHOR}', '{TITLE}', '{SUBJECT}', '{KEYWORD}', '{DESCRIPTION}', '{CATEGORY}'];
|
$search = ['{DATE}', '{AUTHOR}', '{TITLE}', '{SUBJECT}', '{KEYWORD}', '{DESCRIPTION}', '{CATEGORY}', '{LAST_MODIFY_BY}'];
|
||||||
$replace = [gmdate('Y-m-d\TH:i:s\Z'), $this->author, $this->title, $this->subject, $this->keywords, $this->description, $this->category];
|
$replace = [gmdate('Y-m-d\TH:i:s\Z'), $this->esc($this->author), $this->esc($this->title), $this->esc($this->subject), $this->esc($this->keywords), $this->esc($this->description), $this->esc($this->category), $this->esc($this->lastModifiedBy)];
|
||||||
$template = str_replace($search, $replace, $template);
|
$template = str_replace($search, $replace, $template);
|
||||||
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
$this->_writeEntry($fh, $cdrec, $cfilename, $template);
|
||||||
$entries++;
|
$entries++;
|
||||||
@ -1070,6 +1073,12 @@ class SimpleXLSXGen
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setLastModifiedBy($lastModifiedBy)
|
||||||
|
{
|
||||||
|
$this->lastModifiedBy = $lastModifiedBy;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function autoFilter($range)
|
public function autoFilter($range)
|
||||||
{
|
{
|
||||||
$this->sheets[$this->curSheet]['autofilter'] = $range;
|
$this->sheets[$this->curSheet]['autofilter'] = $range;
|
||||||
|
Loading…
Reference in New Issue
Block a user