setScript()函數是PHP中的內置函數| Spreadsheet_Excel_Writer,用於設置文本的腳本類型。
用法:
void Format::setScript( $script )
參數:該函數接受單個參數$script,該參數包含兩個值,上標為1,下標為2。
返回值:成功時返回TRUE,失敗時返回PEAR_ERROR。
範例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();
?>
輸出:
範例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();
?>
輸出:
相關用法
- PHP pos()用法及代碼示例
- PHP sin( )用法及代碼示例
- p5.js int()用法及代碼示例
- p5.js hex()用法及代碼示例
- PHP cos( )用法及代碼示例
- PHP tan( )用法及代碼示例
- PHP end()用法及代碼示例
- p5.js arc()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- p5.js cos()用法及代碼示例
- p5.js log()用法及代碼示例
- p5.js hue()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | Spreadsheet_Excel_Writer | setScript() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。