PHP Spreadsheet_Excel_Writer | SetScript () Function

PHP

Syntax:
void Format::setScript ($script)
Parameters: This function takes one parameter $script which contains two values: 1 for superscript and 2 for subscript.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(); $worksheet = & amp; $workbook -> addWorksheet();  
// Create formats $format_superscript = & amp; $workbook -> addFormat(); $format_superscript -> setScript (1);  
// Add worksheet $worksheet = & amp; $workbook -> addWorksheet();  
// Add superscript to the cell $worksheet -> write (0, 0, "x2" , $format_superscript ); $workbook -> send ( ' test.xls' ); $workbook -> close(); ?>
Output: Example 2: < tbody> require_once 'Spreadsheet / Excel / Writer.php' ;  
// Create a Spreadsheet_Excel_Writer object $workbook = new Spreadsheet_Excel_Writer(); $worksheet = & amp; $workbook -> addWorksheet();  
// Create formats $format_superscript = & amp; $workbook -> addFormat(); $format_subscript -> setScript (2);  
// Add worksheet $worksheet = & amp; $workbook -> addWorksheet();  
// Add text to cell $worksheet -> write (0, 0, "Mg2SO4" , $format_subscript ); $workbook -> send ( ' test.xls' ); $workbook -> close(); ?>
Output: Link : https:// pear .php.net / manual / en / package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setscript.php



Get Solution for free from DataCamp guru