Differenze tra le versioni di "Libreria PHPExcel"
| Riga 15: | Riga 15: | ||
* [[Operazioni su più celle PHPExcel]] | * [[Operazioni su più celle PHPExcel]] | ||
* [[Unioni di più celle PHPExcel]] | * [[Unioni di più celle PHPExcel]] | ||
| + | |||
| + | == Importazione e lettura di un file excel == | ||
| + | <pre> | ||
| + | // leggo il file | ||
| + | $excel = null; | ||
| + | try { | ||
| + | $inputFileType = \PHPExcel_IOFactory::identify( $filepath ); | ||
| + | $objReader = \PHPExcel_IOFactory::createReader( $inputFileType ); | ||
| + | $excel = $objReader->load( $filepath ); | ||
| + | } catch(Exception $e) { | ||
| + | echo 'Errore nel leggere il file come foglio di calcolo elettronico: '.$e->getMessage(); | ||
| + | return false; | ||
| + | } | ||
| + | </pre> | ||
Versione delle 15:29, 16 feb 2024
Creazione file XLSX
$xls = new PHPExcel( ); ... $xlsWriter = new \PHPExcel_Writer_Excel2007( $xls ); $xlsWriter->save( $filepath );
Formattazione
Operazioni
Importazione e lettura di un file excel
// leggo il file
$excel = null;
try {
$inputFileType = \PHPExcel_IOFactory::identify( $filepath );
$objReader = \PHPExcel_IOFactory::createReader( $inputFileType );
$excel = $objReader->load( $filepath );
} catch(Exception $e) {
echo 'Errore nel leggere il file come foglio di calcolo elettronico: '.$e->getMessage();
return false;
}