1.保存html页面到word
2.用JS生成WORD
<script> <BR>function wordcontorl(){ <BR>alert("1111") <BR>var WordApp=new ActiveXObject("Word.Application"); <br><br>var wdCharacter=1 <BR>var wdOrientLandscape = 1 <BR>WordApp.Application.Visible=true; <BR>var myDoc=WordApp.Documents.Add(); <br><br>WordApp.ActiveDocument.PageSetup.Orientation = wdOrientLandscape <br><br>WordApp. Selection.ParagraphFormat.Alignment=1 //1居中对齐,0为居右 <BR>WordApp. Selection.Font.Bold=true <BR>WordApp. Selection.Font.Size=20 <br><br>WordApp. Selection.TypeText("我的标题"); <BR>WordApp. Selection.MoveRight(wdCharacter); //光标右移字符 <BR>WordApp.Selection.TypeParagraph() //插入段落 <BR>WordApp. Selection.Font.Size=12 <BR>WordApp. Selection.TypeText("副标题"); //分行插入日期 <BR>WordApp.Selection.TypeParagraph() //插入段落 <br><br><br><br>var myTable=myDoc.Tables.Add (WordApp.Selection.Range, 8,7) //8行7列的表格 <BR>//myTable.Style="网格型" <BR>var aa = "我的列标题" <br><br>var TableRange; //以下为给表格中的单元格赋值 <BR>for (i= 0;i<7;i++) <BR>{ <BR>with (myTable.Cell(1,i+1).Range) <BR>{ <BR>font.Size = 12; <BR>InsertAfter(aa); <BR>ColumnWidth =4 <BR>} <BR>} <br><br>for (i =0;i<7;i++) <BR>{ <BR>for (n =0;n<7 ;n++) <BR>{ <br><br>with (myTable.Cell(i+2,n+1).Range) <BR>{font.Size = 12; <BR>InsertAfter("bbbb"); <BR>} <BR>} <BR>} <BR>row_count = 0; <BR>col_count = 0 <BR>myDoc.Protect(1) <BR>} <BR>wordcontorl() <BR></script>
***************************************************************************************************
3.遍历导出到word
***************************************************************************************************
1、遍历导出每个文本框内的内容。
2、拷贝table1内的内容到word
**************************************************************************************************
4.操作excel
**************************************************************************************************
******************************************************************************************************
5.有关用js实现网页中的内容直接转化为excel的方法
******************************************************************************************************
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<script> <BR>function out(){ <BR>try{ <BR>var elTable = document.getElementById("out"); <BR>var oRangeRef = document.body.createTextRange(); <BR>oRangeRef.moveToElementText( elTable ); <BR>oRangeRef.execCommand( "Copy" ); <BR>var oXL = new ActiveXObject("Excel.Application") <BR>var oWB = oXL.Workbooks.Add ; <BR>var oSheet = oWB.ActiveSheet ; <BR>oSheet.Paste(); <BR>oSheet.Cells.NumberFormatLocal = "@"; <BR>oSheet.Columns("D:D").Select <BR>oXL.Selection.ColumnWidth = 20 <BR>//oSheet.Columns("A:A").Select <BR>//oSheet.Columns("A").Width = 1000; <BR>oXL.Visible = true; <BR>oSheet = null; <BR>oWB = null; <BR>appExcel = null; <BR>}catch(e){alert(e.description)} <BR>} <BR></script>
00001 |
0002 |
00001 |
000002 |
0003 |
00003 |