Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does PHP import Excel files

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report