📜  jQuery | table2excel 插件

📅  最后修改于: 2021-11-24 04:33:33             🧑  作者: Mango

在网页设计和开发过程中,定期备份是遵循的重要实践。 jQuery 提供了table2excel插件,它有助于将 HTML 表格导出到 excel (.xls) 文件。

请从 jQuery table2excel插件下载所需的库文件,并将其包含在您的工作文件夹中,如以下示例所示。

下载链接: https://github.com/rainabba/jquery-table2excel

示例 1:以下示例演示了 table2excel插件的非常基本的功能。表格内容与标题一起导出到“GFGFile.xls”文件。



    
        jQuery table2excel plugin
        
        
    
    
        

GeeksForGeeks

        jQuery table2excel plugin         

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
CompanyNameCountry
IBMMariaGermany
TCSYen ChangMexico
MicrosoftRolandAustria
WiproHelenUK
SamsungYoshwiniCanada
VirtusaRovelliItaly
                                 

输出:

  • 出口前:

  • 在“GFGFile.xls”中导出后:

示例 2:在下面的示例中,将解释 table2excel插件并显示更多选项设置。在 HTML 结构中,采用两个表来显示导出文件中的不同结果。表格的第 1 行标题不会在输出 excel 文件中导出,因为它们已被分配了类“noExl”,如下面的程序所示。表 2 被分配了类“colorClass”,因此分配给任何 HTML 控件的颜色都被保留,如代码所示。程序员可以根据应用程序的要求设置选项。



    
        jQuery table2excel plugin
        
        
    
    
        

GeeksForGeeks

        jQuery table2excel plugin         

                                                                                                                                                                                                                                                                                             
                    Table 1 Header, column 1 (not exported)Table 1 Header, column 2(not exported)                 
Table 1 Header, column 1 (exported)Table 1 Header, column 2 (exported)
Row 1, column 1 data of table1Row 1 column 2 data of table 1
Row 2, column 1 data of table1Row 2, column 2 dataof table1
This is the footer of table 1.
        

                                                                                                                                                                                                                                                                                                
Table 2 Header, column 1 (not exported)Table 2 Header, column 1 (not exported)
    Table 2 Header, column 1 (exported with colors)Table 2 Header, column 2 (exported)
          Row 1, column 1 data of table2Row 1 column 2 data of table2
Row 2, column 1 data of table2Row 2, column 2 data of table2
                This is the footer of table 2
                         

输出:

  • 出口前:

  • 导出表 1 后:

  • 表 2 导出后: