Code for Generating word:
Copy codeThe Code is as follows:
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ('content-type: application/doc ');
Header ('content-Disposition: attachment; filename = "test .doc "');
Generate the excel Code:
Copy codeThe Code is as follows:
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: attachment; filename =" test .xls "');
However, you may also encounter many problems during the import process. For example, if an excel file is exported and an ID card number is exported in a column, you will find that the ID card number is automatically calculated in scientific notation, no matter how you modify this attribute, you cannot meet your requirements. Some people say on the Internet that it is okay to change the attribute of this column to text and then input the column. The actual excel operation is true, but the php program cannot export the column. Some people also say that adding single quotation marks before the ID card number will not work if you have tried it. The problem is solved by adding spaces before the exported ID card number data. spaces are spaces in html code. The problem is solved.