📌  相关文章
📜  PHP |电子表格_Excel_Writer |关闭()函数

📅  最后修改于: 2022-05-13 01:56:36.241000             🧑  作者: Mango

PHP |电子表格_Excel_Writer |关闭()函数

close()函数是PHP中的内置函数| Spreadsheet_Excel_Writer 用于完成所有操作后完成的电子表格。此方法应始终是每个工作簿上调用的最后一个方法。

句法:

mixed Workbook::close()

参数:此函数不接受任何参数。
返回值:此函数在成功时返回 TRUE,在失败时返回 PEAR_ERROR。

示例 1:

PHP
addFormat();
 
// Set Bold Format
$format_bold->setBold();
 
// Add Worksheet to Spreadsheet
$worksheet =& $workbook->addWorksheet();
 
$format_bold->setBorder(2);
 
// Write to Worksheet
$worksheet->write(0, 0, "Details of GeeksforGeeks
                   Contributors", $format_bold);
$worksheet->write(1, 0, "Author", $format_bold);
$worksheet->write(1, 1, "User Handle", $format_bold);
$worksheet->write(2, 0, "Sarthak");
$worksheet->write(2, 1, "sarthak_ishu11");
 
// Send .xlsx file to header
$workbook->send('test.xls');
 
// Close Workbook Object
$workbook->close();
?>


PHP
addFormat();
 
// Add Worksheet to Spreadsheet
$worksheet =& $workbook->addWorksheet();
 
// Set and Add Border Width
$format_border->setBorder(2);
 
// Set and Add Color to Border
$format_border->setBorderColor('red');
 
// Write to Worksheet
$worksheet->write(0, 0, "Details of GeeksforGeeks
                     Contributors", $format_bold);
$worksheet->write(1, 0, "Author", $format_border);
$worksheet->write(1, 1, "User Handle", $format_border);
$worksheet->write(2, 0, "Sarthak");
$worksheet->write(2, 1, "sarthak_ishu11");
 
// Send .xlsx file to header
$workbook->send('test.xls');
 
// Close Workbook Object
$workbook->close();
?>


输出:

示例 2:

PHP

addFormat();
 
// Add Worksheet to Spreadsheet
$worksheet =& $workbook->addWorksheet();
 
// Set and Add Border Width
$format_border->setBorder(2);
 
// Set and Add Color to Border
$format_border->setBorderColor('red');
 
// Write to Worksheet
$worksheet->write(0, 0, "Details of GeeksforGeeks
                     Contributors", $format_bold);
$worksheet->write(1, 0, "Author", $format_border);
$worksheet->write(1, 1, "User Handle", $format_border);
$worksheet->write(2, 0, "Sarthak");
$worksheet->write(2, 1, "sarthak_ishu11");
 
// Send .xlsx file to header
$workbook->send('test.xls');
 
// Close Workbook Object
$workbook->close();
?>

输出:

参考: https://pear。 PHP.net/manual/en/package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-workbook.close。 PHP