TwigExcelBundle
TwigExcelBundle copied to clipboard
"Unknown format "html""
Hello, I use sonata with Symfony, but I also tried a route in a controller outside of sonata and the error is the same.
public function reportType2Action(Request $request, $id) {
//...
return $this->render('DataBundle:DataValue:report-type2.xls.twig', array('entities' => $query->getResult()));
}
Template file:
{# DataBundle:DataValue:report-type2.xls.twig #}
{% xlsdocument %}
{% xlssheet 'Worksheet' %}
{% xlsrow %}
{% xlscell %}{% trans %}IA Id{% endtrans %}{% endxlscell %}
{% endxlsrow %}
{% for r in entities %}
{% if r.reference is not empty %}
{% xlsrow %}
{% xlscell %}{{ r.value.evidenceLevel }}{% endxlscell %}
{% endxlsrow %}
{% endif %}
{% endfor %}
{% endxlssheet %}
{% endxlsdocument %}
Somehow, in PhpExcelWrapper.php, startDocument($properties) is called with an empty array instead of [format: 'xls'].
Thank you for your help! Catalin
Found the solution: apparently one has to configure twig like this:
{% xlsdocument {format: 'xls'} %}
If you could make this clearer in the docs it would be great: it isn't intuitive at all from the example in the Getting Started guide.