导出 代码
Dim Kms() As String = {"总分"}
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
For Each tjnj As String In DataTables("校名设置").GetValues("统计年级","单位 = '统计'")
For Each tjlb As String In DataTables("校名设置").GetValues("统计类别","单位 = '统计'")
For Each Km As String In Kms
Dim dr As DataRow = DataTables("校名设置").Find("单位 = '统计'")
Tables(Km & tjnj &"级"& tjlb &"重点线上下"& dr("目标7") &"分名册").SaveExcel(dlg.FileName, Km & tjnj &"级"& tjlb &"重点线上下"& dr("目标7") &"分名册") '保存文件
DataTables.Delete( Km & tjnj &"级"& tjlb &"重点线上下"& dr("目标7") &"分名册") '删除原文件
Dim book As new XLS.Book(dlg.FileName)
Dim sheet As XLS.Sheet = book.Sheets(Km & tjnj &"级"& tjlb &"重点线上下"& dr("目标7") &"分名册")
Dim Style As Xls.Style = book.NewStyle '新建一个样式
Style.ForeColor = Color.Red '样式的背景颜色设为红色
Style.Font = new font("宋体",9,FontStyle.Bold)
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
For i As Integer = 0 To sheet.Rows.count -1
Dim Hjs() As String = {"重庆市","梁平县"}
For Each Hj As String In Hjs
If sheet(i,0).Text.EndsWith(Hj) Then '如果指定列(第1列)中含Hj字符存在
For n As Integer = 0 To sheet.Cols.count -1
sheet(i,n).Style = Style
Next
End If
Next
Next
Book.Save(dlg.FileName)
Next
Next
Next
End If
e.Form.Controls("Label1").Text = "临界生名册已导出并删除!"