在命令窗口可以执行
With Tables("分组统计")
.Select(0 ,0, .Rows.Count - 1, .Cols.Count - 1)
End With
Dim Book As New XLS.Book(ProjectPath & "Attachments\权属统计表.xls") '打开模板
Book.Build() '生成细节区
Book.Save("D:\My Documents\退耕报表\权属统计表.xls") '保存工作簿
Dim App As New MSExcel.Application
Dim Wb As MSExcel.Workbook = App.WorkBooks.Open("D:\My Documents\退耕报表\权属统计表.xls")
Dim Wd As MSExcel.Window = Wb.Windows(1) '表示当前工作簿窗口
Wd.DisplayZeros = False '不显示0值
App.Visible = True
单个报表好处理,下面是批量生成的代码该如何加入清零设置?
Dim Names() As String
If DataTables.Contains("分组统计") '如果存在分组统计
If Forms("操作选项").Controls("ComboBox1").Value >"" Andalso Forms("操作选项").Controls("ComboBox2").Value >"" Andalso Forms("操作选项").Controls("CheckBox3").Checked=True Then
Names = New String() {"结果分析","林种统计","面积统计","秋季验收","补助测算","坡度统计","权属统计","设计汇总","设计统计","投资测报","预算汇总","植被统计","验收汇总","二期补助"}
Else
Names = New String() {"结果分析表","林种统计表","面积统计表","秋季验收表","补助测算表","坡度统计表","权属统计表","设计汇总表","设计统计表","投资测报表","预算汇总表","植被统计表","验收汇总表","二期补助表"}
End If
For Each Name As String In Names
With Tables("分组统计")
.Select(0 ,0, .Rows.Count - 1, .Cols.Count - 1)
End With
Dim Book As New XLS.Book(ProjectPath & "Attachments\" & Name & ".xls") '打开模板
Book.Build() '生成细节区
Book.Save("D:\My Documents\退耕报表\"& Name & ".xls") '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File ="D:\My Documents\退耕报表\"& Name & ".xls"
Proc.Start()
Next
Else
MessageBox.Show("先统计!", "提示")
End If
[此贴子已经被作者于2010-7-28 17:15:23编辑过]