Sono riuscito a generare un file Excel tramite questo script:
lo script tramite header genera e da in download il file, io vorrei salvarlo sul server
Codice PHP:
<?php
ob_start();
// ..
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
// ..
$filename = "Test";
// ..
// Send Header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=$filename.xls ");
header("Content-Transfer-Encoding: binary ");
// Open XLS
xlsBOF();
// ..
xlsWriteLabel(1,0,"Scr A2");
xlsWriteLabel(5,0,"Scr A6");
xlsWriteNumber(5,1,"33.333");
// ..
// Close XLS
xlsEOF();
exit();
// ..
?>
cichity74