按模板输出excel文件:
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Title="请选择Excel模板"
dlg.InitialDirectory=ProjectPath & "Attachments\"
dlg.Filter= "Excel模板|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
Dim dlg_save As new SaveFileDialog
dlg_save.Title="请选择保存文件"
dlg_save.InitialDirectory=ProjectPath & "Reports\"
dlg_save.Filter= "Excel文件|*.xls" '设置筛选器
dlg_save.FileName=e.Form.Controls("TB_kmmc1").Value
If dlg_save.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim fl As String = dlg_save.FileName
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()
End If
End If
默认指定模板 改成这样 为什么不行啊
Dim Book As New XLS.Book(“d:\text\text.xls")
Dim dlg_save As new SaveFileDialog
dlg_save.Title="请选择保存文件"
dlg_save.InitialDirectory=ProjectPath & "Reports\"
dlg_save.Filter= "Excel文件|*.xls" '设置筛选器
dlg_save.FileName=e.Form.Controls("TB_kmmc1").Value
If dlg_save.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim fl As String = dlg_save.FileName
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()
End If