1
0
mirror of https://github.com/shuchkin/simplexlsxgen.git synced 2023-08-10 21:12:59 +03:00
This commit is contained in:
Sergey Shuchkin 2022-07-05 11:19:42 +06:00
parent 0bf38275d7
commit f74163d311
4 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,7 @@
# Changelog # Changelog
## 1.2.15 (2022-07-05)
* added wrap words in long strings `<wraptext>long long line</wraptext>`
## 1.2.14 (2022-06-10) ## 1.2.14 (2022-06-10)
* added example [JS array to Excel (AJAX)](https://github.com/shuchkin/simplexlsxgen#js-array-to-excel-ajax) * added example [JS array to Excel (AJAX)](https://github.com/shuchkin/simplexlsxgen#js-array-to-excel-ajax)

View File

@ -75,6 +75,7 @@ $data = [
['Middle + Center', '<style height="50"><middle><center>Middle + Center</center></middle></style>'], ['Middle + Center', '<style height="50"><middle><center>Middle + Center</center></middle></style>'],
['Bottom + Right', '<style height="50"><bottom><right>Bottom + Right</right></bottom></style>'], ['Bottom + Right', '<style height="50"><bottom><right>Bottom + Right</right></bottom></style>'],
['<center>MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS</center>', null], ['<center>MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS</center>', null],
['<top>Word wrap</top>', "<wraptext>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</wraptext>"]
]; ];
SimpleXLSXGen::fromArray( $data ) SimpleXLSXGen::fromArray( $data )
->setDefaultFont( 'Courier New' ) ->setDefaultFont( 'Courier New' )

View File

@ -50,6 +50,7 @@ class SimpleXLSXGen {
const A_TOP = 8; const A_TOP = 8;
const A_MIDDLE = 16; const A_MIDDLE = 16;
const A_BOTTOM = 32; const A_BOTTOM = 32;
const A_WRAPTEXT = 64;
public function __construct() { public function __construct() {
$this->curSheet = -1; $this->curSheet = -1;
@ -354,7 +355,8 @@ class SimpleXLSXGen {
.($xf[1] & self::A_CENTER ? ' horizontal="center"' : '') .($xf[1] & self::A_CENTER ? ' horizontal="center"' : '')
.($xf[1] & self::A_TOP ? ' vertical="top"' : '') .($xf[1] & self::A_TOP ? ' vertical="top"' : '')
.($xf[1] & self::A_MIDDLE ? ' vertical="center"' : '') .($xf[1] & self::A_MIDDLE ? ' vertical="center"' : '')
.($xf[1] & self::A_BOTTOM ? ' vertical="bottom"' : ''); .($xf[1] & self::A_BOTTOM ? ' vertical="bottom"' : '')
.($xf[1] & self::A_WRAPTEXT ? ' wrapText="1"' : '');
$XF[] = '<xf numFmtId="'.$xf[0].'" fontId="'.$F_ID.'" fillId="'.$FL_ID.'" borderId="0" xfId="0"' $XF[] = '<xf numFmtId="'.$xf[0].'" fontId="'.$F_ID.'" fillId="'.$FL_ID.'" borderId="0" xfId="0"'
.($xf[0] > 0 ? ' applyNumberFormat="1"' : '') .($xf[0] > 0 ? ' applyNumberFormat="1"' : '')
@ -557,6 +559,9 @@ class SimpleXLSXGen {
if ( strpos( $v, '<bottom>' ) !== false ) { if ( strpos( $v, '<bottom>' ) !== false ) {
$A += self::A_BOTTOM; $A += self::A_BOTTOM;
} }
if ( strpos( $v, '<wraptext>' ) !== false ) {
$A += self::A_WRAPTEXT;
}
if ( preg_match( '/<a href="(https?:\/\/[^"]+)">(.*?)<\/a>/i', $v, $m ) ) { if ( preg_match( '/<a href="(https?:\/\/[^"]+)">(.*?)<\/a>/i', $v, $m ) ) {
$h = explode( '#', $m[1] ); $h = explode( '#', $m[1] );
$this->sheets[ $idx ]['hyperlinks'][] = ['ID' => 'rId' . ( count( $this->sheets[ $idx ]['hyperlinks'] ) + 1 ), 'R' => $cname, 'H' => $h[0], 'L' => isset( $h[1] ) ? $h[1] : '']; $this->sheets[ $idx ]['hyperlinks'][] = ['ID' => 'rId' . ( count( $this->sheets[ $idx ]['hyperlinks'] ) + 1 ), 'R' => $cname, 'H' => $h[0], 'L' => isset( $h[1] ) ? $h[1] : ''];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 40 KiB