excel|word| data often has to read the contents of the database and generate an Excel file or Word file. Let me talk about my approach and ideas. Please advise the Master
One of the easiest ways to do this is to:
Is the front Plus:
Response.ContentType = "Application/msexcel"
Then it will be opened with Excel.
However, this method will appear a lot of strange problems, such as some machine can be opened, some machines are not, different Office version may not be, but also open a blank page and so on.
The second method:
Through the experiment, we found that an HTML table extension to XLS, double-click, the computer actually opened with Excel, look closely, still like the model, that is, if different versions of Excel to open. Maybe the form line is gone.
Well, that's a good time to read the contents of our database, generate a table in HTML format, then write this table in a file with the extension xls, and then turn to the XLS file, almost done. However, there are three questions to be found: 1. Sometimes opening may be a blank, 2. Illegal operation when closing, and leave an Excel process. 3. The form line is gone.
The solutions to these three problems are as follows:
First question: After generating this temporary XLS file, do not immediately turn to it, after a two-second turn.
The second and third question:
I do a table in Excel, then save as HTML format, you will find that if you turn to this file, the format is not wrong, there is no illegal operation to close the hint, there is no more than that process. Then open this HTM file a look at its code, found in front of a lot of code, the table of each < Td> more code after that. Ok. We'll also dots in this format to generate a file with the extension XLS (which is actually an HTML file).
The above is my method, please talk about your own method, I hope to get a better way,
Ah Yu's email:zydn@meiyuan.net
Home: http://www.zydn.net/index.asp
qq:8692589