白开心

  IT博客 :: 首页 ::  :: 联系 :: 聚合  :: 管理 ::
  9 随笔 :: 76 文章 :: 28 评论 :: 0 Trackbacks

 

//导入Word文档
function tableToWord() 
{
  
var oWD = new ActiveXObject("Word.Application");
  
var oDC = oWD.Documents.Add("",0,1);
  
var oRange =oDC.Range(0,1);
  
var sel = document.body.createTextRange();
  sel.moveToElementText(theObjTable);
  sel.select();
  sel.execCommand(
"Copy");
  oRange.Paste();
  oWD.Application.Visible 
= true;
  }


//导入Excel文档
function tableToExcel()

 window.clipboardData.setData(
"Text",document.all('theObjTable').outerHTML);
 
try
 
{
 
var ExApp = new ActiveXObject("Excel.Application")
 
var ExWBk = ExApp.workbooks.add()
 
var ExWSh = ExWBk.worksheets(1)
 ExApp.DisplayAlerts 
= false
 ExApp.visible 
= true
 }
  
 
catch(e)
 
{
 alert(
"您的电脑没有安装Microsoft Excel软件!")
 
return false
 }
 
  ExWBk.worksheets(
1).Paste;
 }



function createWord()
{
 
var oWD = new ActiveXObject("Word.Application");
 
var oDC = oWD.Documents.Add("",0,1);
 oWD.Application.Visible 
= true;
 
 
var rngCurrent = oWD.Application.ActiveDocument.Content;
    
var tabCurrent = oWD.Application.ActiveDocument.Tables.Add(rngCurrent,20,4);
 
 
for(i=1;i<20;i++)
 
{
  oWD.Application.ActiveDocument.Tables(
1).Rows(i).Borders.Enable = true;
  oWD.Application.ActiveDocument.Tables(
1).Rows(i).Cells(1).Range.InsertAfter("a");
  oWD.Application.ActiveDocument.Tables(
1).Rows(i).Cells(2).Range.InsertAfter("b");
  oWD.Application.ActiveDocument.Tables(
1).Rows(i).Cells(3).Range.InsertAfter("c");
  oWD.Application.ActiveDocument.Tables(
1).Rows(i).Cells(4).Range.InsertAfter("d");
 }

}

posted on 2006-07-06 10:30 白开心 阅读(3541) 评论(0)  编辑 收藏 引用 所属分类: JavaScript
只有注册用户登录后才能发表评论。