实现效果:
- 补全Excel序号
- 需实现效果1:递增补全,第一次1-10,第二次1-20,第三次1-30
- 需实现效果2:不足10补全到10,例结尾序号为1补2-10、结尾序号为12补13-20、结尾序号59补60
需实现效果1- Plugin.lxj_Office.lxj_ExcelOpen "C:\Users\Administrator\Desktop\1.xls",1
- 行号1 = 1
- 行号2 = 1
- Do
- var = var+10
- For i = 1 To var
- TracePrint "序号为"&i&",读取行号为"&行号1
- a = Plugin.lxj_Office.lxj_ExcelRead(1, 行号1, 1)
- If a="" Then
- Exit Do
- End If
- If a <> "" and instr(a, i) > 0 Then
- Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,1,a
- b=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,2)
- Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,2,b
- TracePrint "代码不为空"&b
- c=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,3)
- Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,3,c
- d=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,4)
- Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,4,d
- e=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,5)
- Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,5,e
- 行号1 = 行号1 + 1
- 行号2 = 行号2 + 1
- Else
- TracePrint "代码为空,或编号错误" & i
- Plugin.lxj_Office.lxj_ExcelWrite 2, 行号2, 1, i
- 行号2 = 行号2 + 1
- End If
- Delay 50
- Next
- Loop
- Sub OnScriptExit()
- Plugin.lxj_Office.lxj_ExcelClose
- End Sub
复制代码 需实现效果2Plugin.lxj_Office.lxj_ExcelOpen "C:\Users\Administrator\Desktop\1.xls",1
行号1 = 1
行号2 = 1
i = 1
Do
Do
TracePrint "序号为"&i&",读取行号为"&行号1
a = Plugin.lxj_Office.lxj_ExcelRead(1, 行号1, 1)
If a="" Then
ExitScript
End If
If a <> "" and instr(a, i) > 0 Then
Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,1,a
b=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,2)
Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,2,b
TracePrint "代码不为空"&b
c=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,3)
Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,3,c
d=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,4)
Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,4,d
e=Plugin.lxj_Office.lxj_ExcelRead (1,行号1,5)
Plugin.lxj_Office.lxj_ExcelWrite 2,行号2,5,e
行号1 = 行号1 + 1
行号2 = 行号2 + 1
Else
TracePrint "代码为空,或编号错误" & i
Plugin.lxj_Office.lxj_ExcelWrite 2, 行号2, 1, i
行号2 = 行号2 + 1
If i mod 10 = 0 Then
i=1
Exit Do
End If
End If
i=i+1
Delay 50
Loop
Loop
Sub OnScriptExit()
Plugin.lxj_Office.lxj_ExcelClose
End Sub