Reputation: 75247
I use java, jQuery and jsp at my web application. I want to learn that how can I import the values at my table to Excel file with JQuery at client side
. There are many examples and suggestions even at stackoverflow.com but I saw the solutions as server side as like Apache POI or something like that.
There is a datable plug-in: http://www.datatables.net/ at that plug-in it can be done to export the table data into a excel file I think at client side and so I am searching for a solution as like that.
Upvotes: 1
Views: 9037
Reputation: 2414
Use this VBScript for the client side export. Remember that you need to allow to run activex controls in the browser settings.
<script language="vbscript">
Function Export(objToExport)
ON ERROR RESUME NEXT
DIM sHTML, oExcel, fso, filePath
sHTML = document.all(objToExport).outerHTML
SET fso = CreateObject("Scripting.FileSystemObject")
filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel.xls"
fso.CreateTextFile(filePath).Write(sHTML)
DIM i
SET i = 0
DO WHILE err.number > 0
err.Clear()
filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel" & i & ".xls"
i = i + 1
LOOP
SET oExcel = CreateObject("Excel.Application")
IF err.number>0 OR oExcel = NULL THEN
msgbox("You need to have Excel Installed and Active-X Components Enabled on your System.")
Exit Function
END IF
oExcel.Workbooks.open(filePath)
oExcel.Workbooks(1).WorkSheets(1).Name = "My Excel Data"
oExcel.Visible = true
Set fso = Nothing
End Function
Upvotes: 0
Reputation: 6040
Why don't export easily yo CSV and MS Excel or any speadsheet appliation can parse the .csv file?
Here is a link for a jQuery Plugin called HTML Table to CSV
Here an example of the plugin: http://www.kunalbabre.com/projects/table2CSV.php
Upvotes: 1