ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:19.95KB ,
资源ID:5761025      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5761025.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(js操作wordexcel.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

js操作wordexcel.docx

1、js操作wordexcelJS操作Word和Excel的方法* 单元格1 单元格2 单元格3 单元格4 单元格合并test function MakeWord() var word = new ActiveXObject(Word.Application); / var doc = word .documents.open(c:test.doc); /此处为打开已有的模版var doc = word .Documents.Add(,0,1);/不打开模版直接加入内容 var Range=doc.Range(); var sel = document.body.createTextRange()

2、; sel.moveToElementText(form);/此处form是页面form的id sel.select(); sel.execCommand(Copy); Range.Paste(); word .Application.Visible = true; alert(s); word.Application.Selection.InlineShapes.AddPicture(c:m20.gif); alert(n); doc .saveAs(c:ba.doc); /存放到指定的位置注意路径一定要是“”不然会报错 *2.用JS生成WORD* function wordcontorl(

3、) alert(1111) var WordApp=new ActiveXObject(Word.Application); var wdCharacter=1var wdOrientLandscape = 1WordApp.Application.Visible=true;var myDoc=WordApp.Documents.Add(); WordApp.ActiveDocument.PageSetup.Orientation = wdOrientLandscape WordApp. Selection.ParagraphFormat.Alignment=1 /1居中对齐,0为居右Word

4、App. Selection.Font.Bold=true WordApp. Selection.Font.Size=20 WordApp. Selection.TypeText(我的标题); WordApp. Selection.MoveRight(wdCharacter);/光标右移字符 WordApp.Selection.TypeParagraph()/插入段落 WordApp. Selection.Font.Size=12 WordApp. Selection.TypeText(副标题); /分行插入日期 WordApp.Selection.TypeParagraph()/插入段落 v

5、ar myTable=myDoc.Tables.Add (WordApp.Selection.Range, 8,7) /8行7列的表格 /myTable.Style=网格型 var aa = 我的列标题 var TableRange; /以下为给表格中的单元格赋值 for (i= 0;i7;i+) with (myTable.Cell(1,i+1).Range) font.Size = 12;InsertAfter(aa);ColumnWidth =4for (i =0;i7;i+)for (n =0;n7 ;n+) with (myTable.Cell(i+2,n+1).Range) fon

6、t.Size = 12; InsertAfter(bbbb); row_count = 0; col_count = 0myDoc.Protect(1)wordcontorl()*3.遍历导出到word*1、遍历导出每个文本框内的内容。function OpenWord()/导出wordvar txt=txt;for(i=0;itable1.rows.length;i+)/遍历导出图表和文字txt=txt+jilui;myRange =mydoc.Range(myRange.End-1,myRange.End);/设定起始点var sel=Layer1.document.body.create

7、TextRange();/sel.moveToElementText(table1);sel.moveToElementText(document.alltxt);sel.select();Layer1.document.execCommand(Copy);sel.moveEnd(character);myRange.Paste();myRange =mydoc.Range(myRange.End-1,myRange.End);myRange.InsertAfter(n);ExcelSheet.ActiveWindow.View.TableGridlines = false;/隐藏虚框2、拷贝

8、table1内的内容到wordfunction OpenWord()/导出wordLayer1.style.border=0;ExcelSheet = new ActiveXObject(Word.Application);ExcelSheet.Application.Visible = true;var mydoc=ExcelSheet.Documents.Add(,0,0);myRange =mydoc.Range(0,1);myRange =mydoc.Range(myRange.End-1,myRange.End);/设定起始点var sel=Layer1.document.body.

9、createTextRange();sel.moveToElementText(table1);sel.select();Layer1.document.execCommand(Copy);sel.moveEnd(character);myRange.Paste();myRange =mydoc.Range(myRange.End-1,myRange.End);myRange.InsertAfter(n);ExcelSheet.ActiveWindow.View.TableGridlines = false; *4.操作excel*content function MakeExcel() va

10、r i, j, n; try var xls = new ActiveXObject(Excel.Application); catch(e) alert( 要打印该表,您必须安装Excel电子表格软件,同时浏览器须使用“ActiveX 控件”,您的浏览器须允许执行控件。请点击【帮助】了解浏览器设置方法!); return ; xls.visible =true; / 设置excel为可见 var xlBook = xls.Workbooks.Add; var xlsheet = xlBook.Worksheets(1); xlsheet.Range(xlsheet.Cells(1,1),xl

11、sheet.Cells(1,7).mergecells=true; xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,7).value=发卡记录; xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,3).Interior.ColorIndex=5; / 设置底色为蓝色 / xlsheet.Range(xlsheet.Cells(1,1),xlsheet.Cells(1,6).Font.ColorIndex=4; / 设置字体色 / xlsheet.Rows(1). Interior .ColorIn

12、dex = 5 ;/设置底色为蓝色 设置背景色 Rows(1).Font.ColorIndex=4 xlsheet.Rows(1).RowHeight = 25; xlsheet.Rows(1).Font.Size=14; xlsheet.Rows(1).Font.Name=黑体; xlsheet.Columns(A:D).ColumnWidth =18; xlsheet.Columns(2).NumberFormatLocal=; xlsheet.Columns(7).NumberFormatLocal=; /设置单元格内容自动换行 range.WrapText = true ; /设置单元

13、格内容水平对齐方式 range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;/设置单元格内容竖直堆砌方式 /range.VerticalAlignment=Excel.XlVAlign.xlVAlignCenter /range.WrapText = true; xlsheet.Rows(3).WrapText=true 自动换行 /设置标题栏 xlsheet.Cells(2, 1).Value = 卡号; xlsheet.Cells(2, 2).Value = 密码; xlsheet.Cells(2, 3).Value = 计费方式

14、; xlsheet.Cells(2, 4).Value = 有效天数; xlsheet.Cells(2, 5).Value = 金额; xlsheet.Cells(2, 6).Value = 所属服务项目; xlsheet.Cells(2, 7).Value = 发卡时间; var oTable = document.allfors:data; var rowNum = oTable.rows.length; for(i = 2; i = rowNum; i+) for (j = 1; j = 7; j+) /html table类容写到excel xlsheet.Cells(i + 1, j

15、).Value = oTable.rows(i - 1).cells(j - 1).innerHTML; / xlsheet.Range(xlsheet.Cells(i, 4), xlsheet.Cells(i-1, 6).BorderAround , 4 / for(mn=1,mn=6;mn+) . xlsheet.Range(xlsheet.Cells(1, mn), xlsheet.Cells(i1, j).Columns.AutoFit; xlsheet.Columns.AutoFit; xlsheet.Range( xlsheet.Cells(1,1),xlsheet.Cells(r

16、owNum+1,7).HorizontalAlignment =-4108;/居中 xlsheet.Range( xlsheet.Cells(1,1),xlsheet.Cells(1,7).VerticalAlignment =-4108; xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7).Font.Size=10; xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7).Borders(3).Weight = 2; /设置左边距 xlsheet.Range(

17、xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7).Borders(4).Weight = 2;/设置右边距 xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7).Borders(1).Weight = 2;/设置顶边距 xlsheet.Range( xlsheet.Cells(2,1),xlsheet.Cells(rowNum+1,7).Borders(2).Weight = 2;/设置底边距 xls.UserControl = true; /很重要,不能省略,不然会出问题 意思是exce

18、l交由用户控制 xls=null; xlBook=null; xlsheet=null; ziyuanweihu 卡号 密码 计费方式 有效天数 金额 所属服务项目 发卡时间 h000010010 543860 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010011 683352 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010012 433215 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010013 393899 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010014 031736 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010015 188600 计点 2.0 测试项目 2006-06-23 10:14:40.843 h000010016 363407 计点 2.0 测试项目 20

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1