Welcome to the Linux community forum and interact with 2 million technical staff. I believe that you often encounter the excel file export function during PHP development. Here, you can share a simple code to implement this function. Let's look at the code :? Header (Content-type: applicationvnd. ms-excel); header (Content-Disposition:
Welcome to the Linux community forum and interact with 2 million technical staff> I believe that you often encounter the excel file export function during PHP development. Here, you can share a simple code to implement this function. Let's look at the code :? Header ("Content-type: application/vnd. ms-excel"); header ("Content-Disposition:
Welcome to the Linux community forum and interact with 2 million technicians>
I believe that you often encounter the excel file export function during PHP development. Here, you can share a piece of simple code to implement this function.
Let's look at the Code:
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: filename=test.xls ");
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
?>
When you run the above Code in the php environment, you can see the browser asking you whether to download the excel document, click Save, and an excel file is added to the hard disk, you can see the final result when using excel.
In fact, when doing real applications, you can extract the data from the database, and then add the data following each column, and echo the method after each row of data ends, use header ("Content-type: application/vnd. ms-excel ") indicates that the excel file is output, and the file name output is text.xls using header (" Content-Disposition: filename=test.xls.
In this case, OK. We can modify the header so that it can output more files in different formats. This makes php easier to process various types of files.