我試着下面的代碼Excel文件:打開使用COM並將其保存爲.xml文件
<?php
$workbook = "D:\b2\\test.XLS";
$sheet = "Sheet1";
#Instantiate the spreadsheet component.
$ex = new COM("Excel.sheet") or Die ("Did not connect");
#Get the application name and version
print "Application name:{$ex->Application->value}<BR>" ;
print "Loaded version: {$ex->Application->version}<BR>";
#Open the workbook that we want to use.
$wkb = $ex->application->Workbooks->Open($workbook) or Die ("Did not open");
#Create a copy of the workbook, so the original workbook will be preserved.
$ex->Application->ActiveWorkbook->SaveAs("D:\b2\Ourtest.xml");
#$ex->Application->Visible = 1; #Uncomment to make Excel visible.
#Optionally, save the modified workbook
$ex->Application->ActiveWorkbook->SaveAs("D:\Ourtest.xml");
#Close all workbooks without questioning
$ex->application->ActiveWorkbook->Close("False");
unset ($ex);
?>
這實際工作,並創建Ourtest.xml文件。但即時得到字符,如:
ÐÏࡱA>你þÿÿÿ
我試圖與另存爲(「d:\ Ourtest.pdf」)和它說該文件已損壞或不正確解碼。 任何人都可以幫助我嗎?謝謝
和文檔是在http://msdn.microsoft.com/en-us/library值/bb214129.aspx – VolkerK 2010-03-25 08:39:36
感謝您的鏈接 – chupinette 2010-03-25 08:49:04
$ ex-> Application-> ActiveWorkbook-> SaveAs(「D:\ b2 \ Ourtest.xml」,XlFileFormat.xlXMLSpreadsheet); 應該是這樣嗎? – chupinette 2010-03-25 08:50:48