Index
Basics
- Create a new object: $phpExcel = new PHPExcel();
- Getting the active worksheet: $sheet = $phpExcel->getActiveSheet();
- Add text to a cell: $sheet->setCellValue("A1", "Hello World");
- Add a new worksheet: $sheet2 = $phpExcel->createSheet();
- Add a formula to a cell: $sheet2->setCellValue("A5", "=SUM(A1:A4)");
- Rename a worksheet: $sheet2->setTitle("Simple");
- Merge cells: $sheet2()->mergeCells("A1:E3");
- Unmerge cells: $sheet2()->unmergeCells("A1:E3");
Adding properties to your file
- Set Author: $phpExcel ->getProperties()->setCreator("Tom Smith");
- Set Last Modified By: $phpExcel->getProperties()->setLastModifiedBy("Tom Smith");
- Set Title: $phpExcel->getProperties()->setTitle("Title");
- Set Subject: $phpExcel->getProperties()->setSubject("Subject");
- Set Description: $phpExcel->getProperties()->setDescription("A description of the file.");
Formatting A Cell
- Setting Width: $sheet2->getColumnDimension("A")->setWidth(40);
- Setting Auto Width: $sheet2->getColumnDimension("A")->setAutoSize(true);
- Setting Text Alignment Right: $sheet2->getStyle("A1")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
- Making text of a range of cells bold: $sheet2->getStyle("A1:F1")->applyFromArray(array("font" => array( "bold" => true)));
- Adding an auto filter to a range of cells: $sheet2->setAutoFilter("A1:C9");
Output to the browser as a download.
<?php
$phpExcel = new PHPExcel();
$phpExcel->getActiveSheet()->setTitle("My Sheet");
$phpExcel->setActiveSheetIndex(0);
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"filename.xls\"");
header("Cache-Control: max-age=0");
$objWriter = PHPExcel_IOFactory::createWriter($phpExcel, "Excel5");
$objWriter->save("php://output");
exit;
Setup saprfc php
sudo aptitude install libstdc++2.10-glibc2.2
sudo ln -sf /usr/lib/libstdc++-3-libc6.2-2-2.10.0.so /usr/lib/libstdc++-libc6.1-1.so.2
cd sap_sdk/
unzip 50076444_4.ZIP
unzip 50076444_5.ZIP
unzip 50076444_6.ZIP
cd LINUX_32/
cd NUC/
../../SAPCAR -xvf RFC.SAR
sudo mkdir /usr/sap
sudo cp -av rfcsdk /usr/sap/
wget -vc prdownloads.sourceforge.net/saprfc/saprfc-1.4.1.tar.gz
tar xfvz saprfc-1.4.1.tar.gz
cd saprfc-1.4.1/
phpize
./configure
make
sudo make install
sudo vim /etc/php5/apache2/php.ini
extension=saprfc.so
sudo /etc/init.d/apache2 reload
gestire register_globals = off
http://www.elvisciotti.it/blog/archives/154
Per montare un’applicazione/cms/script che funziona solo con register_globals = on (che sconsiglio !),
invece di rinominare tutte le variabili:
soluzione per tutta la cartella
crea .htaccess e scrivici "php_flag register_globals On"
soluzione per i singoli script
foreach($_POST AS $key => $value) { ${$key} = $value; }
foreach($_GET AS $key => $value) { ${$key} = $value; }
//da fare anche con SESSION e COOKIE se sono usati