Last active
December 11, 2016 13:30
-
-
Save loo2k/a364bcc209d862a20302b1651ff07f0d to your computer and use it in GitHub Desktop.
使用 Node 根据模板批量生成文件并使用 VBScript 自动填写 excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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