diff --git a/CHANGELOG.md b/CHANGELOG.md index 02fef5a..a96f197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## 1.2.15 (2022-07-05) +* added wrap words in long strings `<wraptext>long long line</wraptext>` + ## 1.2.14 (2022-06-10) * added example [JS array to Excel (AJAX)](https://github.com/shuchkin/simplexlsxgen#js-array-to-excel-ajax) diff --git a/README.md b/README.md index 3866efc..c393e3e 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ $data = [ ['Middle + Center', ''], ['Bottom + Right', ''], ['
MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS
', null], + ['Word wrap', "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"] ]; SimpleXLSXGen::fromArray( $data ) ->setDefaultFont( 'Courier New' ) diff --git a/src/SimpleXLSXGen.php b/src/SimpleXLSXGen.php index 7a3b271..ebc54cf 100644 --- a/src/SimpleXLSXGen.php +++ b/src/SimpleXLSXGen.php @@ -50,6 +50,7 @@ class SimpleXLSXGen { const A_TOP = 8; const A_MIDDLE = 16; const A_BOTTOM = 32; + const A_WRAPTEXT = 64; public function __construct() { $this->curSheet = -1; @@ -354,7 +355,8 @@ class SimpleXLSXGen { .($xf[1] & self::A_CENTER ? ' horizontal="center"' : '') .($xf[1] & self::A_TOP ? ' vertical="top"' : '') .($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[] = ' 0 ? ' applyNumberFormat="1"' : '') @@ -557,6 +559,9 @@ class SimpleXLSXGen { if ( strpos( $v, '' ) !== false ) { $A += self::A_BOTTOM; } + if ( strpos( $v, '' ) !== false ) { + $A += self::A_WRAPTEXT; + } if ( preg_match( '/(.*?)<\/a>/i', $v, $m ) ) { $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] : '']; diff --git a/styles.png b/styles.png index da23273..26b8ff4 100644 Binary files a/styles.png and b/styles.png differ