如何使用JQuery在客户端将表导出到Excel文件?

发布于 2024-11-01 17:53:24 字数 305 浏览 6 评论 0原文

我在我的 Web 应用程序中使用 java、jQuery 和 jsp。我想了解如何使用客户端的 JQuery 将表中的值导入 Excel 文件。即使在 stackoverflow.com 上也有很多示例和建议,但我看到了服务器端的解决方案,例如 Apache POI 或类似的东西。

有一个数据插件: http://www.datatables.net/ 该插件我认为可以在客户端将表数据导出到 Excel 文件中,所以我正在寻找类似的解决方案。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

锦上情书 2024-11-08 17:53:24

为什么不轻松导出 CSV 和 MS Excel 或任何可以解析 .csv 文件的电子表格应用程序?

这是一个名为 HTML Table to CSV 的 jQuery 插件的链接

,这是该插件的示例:< a href="http://www.kunalbabre.com/projects/table2CSV.php" rel="nofollow">http://www.kunalbabre.com/projects/table2CSV.php

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

如梦 2024-11-08 17:53:24

使用此 VBScript 进行客户端导出。请记住,您需要在浏览器设置中允许运行 activex 控件。

<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 

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 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文