JetTableAllClasses
Current view: C:\xampp\htdocs\table\jettable\JetExcelDownload.class.php
Date: Fri Dec 1 17:20:38 JST 2006 Executable lines: 24
Code covered: 8.33% Executed lines: 2
Legend: executed not executed dead code


       1                 : <?php                                                                                     
       2                 : require_once "JetPlugin.class.php";                                                       
       3                 :                                                                                           
       4                 : /**                                                                                       
       5                 :  * Excelダウンロードリンク出力<br>                                                        
       6                 :  * テーブルの内容をExcelファイルとして出力するためのプラグイン。                          
       7                 :  *                                                                                        
       8                 :  * @package    jettable.framework                                                         
       9                 :  * @author     rds <tk@rasign.jp>                                                         
      10                 :  * @license     http://www.opensource.org/licenses/mit-license.php The MIT License        
      11                 :  * @version    $Revision: 1.4 $ $Date: 2006/12/01 13:41:52 $                              
      12                 :  * @link       http://jettable.rasign.jp/                                                 
      13                 :  */                                                                                       
      14                 : class JetExcelDownload extends JetPlugin{                                                 
      15                 :     public function __construct(){                                                           
      16               4 :         $this->key = "excel";                                                                   
      17               4 :     }                                                                                        
      18                 :                                                                                           
      19                 :     public function action($header, $records){                                               
      20               0 :         require_once "Spreadsheet\Excel\Writer.php";                                            
      21                 :                                                                                           
      22               0 :         $workbook = new Spreadsheet_Excel_Writer();                                             
      23               0 :         $worksheet =& $workbook->addWorksheet("list");                                          
      24               0 :         $format =& $workbook->addFormat();                                                      
      25               0 :         $format->_font_name = mb_convert_encoding("sjis", "sjis");                              
      26                 :                                                                                           
      27               0 :         $i = 0;                                                                                 
      28               0 :         foreach($header as $headerKey=>$headerValue){                                           
      29               0 :             $worksheet->write(0, $i, mb_convert_encoding($headerValue, "sjis", "euc-jp"));         
      30               0 :             $i++;                                                                                  
      31               0 :         }                                                                                       
      32                 :                                                                                           
      33               0 :         $i = 1;                                                                                 
      34               0 :         foreach($records as $record){                                                           
      35               0 :             $j = 0;                                                                                
      36               0 :             foreach($header as $headerKey=>$headerValue){                                          
      37               0 :                 $worksheet->write($i, $j, mb_convert_encoding($record[$headerKey], "sjis", "euc-jp"));
      38               0 :                 $j++;                                                                                 
      39               0 :             }                                                                                      
      40               0 :             $i++;                                                                                  
      41               0 :         }                                                                                       
      42                 :                                                                                           
      43               0 :         $workbook->send("list.xls");                                                            
      44               0 :         $workbook->close();                                                                     
      45                 :                                                                                           
      46               0 :         die();                                                                                  
      47                 :     }                                                                                        
      48                 : }                                                                                         
      49                 : ?>                                                                                        

Generated by: PHPUnit 3.0.0 and Xdebug 2.0.0RC1.