PHP | Spreadsheet_Excel_Writer | setScript() Function
The setScript() function is an inbuilt function in PHP | Spreadsheet_Excel_Writer which is used to set the script type of the text.
Syntax:
void Format::setScript( $script )
Parameters: This function accepts single parameter $script which contains two value as 1 for superscript and 2 for subscript.
Return Value: This function returns TRUE on success and PEAR_ERROR on failure.
Example 1:
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Create Spreadsheet_Excel_Writer object $workbook = new Spreadsheet_Excel_Writer(); $worksheet =& $workbook->addWorksheet(); // Creating the formats $format_superscript =& $workbook->addFormat(); $format_superscript->setScript(1); // Add Worksheet $worksheet =& $workbook->addWorksheet(); // Add superscript Text to cell $worksheet->write(0, 0, "x2", $format_superscript); $workbook->send('test.xls'); $workbook->close(); ?> |
chevron_right
filter_none
Output:

Example 2:
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Create Spreadsheet_Excel_Writer object $workbook = new Spreadsheet_Excel_Writer(); $worksheet =& $workbook->addWorksheet(); // Creating the formats $format_superscript =& $workbook->addFormat(); $format_subscript->setScript(2); // Add Worksheet $worksheet =& $workbook->addWorksheet(); // Add subscript text to cell $worksheet->write(0, 0, "Mg2SO4", $format_subscript); $workbook->send('test.xls'); $workbook->close(); ?> |
chevron_right
filter_none
Output:

Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- p5.js | red() function
- D3.js | d3.sum() function
- p5.js | int() function
- D3.js | d3.map.set() Function
- PHP | Ds\Map last() Function
- PHP | Ds\Map map() Function
- CSS | url() Function
- PHP | end() Function
- PHP | next() Function
- p5.js | tan() function
- p5.js | log() function
- p5.js | sin() function
- p5.js | value() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



