By using external grid-to-pdf and grid-to-excel services, it possible to convert data of grid to PDF or Excel directly on server side. It can be used to export data from any table to PDF or Excel, without actually rendering data in the grid.
Data part of exported part is defined by render command, header part of data is defined by GridConfiguration - same as for normal grid.
<?php require("../../../codebase/grid_connector.php"); require("../../../codebase/convert.php"); //url to data conversion service $convert = new ConvertService("http://dhtmlx.com/docs/products/devExchange/samples/grid2pdf_02/server/generate.php"); $grid = new GridConnector($res); $grid->set_config(new GridConfiguration()); //mandatory $grid->render_table("grid50"); //table name and optional list of fields ?>
require_once("../../config.php"); $res=mysql_connect($mysql_server,$mysql_user,$mysql_pass); mysql_select_db($mysql_db); require("../../../codebase/grid_connector.php"); require("../../../codebase/convert.php"); //url to data conversion service $convert = new ConvertService("http://dhtmlx.com/docs/products/devExchange/samples/grid2excel_02/server/generate.php"); $convert->excel(); $grid = new GridConnector($res); $grid->set_config(new GridConfiguration()); //mandatory $grid->render_table("grid50"); //table name and optional list of fields
ConvertService has two public methods, which allows to define type of conversion and name of result file
$grid->pdf("some.pdf",false);
or
$grid->excel("some.xls",false);
Second parameter of command controls how file will be delivered