Data output to a WORD or EXCEL file

Source: Internet
Author: User
Tags blank page
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 ..
Method 2:
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
Home: http://www.zydn.net/index.asp
QQ: 8692589

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.