search
Homephp教程php手册如何正确运用PHP Spreadsheet_Excel_Writer

如何正确运用PHP Spreadsheet_Excel_Writer

Jun 13, 2016 am 11:10 AM
excelpphpwriteruseexisthowmethodcorrectuse

在利用

其实在众多方法中感觉Pear中的Spreadsheet_Excel_Writer很是好用。关于PHP Spreadsheet_Excel_Writer的安装本文不予介绍。

以下为PHP Spreadsheet_Excel_Writer的引用的内容:
 

  1.  ?php   
  2. //调用Writer.php   
  3. require_once ‘Spreadsheet/Excel/Writer.php’;   
  4. //创建Workbook   
  5. $workbook = new Spreadsheet_Excel_Writer();   
  6. //定义导出Excel文件名   
  7. $workbook->send(’test.xls’);   
  8. //创建Worksheet   
  9. $worksheet =& $workbook->addWorksheet(’My first worksheet’);   
  10. //设置字体大小   
  11. $format_column = & $workbook->addformat(array(’Size’=>9,’Bold’=>1));   
  12. //数据写入   
  13. //标题行(第一行)   
  14. $worksheet->write(0, 0, ‘Name’, $format_column);   
  15. $worksheet->write(0, 1, ‘Age’, $format_column);   
  16. //第一个人(第二行)   
  17. $worksheet->write(1, 0, ‘John Smith’);   
  18. $worksheet->write(1, 1, 30);   
  19. //第二个人(第三行)   
  20. $worksheet->write(2, 0, ‘Johann Schmidt’);   
  21. $worksheet->write(2, 1, 31);   
  22. //第三个人(第四行)   
  23. $worksheet->write(3, 0, ‘Juan Herrera’);   
  24. $worksheet->write(3, 1, 32);   
  25. //关闭Workbook   
  26. $workbook->close();   
  27. ?> 

以上代码示例就是PHP Spreadsheet_Excel_Writer的具体使用方法。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools