public function export()
 {
     $objPHPExcel = new sfPhpExcel();
     // Set properties
     $objPHPExcel->getProperties()->setCreator("SensorSix");
     $objPHPExcel->getProperties()->setLastModifiedBy("SensorSix");
     $objPHPExcel->setActiveSheetIndex(0);
     $this->sheet = $objPHPExcel->getActiveSheet();
     $this->buildHead();
     $this->buildBody();
     // Rename sheet
     $objPHPExcel->getActiveSheet()->setTitle('Alternatives');
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     // Save Excel 2007 file
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
 }
Пример #2
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data, we will use some formulas here
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sum:');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
$objPHPExcel->getActiveSheet()->setCellValue('B3', 8);
Пример #3
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFCCFFCC')), 'borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM))), "A1:T100");
$objPHPExcel->getActiveSheet()->duplicateStyleArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'FFFFFF00'))), "C5:R95");
// Save Excel 2007 file
Пример #4
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet
echo date('H:i:s') . " Add data and breaks\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
Пример #5
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Generate an image
echo date('H:i:s') . " Generate an image\n";
$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);
// Add a drawing to the worksheet
Пример #6
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data, we will use printing features
echo date('H:i:s') . " Add some data\n";
for ($i = 1; $i < 200; $i++) {
    $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $i);
    $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, 'Test value');
}
Пример #7
0
 */
/** Error reporting */
error_reporting(E_ALL);
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
/** PHPExcel_Cell_AdvancedValueBinder */
require_once 'PHPExcel/Cell/AdvancedValueBinder.php';
// Set timezone
echo date('H:i:s') . " Set timezone\n";
date_default_timezone_set('UTC');
// Set value binder
echo date('H:i:s') . " Set value binder\n";
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_AdvancedValueBinder());
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Set default font
echo date('H:i:s') . " Set default font\n";
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial');
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10);
// Set column widths
echo date('H:i:s') . " Set column widths\n";
Пример #8
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet, representing sales data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
$objPHPExcel->getActiveSheet()->setCellValue('D1', PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, date('m'), date('d'), date('Y'))));
$objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15);
Пример #9
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet
echo date('H:i:s') . " Add data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...");
$objPHPExcel->getActiveSheet()->setCellValue('A3', "Number:");
$objPHPExcel->getActiveSheet()->setCellValue('B3', "10");
Пример #10
0
 /**
  * @param sfWebRequest $request
  */
 public function executeExcelExport(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     /** @var Decision $decision  */
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless($decision);
     $objPHPExcel = new sfPhpExcel();
     header('Content-type: application/force-download');
     header('Content-Disposition: attachment; filename="' . $decision->name . '.xlsx"');
     // Set properties
     $objPHPExcel->getProperties()->setCreator("SensorSix");
     $objPHPExcel->getProperties()->setLastModifiedBy("SensorSix");
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0);
     /** @var ProjectRelease[] $releases  */
     $releases = Doctrine_Query::create()->from('ProjectRelease r')->leftJoin('r.ProjectReleaseAlternative ra')->leftJoin('ra.Alternative a')->where('r.decision_id = ? AND r.criterion_id = ?', array($decision_id, $request->getParameter('criterion_id')))->execute();
     $index = 1;
     $sheet = $objPHPExcel->getActiveSheet();
     foreach ($releases as $release) {
         $sheet->setCellValue('A' . $index++, $release->name);
         foreach ($release->ProjectReleaseAlternative as $releaseAlternative) {
             $sheet->setCellValue('B' . $index, $releaseAlternative->Alternative->name);
             $sheet->setCellValueExplicit('C' . $index, $releaseAlternative->value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
             $index++;
         }
         $sheet->setCellValue('B' . ++$index, 'Total:');
         $sheet->setCellValueExplicit('C' . $index, $release->value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
         $index += 2;
     }
     // Rename sheet
     $objPHPExcel->getActiveSheet()->setTitle('Releases');
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     // Save Excel 2007 file
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
     exit;
 }
Пример #11
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet
echo date('H:i:s') . " Add data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Quarter");
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Country");
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Sales");
Пример #12
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
Пример #13
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
Пример #14
0
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Add some data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Lastname:');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Fullname:');
Пример #15
0
/*
After doing some test, I've got these results benchmarked
for writing to Excel2007:
	
	Number of rows	Seconds to generate
	200				3
	500				4
	1000			6
	2000			12
	4000			36
	8000			64
	15000			465
*/
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet
echo date('H:i:s') . " Add data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
Пример #16
0
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// List functions
echo date('H:i:s') . " List implemented functions\n";
$objCalc = PHPExcel_Calculation::getInstance();
print_r($objCalc->listFunctionNames());
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Add some data, we will use some formulas here
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Sum:');
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Max:');
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Min:');
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Average:');
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Median:');
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Mode:');
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:');
$objPHPExcel->getActiveSheet()->setCellValue('A23', 'MaxA:');
$objPHPExcel->getActiveSheet()->setCellValue('A24', 'MinA:');
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:');
$objPHPExcel->getActiveSheet()->setCellValue('A27', 'StDevA:');
$objPHPExcel->getActiveSheet()->setCellValue('A28', 'StDevP:');
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/lgpl.txt	LGPL
 * @version    1.6.7, 2009-04-22
 */
