PHP Spreadsheet_Excel_Writer | SetBold () Function

PHP

Syntax:
void Format::setBold ($weight = 1)
Parameters: This function takes one parameter, $weight, which is used to set the weight of the text. The default value for text weight is 1 (700). It ranges from 100 to 1000.Return Value:This function returns TRUE on success and PEAR_ERROR on error. 
Example 1: require_once 'Spreadsheet / Excel / Writer.php' ;  
// Create a Spreadsheet_Excel_Writer object $workbook = new Spreadsheet_Excel_Writer();  
// Add worksheet $worksheet = & amp; $workbook -> addWorksheet();  
// Install Family Times New Roman font $format_setBold = & amp; $workbook -> addFormat(); $format_setBold -> setFontFamily ( 'Times New Roman' );  
// Set the Bold property $format_setBold -> setBold();  
// Set text shadow $format_setBold -> setShadow();  
// Save to sheet $worksheet -> write (0, 0, "Information" ); $worksheet -> write (1, 0, "Website Name" , $format_setBold ); $worksheet -> write (1, 1, "Address" , $format_setBold ); $worksheet -> write (2, 0, "GeeksforGeeks" , $format_setBold ); $worksheet -> write (2, 1, " https://www.engineerforengineer.org/ " , $format_setBold ); $workbook -> send ( 'test.xls' ); $workbook -> close(); ?>
Output: Example 2: < tbody> require_once 'Spreadsheet / Excel / Writer.php' ;  
// Add book $workbook = new Spreadsheet_Excel_Writer();  
// Add format to spreadsheet $format_bold = & amp; $workbook -> addFormat();  
// Set in bold $format_bold -> setBold();  
// Add worksheet to Sprerdsheet $worksheet = & amp; $workbook -> addWorksheet();  
// Save to sheet $worksheet -> write (0, 0, "Details of GeeksforGeeks Contributors ", $format_bold ); $worksheet -> write (1, 0, "Author" , $format_bold ); $worksheet -> write (1, 1, "User Handle" , $format_bold ); $worksheet -> write (2, 0, "Sarthak" , $format_bold ); $worksheet -> write (2, 1, "sarthak_ishu11" , $format_bold );  
// Submit the .xlsx file in the header $workbook -> send ( 'test.xls' );  
// Close the book object $workbook -> close(); ?>
Output: Link : https:// pear .php.net / manual / en / package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setbold.php



Get Solution for free from DataCamp guru