Hallo,
ich erzeuge das File genau so. Mit Textdateien etc geht es ja auch.
function __BOF() {
return pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
}
function __EOF() {
return pack("ss", 0x0A, 0x00);
}
ich denke es hat damit zu tun. Leider finde ich seit 2 Tagen keine Lösung. Und das wo ich die Datei wenn ich sie erzeuge öffnen kann und alles gut ausschaut. Am besten wäre natürlich wenn ich eine gute Klasse finden würde. Ich änge Sie mal ganz hier an. Export habe ich halt selber hinzugefügt. Vielleicht kannst du mir helfen was ich da reinschreiben kann.
Danke
S
<?php
class ExcelExport {
var $file;
var $row;
function ExcelExport() {
$this->file = $this->__BOF();
$row = 0;
}
function __BOF() {
return pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
}
function __EOF() {
return pack("ss", 0x0A, 0x00);
}
function __writeNum($row, $col, $value) {
$this->file .= pack("sssss", 0x203, 14, $row, $col, 0x0);
$this->file .= pack("d", $value);
}
function __writeString($row, $col, $value ) {
$L = strlen($value);
$this->file .= pack("ssssss", 0x204, 8 + $L, $row, $col, 0x0, $L);
$this->file .= $value;
}
function writeCell($value,$row,$col) {
if(is_numeric($value)) {
$this->__writeNum($row,$col,$value);
}elseif(is_string($value)) {
$this->__writeString($row,$col,$value);
}
}
function addRow($data,$row=null) {
//If the user doesn't specify a row, use the internal counter.
if(!isset($row)) {
$row = $this->row;
$this->row++;
}
for($i = 0; $i<count($data); $i++) {
$cell = $data[$i];
$this->writeCell($cell,$row,$i);
}
}
function download($filename) {
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 ");
header("Content-Transfer-Encoding: binary ");
$this->write();
}
function export($pathfilename) {
$file = fopen($pathfilename, "w");
fwrite($file, $this->file.$this->__EOF());
chmod($pathfilename,0664);
fclose($file);
}
function write() {
echo $file = $this->file.$this->__EOF();
}
}
?>