PHP generates Excel or PHP generated CSV

Source: Internet
Author: User

First, PHP generates Excel

Using the Phpexcel class file to generate

Second, PHP generated CSV

<?php
$action = "Make";
if ($action = = ' Make ') {
$fp = fopen ("Demo_csv.csv", "a"); Open the CSV file and create it if it does not exist
$title = Array ("First_Name", "last_name", "Contact_email", "telephone"); First row of data

$data _1 = Array ("42343", "423432", "4234", "4234");
$data _2 = Array ("4234", "last_name", "Contact_email", "telephone");

$title = Implode (",", $title); Use ' Split into string '
$data _1 = Implode (",", $data _1); Use ' Split into string '
$data _2 = Implode (",", $data _2); Use ' Split into string '

$data _str = $title. " \ r \ n ". $data _1." \ r \ n ". $data _2." \ r \ n "; Add line break
Fwrite ($fp, $data _str); Write Data
Fclose ($FP); Close file handle
echo "Build Success";
}
echo "<br>";
echo "<a href= '? action=make ' > Generate CSV file </a>";
?>

PHP generates Excel or PHP generated CSV

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.