Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Setting the images root of the HTML file

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:

$objWriter->setImagesRoot('http://www.example.com');

Formula pre-calculation

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>
?>

-->

</style>

<?php
echo $objWriter->generateSheetData();
echo $objWriter->generateHTMLFooter();
?>

Writing UTF-8 HTML files

A HTML file can be marked as UTF-8 by writing a BOM file header. This can be enabled by using the following code:

$objWriter = new PHPExcel_Writer_HTML($objPHPExcel);
$objWriter->setUseBOM(true);

$objWriter->save("05featuredemo.htm");

Decimal and thousands separators

See section PHPExcel_Writer_CSV how to control the appearance of these.

PDF

PHPExcel allows you to write a spreadsheet into PDF format, for fast distribution of represented data.

 

i PDF limitations
Please note that PDF file format has some limits regarding to styling cells, number formatting, …

PHPExcel_Writer_PDF

 

i Please note that PHPExcel_Writer_PDF only outputs the first worksheet by default.

Writing a spreadsheet

You can write a .pdf file using the following code:

$objWriter = new PHPExcel_Writer_PDF($objPHPExcel);

$objWriter->save("05featuredemo.pdf");

Write all worksheets

PDF files can contain one or more worksheets. If you want to write all sheets into a single PDF file, use the following code:



$objWriter->writeAllSheets();

Write a specific worksheet

PDF files can contain one or more worksheets. Therefore, you can specify which sheet to write to PDF:

$objWriter->setSheetIndex(0);


Date: 2016-03-03; view: 818


<== previous page | next page ==>
Setting CSV options | Formula pre-calculation
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.005 sec.)