KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

EXPORT TO EXCEL #882

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

SOFMAN commented on May 21

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

Hi,

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

SOFMAN commented on May 24

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

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

David Winterburn commented on Jun 4

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

Yes, it worked, but why?

David Winterburn commented on Jun 13

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!

Give tips to supporter for his good work

If you feel that supporter has done a good work, consider giving him some credit. Any amount put into the tips box below is appreciated. By doing so, you have contribtuted to the existence of KoolReport and the quality of support.

Tips box
None yet

None