mewesk / twigspreadsheetbundle Goto Github PK
View Code? Open in Web Editor NEWThis Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
License: MIT License
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
License: MIT License
Any chance this bundle can be upgraded to the latest release of phpoffice/spreadsheet (currently 1.2) ?
From https://github.com/PHPOffice/PhpSpreadsheet/releases it appears the transition from 1.0.0-beta2 to 1.2.0 only has one breaking change:
BREAKING CHANGE
Constant TYPE_DOUGHTNUTCHART is now TYPE_DOUGHNUTCHART.
This twig integration looks to be super useful but the beta dependency is a deal breaker for me.
Hey,
Is there any parameter to set CSV separator (to semicolon, for example) ?
Thanks !
There is an include error, may be because an older version, in file: src/Wrapper/SheetWrapper.php
On line 6, there is a use PhpOffice\PhpSpreadsheet\Worksheet
But It has to be PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
It would be very convenient to have a function that returns the current row index.
When using this function the coordinates of images and merges don't have to be changed manually when lines are added or removed.
The commit df1eb8b will implement this function
There is a problem with function definition in SyntaxCheckNodeVisitor, line 53:
protected function doLeaveNode(\Twig_Node $node, \ Twig_Environment $env)
.
It appeared to me when I tried to update my project to PHP8, so this can be only PHP8-related issue.
I got an error when using this bundle with PHP 7.3:
An exception has been thrown during the rendering of a template ("Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?").
The exception is caused from:
in \vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php (line 323)
I think it should be
continue 2;
On src/Wrapper/DocumentWrapper.php:120 you check $this->attributes['preCalculateFormulas'] but actually in the __constructor of the class that attribute (fetched from mewes_k_twig_spreadsheet.yaml) is saved with the key 'pre_calculate_formulas' in snake_case and not in pascalCase.
I am using "mewesk/twig-spreadsheet-bundle": "^1.0" and "symfony/framework-bundle": "^4.1", I don't know if the way symfony pass this attribute has changed through versions but for sure you should able to reproduce the error and check by yourself. I didn't make a PR 'cause I don't know how you prefer to fix this (assuming that this feature has worked in the past and you don't want to break compatibility).
Cheers!
I prepared an example:
{% xlsdocument {format: 'xlsx'} %}
{% set title = 'test' %}
{% set style = {columnDimension: {'B': {autoSize: true},'C': {autoSize: true},'D': {autoSize: true},'E': {autoSize: true}}} %}
{% xlssheet title style %}
{% endxlssheet %}
{% endxlsdocument %}
What happened: Too many parameters in "data_storage/export.xls.twig"
What I expected: That this call works.
I traced it back to the behaviour of the BaseTokenParser regarding TwigNodeExpressionName. Although style contains an array the type is TwigNodeExpressionName this leads to the base token parser recognizing it as a value type and not as an array.
The following code is responsible for this:
switch ($parameterOptions['type']) {
case self::PARAMETER_TYPE_ARRAY:
// check if expression is valid array
$valid = $expression instanceof \Twig_Node_Expression_Array;
break;
case self::PARAMETER_TYPE_VALUE:
// check if expression is valid value
$valid = !($expression instanceof \Twig_Node_Expression_Array);
break;
default:
throw new \InvalidArgumentException('Invalid parameter type');
}
I'm currently using a workaround with:
switch ($parameterOptions['type']) {
case self::PARAMETER_TYPE_ARRAY:
// check if expression is valid array
$valid = $expression instanceof \Twig_Node_Expression_Array || $expression instanceof \Twig_Node_Expression_Name;
break;
case self::PARAMETER_TYPE_VALUE:
// check if expression is valid value
$valid = !($expression instanceof \Twig_Node_Expression_Array) || $expression instanceof \Twig_Node_Expression_Name;
break;
default:
throw new \InvalidArgumentException('Invalid parameter type');
}
It's necessary to update phpoffice/phpspreadsheet because of CVE-2018-19277
See PHPOffice/PhpSpreadsheet#771
Any plans to release an updated version of this bundle soon?
Any plan to update phpoffice/phpspreadsheet to a version > 1.15 due to security reasons. Please refer to:
https://packagist.org/packages/phpoffice/phpspreadsheet/advisories?version=3070847
Here is the code I'm using, but it's not working (alignment works, not the borders)
{% set style = {
alignment : {
horizontal: 'center'
},
borders: {
bottom: {
style: 'thin',
color: {
rgb: '000000'
}
}
}
}
%}
{% xlscell { style: style } %}Date{% endxlscell %}
Hi,
At first, thanks a lot you this bundle !
Is there any configuration in order to set charset ? I have some issues with accented characters, which come differently up to output format.
Thanks !
For now symfony as dependency is limited to versions ~3.2|~4.0
Hi,
i have a problem with {columnDimension: {default: {autoSize: true}}} of a xlssheet if the first xlsrow has only merged xlscells. The determination of the columsn doesn't work properly, because only the merged cell is recognized. I think it would be better, if in this case more then the first row is used to set the columnDimension for the defined/existing columns.
When using the xlsdrawing tag with an image path e.g. {% xlsdrawing 'directory/image.png' %}
The following exception is thrown:
An exception has been thrown during the rendering of a template ("Failed to create ""/tmp/symfony/cache/dev/spreadsheet/bitmap"": mkdir(): Input/output error.").
This is causes because the default value of the bitmap directory is surrounded with double quotes.
Removing these quotes (and clearing the cache) will solve this problem
I use your bundle with DrawingWrapper tag to export products and their pictures (they are on the CDN). When the url of the picture is invalid, The following exception is thrown:
An exception has been thrown during the rendering of a template ("Warning: file_get_contents(https://gd3.alicdn.com/imgextra/i1/1741453808/TB20GGrIXmWBuNjSspdXXbugXXa_!!1741453808.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found ").
This is causes because the url is not founded.
It may be a good idea to ignore URLs (keep blank cell) that could not save data or make it manageable (for example, passing a flag to throw or not throw an error)? Because now I have to pre-test the url for validity.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.