setHAlign()函数是PHP中的内置函数| Spreadsheet_Excel_Writer用于设置电子表格的单元格对齐。
用法:
void Format::setHAlign( $location )
参数:此函数接受单个参数作为$location,该参数采用的位置是将文本放置为“左”,“中”,“右”,“填充”,“对齐”,“合并”,“ equal_space”的位置。
返回值:成功时返回TRUE,失败时返回PEAR_ERROR。
范例1:
<?php
// require_once 'Spreadsheet/Excel/Writer.php';
// Add object of class Spreadsheet_Excel_Writer
$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet();
// Add a format to the workbook
$format_center =& $workbook->addFormat();
// Set color for the text
$format_center->setColor ('green');
// Set alignment of text to the center of the cell
$format_center->setHAlign('center');
// Add boldness to the text
$format_center->setBold(1);
// Set size of the text
$format_center->setSize(25);
// Add data to the cell
$worksheet->write(0, 5, 'GeeksforGeeeks!', $format_center);
$worksheet->write(1, 5, 'A Computer Science Portal For Geeks',
$format_center);
// Send file to the browser
$workbook->send('test.xlsx');
// Free the memory
$workbook->close();
?>
输出:
范例2:
<?php
// require_once 'Spreadsheet/Excel/Writer.php';
// Add object of class Spreadsheet_Excel_Writer
$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet();
// Add a Format to the workbook
$format_center =& $workbook->addFormat();
// Set Color for the text
$format_center->setColor ('white');
// Set Alignment of text to the right of the cell
$format_center->setHAlign('right');
// Set background color
$format_center->setBgColor('black');
// Set Pattern to the cell
$format_center->setPattern(1);
// Add Boldness to the text
$format_center->setItalic(1);
// Set Size of the text
$format_center->setSize(20);
// Add data to the cell
$worksheet->write(7, 5, 'Sarthak Prajapati', $format_center);
$worksheet->write(8, 5, 'sarthak_ishu11', $format_center);
$worksheet->write(9, 5, 'Chandigarh', $format_center);
// Send file to the browser
$workbook->send('test.xlsx');
// Free the memory
$workbook->close();
?>
输出:
相关用法
- p5.js arc()用法及代码示例
- p5.js tan()用法及代码示例
- p5.js sin()用法及代码示例
- p5.js cos()用法及代码示例
- d3.js d3.set.has()用法及代码示例
- p5.js log()用法及代码示例
- PHP ord()用法及代码示例
- d3.js d3.mean()用法及代码示例
- p5.js second()用法及代码示例
- PHP Ds\Map last()用法及代码示例
- PHP dir()用法及代码示例
- p5.js max()用法及代码示例
注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | Spreadsheet_Excel_Writer | setHAlign() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。