не могу разобратся с xml. excel 2007 выдает предупреждение (The file you are trying to open, 'otchet.xls', is the different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file). в OpenOffice вообще не открывает файл. Если поменять расширение на xml, то открывает без ругани везде,но пользователям надо, чтобы расширение было именно xls.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
class excel_creator {
private $header="<?xml version=\" 1 . 0 \"?><?mso-application progid=\"Excel.Sheet\"?>";
private $encoding="UTF-8";
private $filename="file.xls";
private $author="";
private $styles=array();
private $worksheets=array();
private $attributes=array();
private $currentworksheet="";
private $worksheetpointer=null;
private $tablepointer=null;
private $rowpointer=null;
public function __construct($encoding="UTF-8", $filename="file.xls", $author=""){
$this->encoding=$encoding;
$this->filename=$filename;
$this->addStyleProperty("Default","Alignment","Vertical","Bottom");
$this->addStyleProperty("Default","Borders");
$this->addStyleProperty("Default","Font");
$this->addStyleProperty("Default","Interior");
$this->addStyleProperty("Default","NumberFormat");
$this->addStyleProperty("Default","Protection");
}
.
.
.
public function end() {
header("Content-Type: application/vnd.ms-excel; charset=" . $this->encoding);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Disposition: attachment; filename=\"" . $this->filename . ".xls\"");
print(stripslashes(sprintf($this->header, $this->encoding)));
print("\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n".
"\txmlns:o=\"urn:schemas-microsoft-com:office:office\"\n".
"\txmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n".
"\txmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n".
"\txmlns:html=\"http://www.w3.org/TR/REC-html40\">\n");
print("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">\n".
"\t<Author>".$this->author."</Author>\n".
"\t<LastAuthor>".$this->author."</LastAuthor>\n".
"\t<Created>".date("Y-m-d")."T".date("H:i:s")."Z</Created>\n".
"\t<Company>TEST</Company>\n".
"\t<Version>11.8036</Version>\n".
"</DocumentProperties>\n");
.
.
.
print "\n</Workbook>\n";
}
}
заранее спасибо :-)