Skip to content

Instantly share code, notes, and snippets.

@loo2k
Last active December 11, 2016 13:30
Show Gist options
  • Save loo2k/a364bcc209d862a20302b1651ff07f0d to your computer and use it in GitHub Desktop.
Save loo2k/a364bcc209d862a20302b1651ff07f0d to your computer and use it in GitHub Desktop.
使用 Node 根据模板批量生成文件并使用 VBScript 自动填写 excel
Sub autoFiller()
For i = 1 To 100
' get filename
Dim name As String
name = Application.ActiveSheet.Range("H" & CStr(i + 2)) & Application.ActiveSheet.Range("I" & CStr(i + 2)) & "-" & Application.ActiveSheet.Range("B" & CStr(i + 2)) & ".xls"
' declare obj
Set ObjExcel = CreateObject("Excel.Application")
Set ObjWb = ObjExcel.Workbooks.Open("D:\auto\list\" & name)
' operation
Dim f4 As String
f4 = Application.ActiveSheet.Range("F" & CStr(i + 2))
ObjWb.Worksheets("Sheet1").Range("F4").Value = f4
' savefile
ObjWb.Save
ObjWb.Close
ObjExcel.Quit
'cleanup
Set ObjWb = Nothing
Set ObjExcel = Nothing
Next i
End Sub
var fs = require('fs');
var list = [
'AT20160318001-邓君',
'20160318002-石名',
'20160318003-郭芷'
];
// 批量生成文件模板
var template = fs.createReadStream('template.xls');
for (var i = 0; i < list.length; i++) {
template.pipe(fs.createWriteStream(list[i] + '.xls'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment