Source for file OCSP_FRMVIEW_PEAR_DATAGRID.phpclass

Documentation is available at OCSP_FRMVIEW_PEAR_DATAGRID.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file OCSP_FRMVIEW_PEAR_DATAGRID.phpclass
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package default
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-27.11.2008
  12.   * @version $Id: OCSP_FRMVIEW_PEAR_DATAGRID.phpclass,v 1.3 2008/12/06 11:22:01 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------
  18.  
  19.     pcf_require_class('OCSP_FRMVIEW_LIST',dirname(__FILE___OCSP_DIRSEP_ "OCSP_FRMVIEW_LIST.phpclass");
  20.  
  21.  
  22. /**
  23.   * openCSP class OCSP_FRMVIEW_PEAR_DATAGRID
  24.   *
  25.   * @project Open CSP-Management
  26.   * @package default
  27.   *
  28.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  29.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since pk-27.11.2008
  32.   * @version $Id: OCSP_FRMVIEW_PEAR_DATAGRID.phpclass,v 1.3 2008/12/06 11:22:01 pitlinz Exp $
  33.   */
  34. {
  35.     // ---------------------------------------------------------------------------
  36.     // constants
  37.     // ---------------------------------------------------------------------------
  38.     
  39.     /**
  40.      * @constant string CLASS_SRC_FILE
  41.      */
  42.     const CLASS_SRC_FILE = __FILE__;
  43.  
  44.     // ---------------------------------------------------------------------------
  45.     // class (static)
  46.     // ---------------------------------------------------------------------------
  47.     
  48.     /*** class vars ------------------------------------------------------ */
  49.     
  50.     /*** class methods --------------------------------------------------- */
  51.     
  52.     // ---------------------------------------------------------------------------
  53.     // object vars
  54.     // ---------------------------------------------------------------------------
  55.     
  56.     /*** compostion --------------------------------------------------- */
  57.     
  58.     /*** attributes  -------------------------------------------------- */
  59.     
  60.     protected $myExcelWorkBench = Null;
  61.     
  62.     // ---------------------------------------------------------------------------
  63.     // factory / construct
  64.     // ---------------------------------------------------------------------------
  65.     
  66.     // ---------------------------------------------------------------------------
  67.     // getter / setter
  68.     // ---------------------------------------------------------------------------    
  69.  
  70.     
  71.     public function getExcel($fileName="export.xls")
  72.     {
  73.         if (!class_exists('Spreadsheet_Excel_Writer'))
  74.         {
  75.             require_once "Spreadsheet/Excel/Writer.php";
  76.         }
  77.         
  78.         set_time_limit(60*5);
  79.         
  80.         // Create a workbook        
  81.         $this->myExcelWorkBench = new Spreadsheet_Excel_Writer();
  82.  
  83.         // Specify avoid tmpfile error
  84.         $this->myExcelWorkBench->setTempDir(OCSP_CONF::getInstance()->getValue('TMPPATH'));
  85.                 
  86.         // Specify that spreadsheet must be sent the browser
  87.         $this->myExcelWorkBench->send($fileName);
  88.                 
  89.         // Create your format
  90.         $format_bold =$this->myExcelWorkBench->addFormat();
  91.         $format_bold->setBold();
  92.  
  93.         // Fill the workbook, passing the format as an option
  94.         $options array(
  95.                 'headerFormat'     => &$format_bold,
  96.                 'tempDir'           => OCSP_CONF::getInstance()->getValue('TMPPATH'),
  97.                 'filename'           => $fileName,
  98.                 'sendToBrowser'    => True,
  99.                 'encoding'      => 'ISO-8859-15'
  100.             );
  101.         
  102.         
  103.         $obj_dataGrid $this->getMyForm()->getControl()->getDataGrid($debug);
  104.         
  105.         if ($debugechoDebugLine(__FILE__,__LINE__,"DataGrid: " get_class($obj_dataGrid));
  106.         $obj_dataGrid->setRenderer('XLS',$options);
  107.         $obj_dataGrid->fill(&$this->myExcelWorkBench,$options);
  108.         $obj_dataGrid->render();
  109.         
  110.  
  111.         
  112.         
  113.     }
  114. }
  115.  
  116. ?>

Documentation generated on Thu, 08 Jan 2009 17:46:39 +0100 by phpDocumentor 1.4.0a2