/* Modified by Bertrand Zuchuat */
require_once 'symfony.inc.php';
// Create new PHPExcel object
echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new sfPhpExcel();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");
$objPHPExcel->getProperties()->setCategory("Test result file");
// Create a first sheet, representing sales data
echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Amount');
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received');
Пример #18
0
 public function executeExcelExport(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     /** @var Decision $decision  */
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless($decision);
     $average_analyze = new AverageAnalyze();
     $average_analyze->setDecisionId($decision_id);
     $average_analyze->load();
     $measurement = $average_analyze->getMeasurement();
     $objPHPExcel = new sfPhpExcel();
     header('Content-type: application/force-download');
     header('Content-Disposition: attachment; filename="Alternatives (' . $decision->name . ').xlsx"');
     // Set properties
     $objPHPExcel->getProperties()->setCreator("SensorSix");
     $objPHPExcel->getProperties()->setLastModifiedBy("SensorSix");
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0);
     $index = 1;
     $column_index = 0;
     $sheet = $objPHPExcel->getActiveSheet();
     // Add default header
     foreach (array('ID', 'Name', 'Status', 'Work progress', 'Tags', 'Additional info', 'Notes', 'Due date', 'Notify date', 'Created at', 'Created by', 'Updated at', 'Updated by', 'Custom fields') as $value) {
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $value);
     }
     // Add criterias in header
     foreach ($average_analyze->getCriteriaNames() as $criteria_name) {
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $criteria_name);
     }
     foreach ($decision->getAlternative() as $alternative) {
         /** @var Alternative $alternative */
         $index++;
         $column_index = 0;
         $tags = array();
         foreach ($alternative->getTagAlternative() as $tag) {
             $tags[] = $tag->Tag->name;
         }
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->getItemId());
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->name);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->status);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->work_progress);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, implode(', ', $tags));
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->additional_info);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->notes);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->due_date);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->notify_date);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->created_at);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->created_by);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->updated_at);
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, $alternative->updated_by);
         $custom_fields = array();
         foreach (json_decode($alternative->custom_fields, true) as $key => $value) {
             $custom_fields[] = $key . ': ' . $value;
         }
         $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index++) . $index, implode(PHP_EOL, $custom_fields));
         foreach ($average_analyze->getCriteriaNames() as $criteria_id => $criteria_name) {
             if (array_key_exists($alternative->getId(), $measurement[$criteria_id])) {
                 $sheet->setCellValue(PHPExcel_Cell::stringFromColumnIndex($column_index) . $index, $measurement[$criteria_id][$alternative->getId()]->getAverage());
             }
             $column_index++;
         }
     }
     for ($i = 0; $i <= $column_index; $i++) {
         $sheet->getColumnDimensionByColumn($i)->setAutoSize(true);
     }
     $sheet->calculateColumnWidths();
     // Rename sheet
     $objPHPExcel->getActiveSheet()->setTitle('Alternatives');
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objPHPExcel->setActiveSheetIndex(0);
     // Save Excel 2007 file
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
     exit;
 }