Home  >  Article  >  Backend Development  >  How to use PHP correctly Spreadsheet_Excel_Writer_PHP tutorial

How to use PHP correctly Spreadsheet_Excel_Writer_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:33:101066browse

When using

In fact, among many methods, I feel that Spreadsheet_Excel_Writer in Pear is very useful. This article will not introduce the installation of PHP Spreadsheet_Excel_Writer.

The following is the quoted content of PHP Spreadsheet_Excel_Writer:

  1. < ?php
  2. //Call Writer.php
  3. require_once 'Spreadsheet/Excel/Writer.php';
  4. //Create Workbook
  5. $workbook = new Spreadsheet_Excel_Writer();
  6. //Define export Excel file name
  7. $workbook->send('test.xls');
  8. //Create Worksheet
  9. $worksheet =& $workbook->addWorksheet('My first worksheet');
  10. //Set font size
  11. $format_column = & $workbook->addformat(array('Size'=>9,'Bold'=>1));
  12. //Data writing
  13. //Title row (first line)
  14. $worksheet->write(0, 0, 'Name', $format_column);
  15. $worksheet-> write(0, 1, 'Age', $format_column);
  16. //The first person (second line)
  17. $worksheet->write(1, 0, 'John Smith' );
  18. $worksheet->write(1, 1, 30 );
  19. //The second person (third line)
  20. $worksheet->write(2, 0, 'Johann Schmidt');
  21. $worksheet->write(2, 1, 31);
  22. //The third person (fourth line)
  23. $worksheet->write(3, 0, 'Juan Herrera' );
  24. $worksheet->write(3, 1, 32 );
  25. //Close Workbook
  26. $workbook-> close(); 🎜>
  27. The above code example is the specific usage of PHP Spreadsheet_Excel_Writer.
  28. www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446092.htmlTechArticleIn fact, among many methods, I feel that Spreadsheet_Excel_Writer in Pear is very easy to use. This article will not introduce the installation of PHP Spreadsheet_Excel_Writer. The following is PHP Spreadsheet_E...
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