当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP Spreadsheet_Excel_Writer setScript()用法及代码示例


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(); 
?>

输出:

参考: https://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setscript.php



相关用法


注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | Spreadsheet_Excel_Writer | setScript() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。