栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

js导入导出excel(实例代码)

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

js导入导出excel(实例代码)

导入:
复制代码 代码如下:


     Untitled Page









导出:
复制代码 代码如下:
function AutomateExcel()
{
  
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
  
oXL.Visible = true;
  
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
  
// Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name";
oSheet.Cells(1, 2).Value = "Last Name";
oSheet.Cells(1, 3).Value = "Full Name";
oSheet.Cells(1, 4).Value = "Salary";
  
// Format A1:D1 as bold, vertical alignment = center.
oSheet.Range("A1", "D1").Font.Bold = true;
oSheet.Range("A1", "D1").VerticalAlignment = -4108; //xlVAlignCenter
  
// Create an array to set multiple values at once.
  
// Fill A2:B6 with an array of values (from VBscript).
oSheet.Range("A2", "B6").Value = CreateNamesArray();
  
// Fill C2:C6 with a relative formula (=A2 & " " & B2).
var oRng = oSheet.Range("C2", "C6");
oRng.Formula = "=A2 & " " & B2";
  
// Fill D2:D6 with a formula(=RAND()*100000) and apply format.
oRng = oSheet.Range("D2", "D6");
oRng.Formula = "=RAND()*100000";
oRng.NumberFormat = "$0.00";
  
// AutoFit columns A:D.
oRng = oSheet.Range("A1", "D1");
oRng.EntireColumn.AutoFit();
  
// Manipulate a variable number of columns for Quarterly Sales Data.
DispalyQuarterlySales(oSheet);
  
// Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = true;
oXL.UserControl = true;
}

将页面中指定表格的数据导入到Excel中


  




















编号姓名年龄性别
0001张三22
0002李四23





复制代码 代码如下:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



   
    WEB页面导出为EXCEL文档的方法


   
       
           
       
       
           
           
           
           
           
       
       
           
           
           
           
           
       
       
           
           
           
           
           
       
       
           
           
           
           
           
       
   

                WEB页面导出为EXCEL文档的方法
           

                列标题1
           

                列标题2
           

                列标题3
           

                列标题4
           

                列标题5
           

                aaa
           


           

                ccc
           

                ddd
           

                eee
           

                AAA
           


           

                CCC
           

                DDD
           

                EEE
           

                FFF
           

                GGG
           

                HHH
           

                III
           

                JJJ
           

   
   
   

   



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/109281.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号