How can I enable export buttons in the source code below?
<?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
//include("../../Resources/runexample.php");
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
/*
$dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));*/
/*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/
//Getting MSSQL Database Credential from database.
$myServer = "win-oloebbm0t2n\intelliti";
$myUser = 'sa';
$myPass = 'INTELLITI';
$myDB = 'IOCP';
//connection to the database
$connectionOptions = array("Database"=>$myDB,"UID"=>$myUser, "PWD"=>$myPass);
//Creating Connection Object.
$db_con = sqlsrv_connect( $myServer, $connectionOptions);
//Checking Connectioin Object Status
if( $db_con === false ) die( print_r( sqlsrv_errors() ) );
else echo $db_con;
$ds = new SQLSRVPivotDataSource($db_con);
//$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
//$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO")
// ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA");
$ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO")
->from("DM_ESTRUTURA_MERCADOLOGICA");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = "Office2007";
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$pivot->Width = "1400px";
$pivot->HorizontalScrolling = true;
//Set the Height of pivot and use Vertical Scrolling
$pivot->Height = "700px";
$pivot->VerticalScrolling = true;
//Allow filtering
$pivot->AllowFiltering = true;
//Allow sorting
$pivot->AllowSorting = true;
//Allow reordering
$pivot->AllowReorder = true;
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("PRECO_VENDA");
$field->DecimalNumber = 2;
$field->Text = "Preço de Venda (Soma)";
//$field->FormatString = "\${n}";
$field->FormatString = "R$ {n}"; //For example
$field->DecimalPoint = ",";
$field->ThousandSeperate = ".";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotAverageField("PRECO_VENDA");
$field->DecimalNumber = 2;
$field->Text = "Preço de Venda - Medio";
$field->FormatString = "R$ {n}"; //For example
$field->DecimalPoint = ",";
$field->ThousandSeperate = ".";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotSumField("PRECO_CUSTO");
$field->DecimalNumber = 2;
$field->Text = "Preço de Custo (Soma)";
$field->FormatString = "R$ {n}"; //For example
$field->DecimalPoint = ",";
$field->ThousandSeperate = ".";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotAverageField("PRECO_CUSTO");
$field->DecimalNumber = 2;
$field->Text = "Preço de Custo - Medio";
$field->FormatString = "R$ {n}"; //For example
$field->DecimalPoint = ",";
$field->ThousandSeperate = ".";
$field->AllowReorder = false;
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("CANAL");
$field->Text = "Canal de Vendas";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("NEM01");
$field->Text = "Hierarquia Nível 01";
$pivot->AddColumnField($field);
$field = new PivotField("NEM02");
$field->Text = "Hierarquia Nível 02";
$pivot->AddColumnField($field);
$field = new PivotField("NEM03");
$field->Text = "Hierarquia Nível 03";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
<!DOCTYPE>
<html>
<head>
<title>Intelliti Analytics for Retail</title>
</head>
<img src="intelliti mini t.png" vspace="10px" hspace="15px" border="0px" align="top"/>
<body>
<font color="#23238E" size="5px"><right>IOCP - Indicadores Médios dos Nós da Estrutura Mercadológica</font></right>
<form id="form1" method="post">
<?php echo $koolajax->Render(); ?>
<?php echo $pivot->Render();?>
</form>
</body>
</html>