コード例 #1
0
ファイル: Model.php プロジェクト: serega011/izumrud
  public function generateOutput() {
   $xls = $this->loadXls(getCacheDir()."template.xls");
   $colCount = PHPExcel_Cell::columnIndexFromString($xls->getHighestColumn());
   $rowCount = $xls->getHighestRow();
   
//   echo ("Cols: ".$colCount.", rows: ".$rowCount.".<br>");
   
   $IDs = getFromCache('ids');
   
   $filename        = getCacheDir()."result.xls";
   $filename_client = getrootdir().getCacheSubdir()."result.xls";
   
   $output = new PHPExcel;                               // Create new PHPExcel object
   $output->getProperties()->setCreator("CF")
          ->setLastModifiedBy("CF")
          ->setTitle("Office 2007 XLS Test Document")
          ->setSubject("Office 2007 XLS Test Document")
          ->setDescription("Test document for Office 2007 XLS, generated using PHP classes.")
          ->setKeywords("CF")
          ->setCategory("Test result file");
   
   $i = 0;
   $n = 1;
   
   $srcrow = array();
   
   for ($col=0; $col<$colCount; $col++) {
    $output->setActiveSheetIndex(0)->setCellValueByColumnAndRow($col, 1, $xls->getCellByColumnAndRow($col,1)->getValue());
    $srcrow[] = $xls->getCellByColumnAndRow($col,2)->getValue();
   }
   
   $colnames = getColNames();
   
   $i=2;
   
   foreach ($IDs as $id) {
    $col=0;
    
    $thisrecord = $this->cache[(string)$id];
    
    foreach ($srcrow as $c) {
     if ((substr($c,0,1)=="%") && (substr($c,strlen($c)-1,1)=="%")) {
      $colname = substr($c,1,strlen($c)-2);
      $buf = $thisrecord->$colname;
     } else {
      $buf = $c;
     }
     
     $output->setActiveSheetIndex(0)->setCellValueByColumnAndRow($col, $i, $buf);
     $col++;
    }
    
    $i++;
   }
   
   $objWriter = PHPExcel_IOFactory::createWriter($output, 'Excel5');
   $objWriter->save($filename);
   
   return ($filename_client);
   
  }
コード例 #2
0
ファイル: cache.1.3.php プロジェクト: serega011/izumrud
 function getCacheDir($mode, $name) {
  $s = $_SERVER['SCRIPT_FILENAME'];
  $ret = (substr($s, 0, strrpos($s, "/")))."/".getCacheSubdir($mode, $name);
  mkdirr($ret);
  return $ret;
 }