Hi Guys
What I want to be able to do it to save a Excel file as HTML page. I know this can be done manually but what I want is the user to upload a excel file it then be converted to html (Effectively doing a File, Save as in Excel) automatically. Does anyone have any idea where to start or any sample code?
I have written code to upload the file which works fine but I don’t know how to save the excel file as a webpage
Thanks
Craig
Excel to HTML
Moderator: General Moderators
Thanks for the reply. I found this code on the page you linked to which originally saved the file as .csv I have adapted it so it will save as .htm However i dont know the number at the end of the Save As line. (as commented below)
Here is it code
Is there a list of numbers and which type of file they are saved as or does anyone no which number i need to use?
Thanks
Craig
Here is it code
Code: Select all
<?php
// starting excel
$excel = new COM("excel.application") or die("Unable to instanciate excel");
print "Loaded excel, version {$excel->Version}\n";
//bring it to front
#$excel->Visible = 1;//NOT
//dont want alerts ... run silent
$excel->DisplayAlerts = 0;
//open document
$excel->Workbooks->Open("C:\\phpdev\\www\\Rename\\test.xls");
echo"<br>file opened<br>";
//XlFileFormat.xlcsv file format is 6
//saveas command (file,format ......)
$excel->Workbooks[1]->SaveAs("C:\\phpdev\\www\\Rename\\test.html",6);\\the number at the end of this line
echo"Save as worked<br>";
//closing excel
$excel->Quit();
echo"Excel closed<br>";
//free the object
$excel->Release();
echo"file closed<br>";
$excel = null;
?>Thanks
Craig
Hi
I have done from numbers 1-11 after that it errors out....none of which save in the correct format...Here is my code are there any mistakes in it?
I have done from numbers 1-11 after that it errors out....none of which save in the correct format...Here is my code are there any mistakes in it?
Code: Select all
<?php
// starting excel
$excel = new COM("excel.application") or die("Unable to instanciate excel");
print "Loaded excel, version {$excel->Version}\n";
//bring it to front
#$excel->Visible = 1;//NOT
//dont want alerts ... run silent
$excel->DisplayAlerts = 0;
//open document
$excel->Workbooks->Open("C:\\phpdev\\www\\Rename\\test.xls");
echo"<br>file opened<br>";
//XlFileFormat.xlcsv file format is 6
//saveas command (file,format ......)
$excel->Workbooks[1]->SaveAs("C:\\phpdev\\www\\Rename\\test.htm",6);
echo"Save as worked<br>";
//closing excel
$excel->Quit();
echo"Excel closed<br>";
//free the object
$excel->Release();
echo"file closed<br>";
$excel = null;
?>