我的代码如下:
Dim Book As New XLS.Book(ProjectPath & "Attachments\个税计算表-正常工资薪金.xls")
Dim fl As String = dlg.SelectedPath & "\个税计算表(正常工资薪金)-" & dwmc & right(cstr(jt.Year),2) & "-" & cstr(jt.Month).PadLeft(2,"0") & ".Xls"
Dim sql As String
sql="SELECT 税款所属期,姓名,养老金,公积金,独子费,通信费,待保,医保,企业年金,其他," & Functions.Execute("SQLAs","奖金","福利收入","外单位收入","奖金") & "工资,收入总额," & _
"允许扣除费用,累计费用扣除标准,子女教育,继续教育,房贷利息,住房租金,赡养老人,大病医疗,专项附加合计," & _
"应纳税所得额,税率,速算扣除数,应纳税额,当月应交个税,年累已纳税款,汇算清缴" & _
" FRO M {Xcgl_zxkcb} WHERE YEAR(税款所属期) = " & jt.Year & " AND MONTH(税款所属期)<=" & jt.Month & " ORDER BY 工号,证照号码,税款所属期"
book.AddDataTable("jsb","ZHGL",sql)
Dim g As New SQLGroupTableBuilder("tjb", "Xcgl_zxkcb")
g.C
g.Groups.AddDef("证照号码")
g.Totals.AddDef("养老金")
g.Totals.AddDef("公积金")
book.AddDataTable("tjb", g.Build(True)) '添加临时表
book.AddRelation("tjb","证照号码","jsb","证照号码")
Book.Build()
Book.Save(fl)
运行后会提示错误:
未将对象引用设置到对象的实例。
经测试,在Book.Build()环节出错。以前是可以的,不知是什么原因。
[此贴子已经被作者于2020/5/21 14:40:57编辑过]