PHP Excel export Spreadsheet_Excel_Writer

Source: Internet
Author: User
Tags php excel
PHP Excel export Spreadsheet_Excel_Writer Excel

I have seen a lot of articles about exporting Excel from PHP, and I have done so in many ways,

For example, echo a Table and modify the header to Excel.

In fact, among the many methods, it seems that Spreadsheet_Excel_Writer in Pear is very useful.

This article does not describe how to install Spreadsheet_Excel_Writer.

The answer :) can also refer to: http://pear.php.net/package/Spreadsheet_Excel_Writer/download

Reference content is as follows:
// Call Writer. php
Require_once 'Spreadsheet/Excel/Writer. php ';
// Create a Workbook
$ Workbook = new Spreadsheet_Excel_Writer ();
// Define the exported Excel file name
$ Workbook-> send('test.xls ');
// Create a Worksheet
$ Worksheet = & $ workbook-> addWorksheet ('my first worksheet ');
// Set the font size
$ Format_column = & $ workbook-> addformat (array ('size' => 9, 'bold '=> 1 ));
// Write data
// Title line (first line)
$ Worksheet-> write (0, 0, 'name', $ format_column );
$ Worksheet-> write (0, 1, 'age', $ format_column );
// The first person (row 2)
$ Worksheet-> write (1, 0, 'johnsmith ');
$ Worksheet-> write (1, 1, 30 );
// Second person (row 3)
$ Worksheet-> write (2, 0, 'Johann Schmidt ');
$ Worksheet-> write (2, 1, 31 );
// Third person (row 4)
$ Worksheet-> write (3, 0, 'Juan Herrera ');
$ Worksheet-> write (3, 1, 32 );
// Close The Workbook
$ Workbook-> close ();
?>

:

Of course, Spreadsheet_Excel_Writer has more than these settings. for details, see:

Http://pear.php.net/package/Spreadsheet_Excel_Writer/docs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.