Home  >  Q&A  >  body text

Can you please explain how to use phpexcel to import and export excel and database?

Can you please explain how to use phpexcel to import and export excel and database!

Ж墨竹疏影ЖЖ墨竹疏影Ж2230 days ago1908

reply all(3)I'll reply

  • orzker

    orzker2018-10-06 16:23:57

    As for the process, first of all, there is a PHPExcel class library on github.

    Excel import

    Import the PHPExcel class library, then read the contents of the Excel table you imported and format it into the array format you need. Then it's up to you whether to display or store it in the database.

    Excel export

    Similarly, import the class library and determine the file name, content header and content of the table to be exported. Then the built-in style function of phpexcel sets the style, and the header function defines the file stream to transfer the table file data to the browser, and nothing else.

    Specific phpExcel built-in functions are available in Baidu, or you can directly look at the code in the class library.

    reply
    0
  • Ж墨竹疏影Ж

    Thanks, even though I don’t know it yet!

    Ж墨竹疏影Ж · 2018-10-06 17:56:43
    orzker

    You can search on Baidu for import and export of PHPExcel. Take a look at the code. If you don't understand it, copy it to Baidu to see the meaning of the function. Although the efficiency is slower, you can remember it more deeply. To put it bluntly, importing a table is nothing more than uploading the file first, and then using the function written in the PHPExcel class library to loop out the contents of the table file and organize it into an array. You can use functions to perform various operations on the array, and finally import it into the database. Exporting a table means taking out the data from the database, then defining the file name and table header, then locating the cell position and writing the array contents in a loop. For example: $PHPExcel->getactivesheet()->setcellvalue('A1',$list['name']); Finally, it is passed to the browser and downloaded directly. There are many specific functions used in PHPExcel, and it is impossible to write them all here. It is recommended that you go to Baidu to look at the codes written by others and learn their development ideas.

    orzker · 2018-10-16 10:48:34
  • Cancelreply