Next
Update
Prev
Excel Upload
xlsx xls
Data Only

You can export data to a Excel File and then upload it to the server by using the KoolGrid API, excelExportUpload() and any server-side script (such as ASP, PHP, etc). Click the Export button and check the exported file.

function excelExportUpload() {
  dataGrid.exportOnlyData = inputForm.dataOnly.checked;
  
  for (var i = 0; i < inputForm.export_type.length; i++) {
    if (inputForm.export_type[i].checked) {
      dataGrid.exportType = inputForm.export_type[i].value;
      break;
    }
  }
  dataGrid.exportFileName = "export." + dataGrid.exportType;
  
  gridRoot.addLoadingBar();
  
  gridRoot.excelExportUpload("https://www.koolchart.com/koolgrid/server/uploadExcel.php", false);
}

[uploadExcel.php]
<?php
/*
 * This PHP code is to show how to decode and save the excel file.
*/
  date_default_timezone_set('US/Eastern');
  $data = $_POST['fileData'];
  $fileName = $_POST['fileName'];
  $updir = gethostname () + "/koolgrid/upload/";
  $dt = new DateTime();
	
  $userIp = $_SERVER['SERVER_ADDR'];

  $filename = $userIp . "_" . $dt->format('YmdHis') . "." . $fileName;
	
  $filePath = $_SERVER['DOCUMENT_ROOT'] . "/koolgrid/upload/" . $filename;

  $f = fopen($filePath, "w") or die("Unable to open file!");
  $path = "";

  if ($data != null && strlen($data) > 0) {
    $byteFile = base64_decode($data);
    echo "<SCRIPT> alert( '" . "contents: " . $byteFile . "'); </SCRIPT>";
    fwrite($f, $byteFile);
  }
  fclose($f);
		
  $path = $updir . $filename;
?>

© 2017 KoolChart. All rights reserved.