Exporting paginated grid to excel

Hello,
I am trying to export paginated grid to excel.
The export works fine, the only problem is that it is exporting just the rows which are currently loaded (in my case 10 pages, or 200 records).
Is there any way to export all the data at the same time and not just the data which is currently loaded?
Many thanks :slight_smile:
Jelena

Hi,
there is no way to implement it from client side - export script takes only rendered rows so it ignores another pages. But it’s possible to take all data from database (using connector) and call exporting directly - without loading data into browser.
To implement it you may use something like this:

<?php
require("./config.php");
require("./connector/grid_connector.php");
require_once './grid-excel-php/gridExcelGenerator.php';
require_once './grid-excel-php/tcpdf/tcpdf.php';
require_once './grid-excel-php/gridExcelWrapper.php';

$res = mysql_connect($mysql_server, $mysql_user, $mysql_pass);
mysql_select_db($mysql_db, $res);

$grid = new GridConnector($res);
$grid->set_config(new GridConfiguration());

$grid->event->attach("beforeOutput", "export");
$fields = "item_nm,item_cd";
$grid->render_table("grid50", "item_id", $fields);

function export($grid, $out) {
	$xml = simplexml_load_string($out->__toString());
	$excel = new gridExcelGenerator();
	$excel->printGrid($xml);
	die();
}

?>

Please post equivalent code for ASP.NET.

Hi,
unfortunately such functionality is not available for asp.net.

Can you tell how it then is possible to export a grid that is paged to Excel. I have tried using a Connector and ExcelWriter, but with very little documentation is has turned out to be very frustrating.

Can i export paginated grid in excel using java with whole data which is not rendered also??

Hi,
unfortunately there is no way to export the whole grid fomr client side.
But you export it from server side. Here is a code of connector:

GridConnector c = new GridConnector(conn);

GridConfiguration config = new GridConfiguration();
config.addColumn(new GridColumn("ID", "ro", "id", 60, "left", "middle", "str", "", false));
config.addColumn(new GridColumn("First name", "ed", "firstname", 160, "left", "middle", "str", "", false));
config.addColumn(new GridColumn("Last name", "ed", "lastname", 160, "left", "middle", "str", "", false));
c.setConfiguration(config);

c.event.attach(new ExportServiceBehaviour("export url", ExportServiceType.PDF));
c.render_table("grid50000", "item_id", "item_nm,item_cd,item_id");

Be carefull, for such usage case grid must be configured at server side using GridConfiguration.

Hi,

We have implemented to export data to excel but it only exports the records that are displayed in the page. So, to fulfill the full data export we need to implement exactly above. We are on the java application.

Could you please provide the steps on how we can implement it using java application to export the all records from the application server end?

Thanks for all your help !!

-Ed

Just change ExportServiceType.PDF to ExportServiceType.Excel in the above code.