Dim t As Table = CurrentTable
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim lms As new List(of String)
Dim lmsc As new List(of String)
Dim flg As New SaveExcelFlags
'flg.RowNumber = True
flg.CellStyle = True
For Each c As Col In t.Cols
If c.Visible = True
lms.Add(c.Name)
lmsc.Add(c.Caption)
End If
Next
For i As Integer = 0 To lms.Count-1
Sheet(0,i).Value = lmsc(i)
Next
For r As Integer = 0 To t.Rows.Count-1 '填入数据
For i As Integer = 0 To lms.Count-1
try
If lms(i).Contains("状态") Then
Sheet(r+1,i).Value = t.Cols(lms(i)).DataMap(t.rows(r)(lms(i)))
If Sheet(r+1,i).Value="" Then '----如果datamap读取出来是空置则读取原始值
Sheet(r+1,i).Value = t.rows(r)(lms(i))
End If
Else
Sheet(r+1,i).Value = t.rows(r)(lms(i))
End If
catch ex As Exception
Sheet(r+1,i).Value = t.rows(r)(lms(i))
End try
Next
Next
Sheet.MergeCell(1,0,11,0)
Sheet.MergeCell(12,0,4,1)
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()
[此贴子已经被作者于2023/4/20 9:23:34编辑过]