mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
Compare commits
2 Commits
121f1222c2
...
1c206d06bc
Author | SHA1 | Date | |
---|---|---|---|
|
1c206d06bc | ||
|
f0cbc32af9 |
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 1.1.11 (2022-02-05)
|
||||
* sheet name maximum length is 31 chars, mb_substr used now
|
||||
* license fixed
|
||||
|
||||
## 1.1.10 (2022-02-05)
|
||||
* namespace added, use Shuchkin\SimpleXLSXGen
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Lukas Martinelli
|
||||
Copyright (c) 2020-2022 Sergey Shuchkin sergey.shuchkin@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -120,12 +120,17 @@ class SimpleXLSXGen {
|
|||
if ( $name === null ) { // autogenerated sheet names
|
||||
$name = 'Sheet'.($this->curSheet+1);
|
||||
} else {
|
||||
$name = mb_substr($name, 0, 31);
|
||||
$names = [];
|
||||
foreach( $this->sheets as $sh ) {
|
||||
$names[ mb_strtoupper( $sh['name']) ] = 1;
|
||||
}
|
||||
for( $i = 0; $i < 100; $i++ ) {
|
||||
$new_name = ($i === 0) ? $name : $name .' ('.$i.')';
|
||||
$postfix = ' ('.$i.')';
|
||||
$new_name = ($i === 0) ? $name : $name . $postfix;
|
||||
if (mb_strlen($new_name) > 31) {
|
||||
$new_name = mb_substr($name,0, 31-mb_strlen($postfix)) . $postfix;
|
||||
}
|
||||
$NEW_NAME = mb_strtoupper( $new_name );
|
||||
if ( !isset( $names[ $NEW_NAME ]) ) {
|
||||
$name = $new_name;
|
||||
|
|
Loading…
Reference in New Issue
Block a user