Dim Book As New XLS.Book(ProjectPath & "Attachments\干部职工基本情况登记表.xls")
Dim fl As String = ProjectPath & "Reports\干部职工基本情况登记表" & Tables("基本信息").current("姓名") & Tables("基本信息").current("档案编号") & " .xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim cmd As new SQLCommand
Dim dt As DataTable
Dim str As String
cmd.C
If Forms("综合报表").Controls("CheckBox1").checked = True Then
sheet(2,8).value = "<all>"
For i As Integer = 0 To Tables("基本信息").rows.count-1
str =""
cmd.CommandText="s elect * f rom {工作简历} where 身份证号码='" & Tables("基本信息").Rows(i)("身份证号码") & "' Order by 任职时间"
dt = cmd.ExecuteReader
If dt.DataRows.Count > 0 Then
For Each dr1 As DataRow In Dt.DataRows
str = str & iif(dr1.Isnull("任职时间")," ",format(dr1("任职时间") ,"yyyy.MM")) & StrToWide("-") & iif(dr1.Isnull("任职结束")," ",format(dr1("任职结束"),"yyyy.MM")) & " " & dr1("工作单位") & dr1("担任职务") & vbcrlf
Next
End If
MessageBox.show( i & "--" & 10+i*12 & "--" & str)
sheet(10 + i*12,2).value = str
Next
Else
sheet(2,8).value = ""
cmd.CommandText="s elect * f rom {工作简历} where 身份证号码='" & Tables("基本信息").current("身份证号码") & "' Order by 任职时间"
dt = cmd.ExecuteReader
If dt.DataRows.Count > 0 Then
For Each dr1 As DataRow In Dt.DataRows
str = str & iif(dr1.Isnull("任职时间")," ",format(dr1("任职时间") ,"yyyy.MM")) & StrToWide("-") & iif(dr1.Isnull("任职结束")," ",format(dr1("任职结束"),"yyyy.MM")) & " " & dr1("工作单位") & dr1("担任职务") & vbcrlf
Next
End If
Sheet(10,2).Value = str
End If
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()
上面报表代码中,红色部分代码,能够正常生成str ,但是写入不了 sheet(10 + i*12,2),请教高手,代码应该怎么修改。
[此贴子已经被作者于2016/2/22 13:59:47编辑过]