KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

EXPORT TO EXCEL #882

Closed SOFMAN opened this topic on on May 21, 2019 - 6 comments

SOFMAN commented on May 21, 2019

I need to export 12 columns to excel but it is not exported correctly The query is the following

$consultaSQLExcel = "select codigo_item as 'CODIGO ITEM', nombre_item as ITEM, numero_serie as 'NUMERO SERIE',   tipo_doc_mov_serie_item as  'TIPO DE DOCUMENTO', numero_documento as 'NUMERO DOCUMENTO', nombre_bodega as  BODEGA, disponibilidad_item_serie as DISPONIBILIDAD, integridad_item_serie as INTEGRIDAD, razon_social_cliente   as CLIENTE, razon_social_proveedor as PROVEEDOR, nombres_usuario as 'CREADO POR',fecha_hora_creacion_ultimo_movimiento   as 'FECHA CREACION' from series_items_inventario where contribuyente=" . $idContribuyente;
$this->src('mysql')  ->query($consultaSQLExcel)  ->pipe($this->dataStore('seriesItems'));

In the view

\koolreport\excel\Table::create(array(
        "dataSource" => $this->dataStore("seriesItems"),
));

David Winterburn commented on May 24, 2019

Hi,

Would you please post your export function's php code? Thanks!

SOFMAN commented on May 24, 2019

The code is the following

public function exportExcel()
    {      
        $report = new ReportSeriesItems();
        $report->exportExcel();
        $report->run()->exportToExcel('ReportSeriesItemsExport')
            ->toBrowser("ReportSeriesItemsExport.xlsx");
    }

The code of the ReportSeriesItems class is

 function exportExcel()
    {
$consultaSQLExcel = "select codigo_item as 'CODIGO ITEM', nombre_item as ITEM, numero_serie as 'NUMERO SERIE',   tipo_doc_mov_serie_item as  'TIPO DE DOCUMENTO', numero_documento as 'NUMERO DOCUMENTO', nombre_bodega as  BODEGA, disponibilidad_item_serie as DISPONIBILIDAD, integridad_item_serie as INTEGRIDAD, razon_social_cliente   as CLIENTE, razon_social_proveedor as PROVEEDOR, nombres_usuario as 'CREADO POR',fecha_hora_creacion_ultimo_movimiento   as 'FECHA CREACION' from series_items_inventario where contribuyente=" . $idContribuyente;
$this->src('mysql')  ->query($consultaSQLExcel)  ->pipe($this->dataStore('seriesItems'));
    }

And finally the code of the view that I want to export (ReportSeriesItemsExport.excel.phpl)

<?php

$sheet1 = "SERIES ITEMS";
?>
<div sheet-name="<?php echo $sheet1; ?>">
    <div>
        <?php
            \koolreport\excel\Table::create(array(
                "dataSource" => $this->dataStore("seriesItems"),
            ));
        ?>
    </div>
</div>

NOTE: I have tried with 5 columns and if it works when exporting but with 12 columns it does not work.

SOFMAN commented on Jun 3, 2019

KoolReport support if you are able to help me please answer the forum.

David Winterburn commented on Jun 4, 2019

Hi,

In your export template file please try this command instead to see if it makes difference:

\koolreport\excel\Table::create(array(
                "dataSource" => "seriesItems",
            ));

Let us know the result (screenshot or error message if possible). Thanks!

SOFMAN commented on Jun 12, 2019

Yes, it worked, but why?

David Winterburn commented on Jun 13, 2019

We have 2 ways to define an excel table's datasource using either a datastore directly or its name. It should work either way with the latest Excel package. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None