Dim dt As DataTable = DataTables("工资摘要名称")
Dim f1 As String = (projectPath & "\模板\工资表.xls")
Dim f0 As String = (projectpath & "\工资\汇总工资")
If not FileSys.DirectoryExists(f0) Then
FileSys.CreateDirectory(f0)
End If
Dim f2 As String = (f0 & "\工资.xls")
If FileSys.FileExists(f2) Then
FileSys.DeleteFile(f2)
End If
FileSys.CopyFile(f1,f2, True)
Dim App As New MSExcel.Application
Dim wb As MSExcel.WorkBook = App.WorkBooks.open(f2)
Dim ws1 As MSExcel.WorkSheet = wb.WorkSheets("工资")
Dim jzkms As List(of String) = dt.GetValues("记账科目", "是否录入 = true", "序号")
Dim idx As Integer = 3
Dim rg = ws1.Range("C:C")
For Each jzkm As String In jzkms
Dim gzzys As List(Of String) = dt.GetValues("工资摘要", "记账科目 = '" & jzkm & "'", "序号")
Dim pidx As Integer = idx
For i As Integer = 0 To gzzys.count-1
Rg.EntireColumn.Insert(MSExcel.XlInsertShiftDirection.xlShiftToRight)
ws1.cells(2, idx).Value = gzzys(i)
ws1.cells(2, idx).HorizontalAlignment = MSExcel.Constants.xlCenter '水平居中
idx += 1
Next
Dim nrg = ws1.range(ws1.cells(1, pidx).address, ws1.cells(1,idx-1).address) ''''
nrg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous '边框线型
nrg.Borders.Weight = MSExcel.XlBorderWeight.xlThin'边框粗细
nrg.Borders.ColorIndex = 1'边框颜色
nrg.merge
ws1.cells(1, pidx).value = jzkm
nRg.HorizontalAlignment = MSExcel.Constants.xlCenter '水平居中
Dim nrg1 = ws1.range(ws1.cells(3, pidx).address, ws1.cells(3,idx-1).address) ''''
nrg1.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous '边框线型
nrg1.Borders.Weight = MSExcel.XlBorderWeight.xlThin'边框粗细
nrg1.Borders.ColorIndex = 1'边框颜色
nrg1.merge
ws1.cells(3,pidx).Formula = "=sum(" & nrg1 & ")"
nRg1.HorizontalAlignment = MSExcel.Constants.xlCenter '水平居中
Next
'Dim s As String = ws1.cells(1, idx).address.Substring(1,1)
'ws1.range(s & ":" & s).delete
rg = ws1.range("6:6")
idx = 0
Dim n1 As Integer = 0
For Each r As Row In Tables("职工资料").Rows
Rg.EntireRow.Insert(MSExcel.XlInsertShiftDirection.xlShiftDown)
ws1.cells(r.Index+5, 1).Value = r.Index+1
ws1.cells(r.Index+5, 2).Value = r("姓名")
idx += 1
For n As Integer = 0 To Tables("工资摘要名称").rows.count-1
Dim fdr As DataRow = DataTables("过导工资明细表").find("姓名 = '" & r("姓名") & "' and 工资摘要 = '" & ws1.cells(2,3+n).value & "'")
If fdr IsNot Nothing Then
ws1.cells(5+n1,3+n).value = fdr("金额")
End If
Next
n1=n1+1
Next
ws1.range(idx+5 & ":" & idx+6).Delete
App.Visible = True
'ws1.UsedRange.Formula = ws1.UsedRange.Formula
'app.ActiveWindow.DisplayZeros = False
代码中合计、小计以及最后一列的人员工资合计的公式应如何加入代码?ws1.cells(3,pidx).Formula = "=sum(" & nrg1 & ")"