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.