最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php生成excel文件并输出到浏览器
时间:2022-06-24 19:05:48 编辑:袖梨 来源:一聚教程网
本文介绍了php spreadsheet_excel_writer与如何生成excel文件。
第一步,安装spreadsheet_excel_writer 由于这包使用ole包,您可能需要安装它
执行以下命令来执行更新: 更新pear.php.net ole - 0.5 spreadsheet_excel_writer - 0.9.1
看一个实例,myfile.xls是文件名(包括路径),工作簿包含一个具有学生名单表
require_once 'spreadsheet/excel/writer.php';
// creating workbook
$workbook = new spreadsheet_excel_writer('myfile.xls');
// adding worksheet
$worksheet =& $workbook->addworksheet('students');
// data input
$worksheet->write(0, 0, 'name');
$worksheet->write(0, 1, 'grade');
$worksheet->write(1, 0, 'ivancho');
$worksheet->write(1, 1, 7);
$worksheet->write(2, 0, 'mariika');
$worksheet->write(2, 1, 7);
$worksheet->write(3, 0, 'stoyancho');
$worksheet->write(3, 1, 8);
// saving file
$workbook->close();
?>
下面来看一款把数据导出给用户保存吧。
require_once 'spreadsheet/excel/writer.php';
// creating workbook
$workbook = new spreadsheet_excel_writer();
// sending headers to browser
$workbook->send('students.xls');
// adding worksheet
$worksheet =& $workbook->addworksheet('students');
// data input
$worksheet->write(0, 0, 'name');
$worksheet->write(0, 1, 'grade');
$worksheet->write(1, 0, 'ivancho');
$worksheet->write(1, 1, 7);
$worksheet->write(2, 0, 'mariika');
$worksheet->write(2, 1, 7);
$worksheet->write(3, 0, 'stoyancho');
$worksheet->write(3, 1, 8);
// sending the file
$workbook->close();
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21