⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 复件 default.vbs

📁 漂亮的模板,商店销售统计,日销售,月销售统计,销售录入
💻 VBS
字号:
<s cript language="vbs cript">


Sub buildDoc


set table = document.all.data   //把html文档中的表格data的结构和数据赋值给table


row = table.rows.length   //row为table的行数


column = table.rows(1).cells.length   //colnum为table的列数


Set objWordDoc = CreateObject("Word.Document")  //创建一个Word.Document的对象


Dim theArray(10,10000)   //定义数组变量,存放表格中的数据,10是虚拟列数,10000是虚拟行数


//以下两层for循环将html文档的表格中的纯文本数据赋值给数组


for i=0 to row-1


for j=0 to column-1


theArray(j+1,i+1) = table.rows(i).cells(j).innerTEXT  


next


next


 


objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("公司员工统计表")   //显示表格标题


objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("") //输出标题后回车换行


 


Set rngPara = objWordDoc.Application.ActiveDocument.Paragraphs(1).Range


//以下With代码段设置标题属性


With rngPara


.Bold = True   //将标题设为粗体


.ParagraphFormat.Alignment = 1   //将标题居中


.Font.Name = "Arial"    //设定标题字体


.Font.Size = 12    //设定标题字体大小


End With


 


Set rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range


Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,row,column)


//以下for循环输出表头


for i = 1 to column


objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)


objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1


next


//以下两层for循环输出表格实际内容


For i =1 to column


For j = 2 to row


objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter theArray(i,j)


objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1


Next


Next


objWordDoc.Application.ActiveDocument.SaveAs


End Sub


</s cript>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -