mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
1.0.20
This commit is contained in:
parent
5b58103e3b
commit
7f5c584772
@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.20 (2021-07-29)
|
||||
|
||||
* Fixed sheet names duplicates (Page, Page (1), Page (2)...)
|
||||
|
||||
## 1.0.19 (2021-07-28)
|
||||
|
||||
* Fixed sheet names duplicates
|
||||
|
@ -115,17 +115,26 @@ class SimpleXLSXGen {
|
||||
}
|
||||
|
||||
public function addSheet( array $rows, $name = null ) {
|
||||
$this->curSheet++;
|
||||
|
||||
if ( $name !== null ) {
|
||||
$this->curSheet++;
|
||||
if ( $name === null ) { // autogenerated sheet names
|
||||
$name = 'Sheet'.($this->curSheet+1);
|
||||
} else {
|
||||
$names = [];
|
||||
foreach( $this->sheets as $sh ) {
|
||||
if ( $name === $sh['name'] ) {
|
||||
$name .= ' ' . mt_rand( 100000, 999999 );
|
||||
$names[ strtoupper( $sh['name']) ] = 1;
|
||||
}
|
||||
for( $i = 0; $i < 100; $i++ ) {
|
||||
$new_name = ($i === 0) ? $name : $name .' ('.$i.')';
|
||||
$NEW_NAME = strtoupper( $new_name );
|
||||
if ( !isset( $names[ $NEW_NAME ]) ) {
|
||||
$name = $new_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->sheets[$this->curSheet] = ['name' => $name ?: 'Sheet'.($this->curSheet+1), 'hyperlinks' => []];
|
||||
$this->sheets[$this->curSheet] = ['name' => $name, 'hyperlinks' => []];
|
||||
|
||||
if ( is_array( $rows ) && isset( $rows[0] ) && is_array($rows[0]) ) {
|
||||
$this->sheets[$this->curSheet]['rows'] = $rows;
|
||||
|
Loading…
Reference in New Issue
Block a user