<?php
Class excel{
var $header = "<?xml version=" 1.0 "encoding=" UTF-8 "?>"
<workbook xmlns= "Urn:schemas-microsoft-com:office:spreadsheet"
xmlns:x= "Urn:schemas-microsoft-com:office:excel"
Xmlns:ss= "Urn:schemas-microsoft-com:office:spreadsheet"
Xmlns:html= "HTTP://WWW.W3.ORG/TR/REC-HTML40" > ";
var $footer = "</Workbook>";
var $lines = array ();
var $worksheet _title = "Table1";
function AddRow ($array) {
Initializing columns
$cells = "";
foreach key-> write value into cells
foreach ($array as $k => $v):
Add a string and a number to avoid the generated Excel appears with a warning that the number is stored as a string
if (Is_numeric ($v)) {
Prevent 0 loss After Excel is generated from the first letter 0 o'clock
if (substr ($v, 0, 1) = 0) {
$cells. = "<cell><data ss:type=" String ">". $v. "</Data></Cell>";
} else {
$cells. = "<cell><data ss:type=" number ">". $v. "</Data></Cell>";
}
} else {
$cells. = "<cell><data ss:type=" String ">". $v. "</Data></Cell>";
}
Endforeach;
Transform $cells content into one row
$this->lines[] = "<Row>". $cells. "</Row>";
}
function AddArray ($array) {
Returns an array and saves it to a cell
foreach ($array as $k => $v):
$this->addrow ($v);
Endforeach;
}
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