Manipulating Excel Instance code in PHP

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags address address bar application browser code file http name

Save the file as a "excelsample.php tutorial" in the Htdocs folder. Open the browser and enter in the Address bar:

The current version of Excel is displayed on the page, and the workbook named Php_excel_test.xls is created and the test is entered in the worksheet Sheet1 cell A1.
Open the workbook Php_excel_test.xls and you will see that you have entered the test in cell A1.
Note: In order to prevent garbled, the code format has been set up and the file is saved in gb2312 format.

Specify page encoding to prevent the occurrence of garbled Chinese
Header (' content-type:text/html charset=gb2312 ');

Start Excel
$ms _excel=new COM ("Excel.Application") or Die ("Cannot open Excel application");

Display the current version of Excel in a Web page
echo "Excel version: {$ms _excel->version}n";

Create a new workbook
$ms _excel->application->workbooks->add () or Die ("Cannot add a new workbook");

Enter text in cell A1 in the worksheet Sheet1 of the workbook
$ms _excel->worksheets ("Sheet1")->range ("A1")->value= "test";

Save the workbook, if you do not specify a path, the default is saved in my document
$ms _excel->workbooks (1)->saveas ("Php_excel_test.xls");

Close Workbook
$ms _excel->quit ();

Empty objects
$ms _excel=null;

Related Article

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: 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.