Skip to content

Commit a61510d

Browse files
committed
fix formatting for xls tab name
1 parent 9174c85 commit a61510d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/services/formatting.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ public static function xlsxTabName( string $tabName, string $replacementForIlleg
5555
':',
5656
'?'
5757
];
58-
$correction1 = $forceLowerCase ? strtolower( $tabName ) : $tabName;
59-
$correction2 = str_replace( $illegalChars, $replacementForIllegalChars, $correction1 );
60-
$correction3 = preg_replace( '/(\r\n|\r|\n)+/', ' ', $correction2 );
61-
$correction4 = preg_replace( '/(' . $replacementForIllegalChars . ')+/', ' ', $correction3 );
58+
$correction = $forceLowerCase ? strtolower( $tabName ) : $tabName;
59+
$correction = str_replace( $illegalChars, $replacementForIllegalChars, $correction );
60+
$correction = preg_replace( '/(\r\n|\r|\n)+/', ' ', $correction );
61+
if($replacementForIllegalChars!='') {
62+
$correction = preg_replace( '/(' . $replacementForIllegalChars . ')+/', ' ', $correction );
63+
}
6264

63-
if(strlen($correction4)>31) {
64-
return substr($correction4, 0, 31);
65+
if(strlen($correction)>31) {
66+
return substr($correction, 0, 31);
6567
}
6668

67-
return $correction4;
69+
return $correction;
6870
}
6971

7072

0 commit comments

Comments
 (0)