PlatinumGrid
develop faster.

PlatinumGrid has an extremely simple and flexible API. This allows developers to begin using PlatinumGrid very quickly, and allows them to access even advanced features with ease. This page demonstrates this easy-to-use API.

PlatinumGrid ships with over 30 examples covering virtually all features of the grid, that provide a simple and effective way of showing how to use the API. We've taken a few of these examples to convey some idea of the simplicity of using PlatinumGrid in any PHP application.

Note. For applications written using RadPHP, PlatinumGrid is a drag-and-drop component with complete integration into the RPCL. This page is intended for the developers who do not use RadPHP.

Exporting:
PlatinumGrid supports exporting grid results into PDF, XLS or CSV. It ships with all the necessary libraries to perform the export. Exporting is as simple as calling a particular method on the grid, as this example demonstrates.
<?php
require_once( '../vcl/platinumgrid/lib/Spreadsheet_Excel_Writer.php' );
require_once( 
'../vcl/platinumgrid/lib/tcpdf/tcpdf.php' );
require_once( 
'../grid.inc.php' );

$dbConnection mysql_connect'localhost''root''' );

mysql_select_db'gridsamples'$dbConnection );

$dataSource = new MySQLDatasource$dbConnection );
$dataSource->DataSet->TableName 'employeestiny';
$dataSource->DataSet->Open();

// Construct the grid.
$grid = new JTPlatinumGrid();
$grid->Datasource $dataSource;
$grid->Height '';
$grid->SiteTheme->Theme 'default';

$textCol = new JTPlatinumGridTextColumn$grid );
$textCol->Caption 'First Name';
$textCol->DataField 'FirstName';
$textCol->Name 'FirstNameCol';

$dateCol = new JTPlatinumGridDateTimeColumn$grid );
$dateCol->Caption 'Date';
$dateCol->DataField 'DateCol';
$dateCol->Display JTPlatinumGridDateTimeColumn::DateOnly;
$dateCol->Name 'DateCol';

$grid->Columns = array( $textCol$dateCol );

$grid->init();

if( isset( 
$_POST'export' ] ) )
{
    
// Check which export button was pressed.
    
switch( $_POST'export' ] )
    {
        case 
'PDF':
            
$grid->exportGridToPDFDownload'demoexport.pdf' );
            break;

        case 
'CSV':
            
$grid->exportGridToCSVDownload'demoexport.csv' );
            break;

        case 
'XLS':
            
$grid->exportGridToXLSDownload'demoexport.xls' );
            break;
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Basic Export Demo</title>
<?php
$grid
->dumpHeaderCode();
?>
</head>
<body>
  <h1>Basic Export Demo</h1>
  <form action="" method="post">
    <div id="<?php echo( $grid->Name ); ?>_outer">
<?php $grid->dumpContents(); ?>
    </div>
    <p>
      Export:<br />
      <input type="submit" name="export" value="PDF" />
      <input type="submit" name="export" value="CSV" />
      <input type="submit" name="export" value="XLS" />
    </p>
  </form>
</body>
</html>