How does PHP import Excel files
This article mainly explains the "PHP how to import Excel file", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "PHP how to import Excel file" bar!
An example of PHP importing Excel file code is as follows:
SetOutputEncoding ('gb2312')
/ *
* if you want you can change'
Iconv' to mb_convert_encoding:
* $data- > setUTFEncoder ('mb')
* / / *
* By default rows & cols indeces start with 1
* For change initial index use:
* $data- > setRowColOffset (0)
* * /
/ *
* Some function for formatting output.
* $data- > setDefaultFormat ('.2f')
* setDefaultFormat-set format for
Columns with unknown formatting
* $data- > setColumnFormat (4,'% .3f')
* setColumnFormat-set format for
Column (apply only to number fields)
* * /
/ / specify the excel file to read
$data- > read ('.. / uploads/jsxz01.xls')
/ *
$data- > sheets [0] ['numRows']-count rows
$data- > sheets [0] ['numCols']-count columns
$data- > sheets [0] ['cells'] [$I] [$j]-data
From $i-row $j-column
$data- > sheets [0] ['cellsInfo'] [$I] [$j]-
Extended info about cell
$data- > sheets [0] ['cellsInfo'] [$I] [$j] [' type']
= "date" | "number" | "unknown"
If 'type' = = "unknown"-use' raw' value
Because cell contain value with format '0.00'
$data- > sheets [0] ['cellsInfo'] [$I] [$j] [' raw']
= value if cell without format
$data- > sheets [0] ['cellsInfo'] [$I] [$j] [' colspan']
$data- > sheets [0] ['cellsInfo'] [$I] [$j] [' rowspan']
, /
Error_reporting (E_ALL ^ E_NOTICE)
/ / read each unit value in a loop
For ($I = 1; $I sheets [0]
['numRows']; $iTunes +) {
For ($j = 1; $j sheets [0]
['numCols']; $jacks +) {
Echo "\". $data- > sheets [0] ['cells']
[$I] [$j]. "\",
}
Echo ""
}
/ / print_r ($data)
/ / print_r ($data- > formatRecords)
? >
Thank you for your reading, these are the contents of "how to import PHP into Excel files". After the study of this article, I believe you have a deeper understanding of how to import PHP into Excel files, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!