Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
I often want to read the content in the database and generate an EXCEL or WORD file. Let's talk about my handling methods and ideas. If not, please advise me.
There is one of the simplest methods:
Is the preceding addition:
Response. ContentType = "Application/msexcel"
Then it will be opened in EXCEL.
However, this method may cause many strange problems. For example, some machines can be switched on, some machines cannot work, and different OFFICE versions may not work. It may also be a blank page ..
Through the experiment, we found that the extension of an HTML table was changed to XLS. Double-click the table and the computer opened it in EXCEL, if different versions of EXCEL are used. maybe the table line is gone.
Well, this is easy to do. We read the content in the database, generate an HTML table, and write the table into a file with the extension of XLS. Then, turning to this XLS file almost succeeded. however, there are three problems: 1. sometimes it may be blank, 2. when it is disabled, the operation is invalid and an EXCEL process is left. 3. the table line is gone.
The solution to these three problems is as follows:
First problem: do not turn to the temporary XLS file immediately after it is generated.
The second and third questions:
When I create a table in EXCEL and save it as HTML, I will find that if I direct it to this file, there is no error in the format, and there is no invalid operation prompt when I close it, there is no such process. open the HTM file and check its code. You can find a lot of code above. Each <TD> in the table has more code. okay. in the future, we will also draw a gourd based on the format to generate a file with the extension of XLS (actually an HTML file ).
The above is my method. Please talk about your method. I hope to find a better solution,
A Yu's EMAIL: ZYDN@MEIYUAN.NET
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.