There might be situations where you want to explicitly set the included images root. For example, one might want to see <img style="position: relative; left: 0px; top: 0px; width: 140px; height: 78px;" src="http://www.domain.com/images/logo.jpg" border="0"> instead of <img style="position: relative; left: 0px; top: 0px; width: 140px; height: 78px;" src="./images/logo.jpg" border="0">.
You can use the following code to achieve this result:
By default, this writer pre-calculates all formulas in the spreadsheet. This can be slow on large spreadsheets, and maybe even unwanted. You can however disable formula pre-calculation:
$objWriter = new PHPExcel_Writer_HTML($objPHPExcel); $objWriter->setPreCalculateFormulas(false);
$objWriter->save("05featuredemo.htm");
Embedding generated HTML in a web page
There might be a situation where you want to embed the generated HTML in an existing website. PHPExcel_Writer_HTML provides support to generate only specific parts of the HTML code, which allows you to use these parts in your website.
Supported methods:
generateHTMLHeader()
generateStyles()
generateSheetData()
generateHTMLFooter()
Here’s an example which retrieves all parts independently and merges them into a resulting HTML page:
<?php $objWriter = new PHPExcel_Writer_HTML($objPHPExcel); echo $objWriter->generateHTMLHeader(); ?>
<style>
<!--
html {
font-family: Times New Roman;
font-size: 9pt;
background-color: white;
}
<?php echo $objWriter->generateStyles(false); // do not write <style> and </style> ?>