KoolReport's Forum

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

Export excel question #354

Open Clara Gaudry opened this topic on on Jul 6, 2018 - 5 comments

Clara Gaudry commented on Jul 6, 2018

Hi,

I would like to know if it's possible to export to Excel only one dataStore (if I have several) and how can i do it if it's possible ?

Thanks

KoolReport commented on Jul 6, 2018

You can do so, for example:

->exportToExcel(array("storeName"))
->toBrowser("result.xls");
Clara Gaudry commented on Jul 9, 2018

Hi, It doesn't work, i still have 2 sheets for my 2 dataStores

David Winterburn commented on Jul 9, 2018

Hi Clara,

Would you please post your php code here for us to check for you? Thanks!

Clara Gaudry commented on Jul 9, 2018

MyFile.php :

$this->src('criter')
		
		->query("SELECT
				concat(concat(concat('PTM',p.ptm_id),' : '),p.ptm_lib) PTM,
				p.PTM_ID,
				p.PTM_LIB
			FROM
				cfg_pt_mesure p,
				cfg_arc a
			WHERE
					p.arc_id = a.arc_id (+)
				AND
					a.arc_suppr (+) = 0
				AND
					p.ptm_suppr (+) = 0
				AND 
					PTM_ID<994
				
			order by PTM_ID")

		->pipe(new Map(array(
			'{value}' => function($row, $metaData) {
				$row['PTM'] = (string)$row['PTM'];
				$row['PTM_ID'] = (float)$row['PTM_ID'];
				return array($row);
			}
		)))

		->pipe(new ColumnMeta(array(
			"PTM"=>array(
				'type' => 'string',
			),
			"PTM_ID"=>array(
				'type' => 'number',
			)
		)))
		
		->pipe(new Custom(function($data){
			$data["PTM"] = utf8_encode($data["PTM"]);
			return $data;
			}))
		
		->pipe($this->dataStore('PTM'));

$this->src('criter')
		
		->query("select 
					TO_CHAR(F.MFH_HD, 'DD/MM/YYYY HH24:MI:SS') MFH_HD,
					F.MFH_DEBIT,
					F.MFH_TAUX,
					F.MFH_VITESSE
				from 
					HST_MES_FLUX_HEURE F
				join 
					CFG_PT_MESURE P on F.PTM_ID=P.PTM_ID
				where 
					p.ptm_lib = trim(substr('$ptm_nom',instr('$ptm_nom',':')+1))
				AND 
					f.MFH_hd >= TO_DATE('$date1 $heure1','YYYY/MM/DD HH24:Mi')
				AND 
					f.MFH_hd < TO_DATE('$date2 $heure2','YYYY/MM/DD HH24:Mi')
				order by F.MFH_HD")
		

		->pipe(new Map(array(
			'{value}' => function($row, $metaData) {
				$row['MFH_HD'] = (string)$row['MFH_HD'];
				$row['MFH_DEBIT'] = (float)$row['MFH_DEBIT'];
				$row['MFH_TAUX'] = (float)$row['MFH_TAUX'];
				$row['MFH_VITESSE'] = (float)$row['MFH_VITESSE'];
				return array($row);
			}
		)))

		->pipe(new ColumnMeta(array(
			"MFH_HD"=>array(
				'type' => 'string',
			),
			"MFH_DEBIT"=>array(
				'type' => 'number',
			),
			"MFH_TAUX"=>array(
				'type' => 'number',
			),
			"MFH_VITESSE"=>array(
				'type' => 'number',
			),
		)))
		
		->pipe($this->dataStore('table_horaire'));

myFile_export.php :

<?php
require_once "T1_Comptage_QT_TT.php";


$Comptage_QT_TT = new Comptage_QT_TT;
$Comptage_QT_TT->run()->exportToExcel(array("table_horaire"))->toBrowser("Comptage_QT_TT_VT.xls");
$Comptage_QT_TT->render("T1_Comptage_QT_TT");

Clara Gaudry commented on Jul 11, 2018

Update : I found by myself :

$Comptage_QT_TT = new Comptage_QT_TT ;
$Comptage_QT_TT ->run()->exportToExcel(array(
    "dataStores" => array(
        'table_horaire' => array()
    )
))->toBrowser("Comptage_QT_TT .xls");

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
solved

None