Situatie
The setFontFamily() function is an inbuilt function in PHP | Spreadsheet_Excel_Writer which is used to set the font family.
This function accepts single parameter $font_family.
This function returns TRUE on success and PEAR_ERROR on failure.
Solutie
<?php
require_once ‘Spreadsheet/Excel/Writer.php’;
// Add Workbook
$workbook = new Spreadsheet_Excel_Writer();
// Add Format to spreadsheet
$format_border =& $workbook->addFormat();
// Add Worksheet to Sprerdsheet
$worksheet =& $workbook->addWorksheet();
// Add Format to variable
$format_times =& $workbook->addFormat();
// Set Font Family Times New Roman
$format_times->setFontFamily(‘Times New Roman’);
// Add Format to variable
$format_courier =& $workbook->addFormat();
// Set Font Family Courier
$format_courier->setFontFamily(‘Courier’);
// Write to Worksheet
$worksheet->write(0, 0, “test”);
$worksheet->write(1, 0, “Ceva”, $format_times);
$worksheet->write(1, 1, “Ceva2”, $format_courier);
$worksheet->write(2, 0, “Altceva”);
$worksheet->write(2, 1, “Altceva2”);
// Send .xlsx file to header
$workbook->send(‘gfg1.xls’);
// Close Workbook Object
$workbook->close();
?>
Leave A Comment?