<?php

/** Include PHPExcel */
require_once 'Classes/PHPExcel.php';

error_reporting(E_ALL);
/**
 * testDos actions.
 *
 * @package    canon
 * @subpackage testDos
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class testDosActions extends sfActions {

    public function executeList(sfWebRequest $request) {

//
//
//        $callStartTime = microtime(true);
//        $cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
//        $cacheSettings = array(' memoryCacheSize ' => '1MB');
//        PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
//
//        $objPHPExcel = new PHPExcel();
//
//
//
//// Set document properties
//        $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
//                ->setLastModifiedBy("Maarten Balliauw")
//                ->setTitle("Office 2007 XLSX Test Document")
//                ->setSubject("Office 2007 XLSX Test Document")
//                ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
//                ->setKeywords("office 2007 openxml php")
//                ->setCategory("Test result file");
//
//        $sql = <<<EOD
//   
//select * from ca_usuario
//   
//EOD;
//
//        $conn = Doctrine_Manager::connection();
//        $assoc = $conn->execute($sql)->fetchAll();
//
//        $objPHPExcel->getActiveSheet()->fromArray($assoc);
//
//// Rename worksheet
//        $objPHPExcel->getActiveSheet()->setTitle('Simple');
//
//
//// Set active sheet index to the first sheet, so Excel opens this as the first sheet
//        $objPHPExcel->setActiveSheetIndex(0);
//
//
//// Save Excel 2007 file
//        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//        header('Content-Disposition: attachment;filename="Test.xlsx"');
//        header('Cache-Control: max-age=0');
//
//        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//        $objWriter->setPreCalculateFormulas(false);
//        $objWriter->setUseDiskCaching(true);
//        $objWriter->save('php://output');
//      
//        $objPHPExcel->disconnectWorksheets();
//        unset($objPHPExcel);
//        
//        $callEndTimeRead = microtime(true);
//        $callTimeInit = $callEndTimeRead-$callStartTime;
//        $this->logMessage( 'Termino la lectura del archivo y duro: '.$callTimeInit.' segundos.');
////        
////        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
////        $objWriter->setUseDiskCaching(true);
////        $objWriter->setPreCalculateFormulas(false);
////        $objWriter->save("/home/harold/NetBeansProjects/canon/apps/api/modules/testDos/actions/temporal.xlsx");
////        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
////        header('Content-Disposition: attachment;filename="myfile.xlsx"');
////        header('Cache-Control: max-age=0');
////        readfile("/home/harold/NetBeansProjects/canon/apps/api/modules/testDos/actions/temporal.xlsx");    
//        $callEndTime = microtime(true);
//        $callTime = $callEndTime - $callStartTime;
//        $this->logMessage( 'Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB<br /> y duro: '.$callTime.' segundos.');
//
//        $this->list_data = array();
    }

}
