Go to: Export Excel using JavaScript

Source: Internet
Author: User

From: http://www.iteye.com/topic/178043

 

Today, I have no intention of finding the JS Excel export function for a long time. I feel good to use it. I have seen many people export JavaScript excel on the Internet, but it is always a headache to export EXCEL from Table lines, here is a simple JS export.
This is just a simple demo. First, the static page

<HTML xmlns = "http://www.w3.org/1999/xhtml"> 

Next, call JS

 
<Script language = JavaScript> function Preview () {window. clipboardData. setdata ("text", document. all ('table1 '). outerhtml); try {var exapp = new activexobject ("Excel. application ") var exwbk = exapp. workbooks. add () var exwsh = exwbk. worksheets (1) exapp. displayalerts = falseexapp. visible = true} catch (e) {alert ("Microsoft Excel software is not installed on your computer! ") Return false} exwbk. worksheets (1). paste ;}</SCRIPT>

 

Very simple. If you are interested, try it.

This JS file is exported Based on the table ID. This JS file has the disadvantage of exporting the "View" of the last column to an Excel file. Solution: Output a hidden table on this page and mark it. This hidden table only contains data. In this way, click Export to export only data. The method is heavy. I hope there are other solutions. If you have any, please advise.

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.