Exporting to Excel

I have a question about exporting to Excel.

I analized your library and, with satisfaction, i discovered that your solution is based on PHPExcel (one great product united to your great product make a much more great product).
You built two classes, included a wrapper to PHPExcel very easy to use but that are also not very flexible compared to PHPExcel (stand alone).

What i’d like to do is using both the approaches to overcome some problems (for istance: exporting grid with spliAt where the splitted column’s label are not exported, could be solved rewriting the cells in the sheet with the lost labels)

Always analizing your code in “generate.php” i thought to insert commands to write cells immediately after:

$excel = new gridExcelGenerator();
$excel->printGrid($xml);

A this point the function pringtGrid() just called printGridExcel() that just called createXLS() that just opened an istance of PHPExcel() named “excel”
Now the problem is how to refer to PHPExcel Istance. I tried something like that:

$excel->excel->setActiveSheetIndex(0);
$excel->excel->getActiveSheet()->setCellValue('A2,‘COD’);
$excel->excel->getActiveSheet()->setCellValue('B2,‘INTESTAZIONE’);

but it seems not to be correct.

I don’t know PHP very well so probably this is not the correct way to call the PHPExcel istance.

Can you help me ! This is very important because it would be possible change almost everything in the sheet making really good reports.

Many many thanks.

Wow i found the solution and i think it would be useful for other “dhtmlxer”.

In gridExcelGenerator.php I modify the printGridExcel function deleting the last sentence.

$this->wrapper->outXLS($this->title, $this->outputType);

Then i modify Generate.php in this way:

I simply insert command of PHPExcel after:

$excel->printGrid($xml);

$excel->wrapper->excel->setActiveSheetIndex(0);
$excel->wrapper->excel->getActiveSheet()->setCellValue(‘A2’, ‘COD’);
$excel->wrapper->excel->getActiveSheet()->setCellValue(‘B2’, ‘INTESTAZIONE’);

Now i simply call the command that i deleted from printGridExcel:

$excel->wrapper->outXLS($execel->title, $excel->outputType);

And all runs great. In this way you open the door to every change that you want to do on Sheet before the final render.

Help Help !

There is another strange problem that non depends on my modification described before because i deleted them to solve the problem.

Also with the original script Generate.php export runs correctly only for maximum 25 rows. After that seems looping without opening Excel and doesn’t produce the debug xml file. ??

Are there some limitations to the exported rows ? It looks strange.

Thanks.

As well for me, when I’m exporting to excel using PHP, it is really, really, really slow… Even sometimes it kills the PHP proccess… I’m trying to export around 1700 rows ( what it has to be said, it is not that much ) and major times it can’t be done…
I’m doing a exporter my myself cause the grids on is not that good. I’ve already tried in a lot of servers…

Hi,
sorry for the delay in answerring.
Unfortunately export to excel is too slow to export big datasets. The first step is to enable more resources in server configurations: available memory and maximum execution time.
You may also try to use export to HTML (it’s similar to excel and may be opened by excel, but it’s html-table format, not real excel) instead of export to excel.
grid-html-php.zip (2.25 KB)

Hi Radyno and thanks

I tried html and after a lot of experiments increasing memory and max_execution_time i reach the goal to export over 1.000 rows but not always. In the page i use both Excel an Pdf Export. Trying to export 1.280 rows to Excel-html it doesn’t run the first time, but if before i export to pdf and then to Excel this time it runs. Quite strange isn’t it ? I dont undertstand this behaviour as they are two different calls to different functions.

Another question. I don’t understand why grid-excel-php has so small limitations on exporting. In my grid i reach only 25 rows exported. But Why ? Excel 2007 could list over 500.000 rows.
I tried also to increase memory abd max_execution_time but nothing has changed.

I read also about PHPExcel library but also here there are no notice of this limitations. It’s a real pity because exporting to Excel is more flexible united to PHPExcel.

Thanks

Hi,
if you have troubles in exporting big dataset with grid-html-php then please, provide complete demo.
PHPExcel requires a lot of resources to process big datasets. Unfortunately it can’t produce XLS with a lot of data. Number of exported rows may be different and depends of server configurations (available memory, execution time, etc) and number of columns.

OK but in your opinion it would be possible, after exporting through grid-html-php, processing the sheet through PHPExcel to modify and format correctly the sheet, before show it (printGrid) ? If Yes how and where in generate.php or in gridHTMLGenerator.php.

Thanks.

P.S. About grid-excel-php what do you mean for big dataset ? 25 rows even if with 30/40 column doesnt’ seem to be a big dataset ?!?

Dear,

I’m trying to export 30 thousand lines, now using grid_html_php, but comes on line 6829 the following error occurs:

Warning: Invalid argument supplied for foreach() in E:\web\apache\htdocs\brasa\include\dhtmlxGrid\dhtmlxGrid\codebase\grid-html-php\gridHTMLGenerator.php on line 72
Warning: Invalid argument supplied for foreach() in

E:\web\apache\htdocs\brasa\include\dhtmlxGrid\dhtmlxGrid\codebase\grid-html-php\gridHTMLGenerator.php on line 159

Hi,

No, there is no way to do it.

I agree, it’s not so much data, but unfortunately PHPExcel is not optimized to export such dataset.

rodrigo_hostplan, provide a complete demo, please.