. Net: a method for exporting Word

Source: Internet
Author: User

ActiveX controls only support IE (it seems that FF can be supported by installing plug-ins), so the method of exporting word in js is quite limited.

However, after the page is modified by js,. net cannot be obtained. Therefore, you need to use js to obtain the latest html and send it to the background to generate a file stream for download.

$ ("# Expword "). click (form = $ ("<form>" form. attr ('style', 'display: none' form. attr ('target', ''form. attr ('method', 'post' form. attr ('action', 'exportword. aspx 'input1 = $ ('<input> 'input1.attr ('type', 'did' input1.attr ('name', 'curdidhtml' input1.attr ('value ', $ ('# divArea' $ ('body'}); View Code


To transmit html content in the preceding method, you must add ValidateRequest = "false" to the Source Page and the "ExportWord. aspx" page"

After obtaining the html content, input the following method to output the word file through Response.

ExportHTML (html, HttpContext. current. response. appendHeader (, + HttpUtility. urlEncode (filename + HttpContext. current. response. contentType = HttpContext. current. response. charset = HttpContext. current. response. contentEncoding =} View Code

 

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.