1
0
mirror of https://github.com/shuchkin/simplexlsxgen.git synced 2023-08-10 21:12:59 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Sergey Shuchkin
1c206d06bc 1.1.11 2022-02-12 03:25:59 +06:00
Sergey Shuchkin
f0cbc32af9 1.1.11 2022-02-12 03:04:46 +06:00
3 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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;