部分代码如下,请参考:
comm.CommandText = (strSQL1)
comm.Connection = dbcnt400
commreader = comm.ExecuteReader
numn = 0
While commreader.Read
If commreader.GetValue(0).ToString <> "" Then
term = commreader.GetValue(0)
mon = commreader.GetValue(1)
Dim ts As Integer
ts = FpSpread2.Sheets.Count
Call sql11()
Adapter1 = New OleDbDataAdapter(strSQL1, dbcnt400)
Adapter1.Fill(db1, "tab" & (numn + 1) & "")
name = "tab" & (numn + 1) & ""
Dim t As Integer
t = db1.Tables("tab" & (numn + 1) & "").Rows.Count
Dim newsheet As New FarPoint.Web.Spread.SheetView
newsheet.SheetName = "'P-" & term & " 天 " & mon & "'"
FpSpread2.Sheets.Add(newsheet)
Dim model1 As FarPoint.Web.Spread.Model.DefaultSheetDataModel
model1 = New FarPoint.Web.Spread.Model.DefaultSheetDataModel(db1.Tables("tab" & (numn + 1) & ""))
FpSpread2.Sheets(numn).DataModel = model1
FpSpread2.Sheets(numn).SheetName = "'P-" & term & " 天 " & mon & "'"
FpSpread2.Sheets(numn).ColumnHeader.Cells(0, 0).Text = "" & yy & " 年" & mm & "月験収実際一覧表(" & term & " 天/" & mon & ")"
FpSpread2.Sheets(numn).ColumnHeader.Cells(0, 0).Font.Size = 20
numdbcount = db1.Tables("tab" & (numn + 1) & "").Rows.Count
For n = 0 To numdbcount - 1
FpSpread2.Sheets(m).Cells(n, 0).Text = n + 1
Next
db1.Tables("tab" & (numn + 1) & "").Rows.Add()
FpSpread2.Sheets(numn).Cells(n, 0).Text = "合计"
FpSpread2.Sheets(numn).Cells((numdbcount), 3).Formula = "sum(D1" & n & ")"
FpSpread2.Sheets(numn).Cells((numdbcount), 4).Formula = "sum(E1:E" & n & ")"
FpSpread2.Sheets(numn).Cells((numdbcount), 5).Formula = "sum(F1:F" & n & ")"
numn = numn + 1
Else
End If
End While
m = m + numn
ViewState("m") = m |