如何在一个工作簿中打印所有工作表。 [英] how to print all worksheets in one one workbook .

查看:67
本文介绍了如何在一个工作簿中打印所有工作表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我使用下面的代码来打印excel文件。

但是我无法打印所有工作表。





Actually I am using below code to print the excel file .
But i am not able to print all worksheets .


Dim oProcess As New System.Diagnostics.Process
With oProcess.StartInfo
  .CreateNoWindow = True
  .WindowStyle = ProcessWindowStyle.Hidden
  .Verb = "print"
  .UseShellExecute = True
  .FileName = Application.StartupPath + "\tempcashDeposit.xlsx"
End With

xlWorkBook.Close(SaveChanges:=True)
oProcess.Start()
oProcess.Dispose()
oProcess.Close()

推荐答案

此时我发现你正在使用Interop。为什么不使用Excel的方法?



At this moment i see that you're using Interop. Why don't you use Excel's methods?

For Each wsh As Worksheet in xlWorkBook.Worksheets
    wsh.PrintOut
Next 





Worksheet.PrintOut方法 [ ^ ]

For Each ...下一个声明(Visual Basic) [ ^ ]


您不能简单地启动进程并将其用作vbs样式的xlWorkBook。从vb.net你需要自己设置com互操作。但是......我发布了一个帮助ExcelDataReader,名为ExelDataReaderHelper。它使得从excel文件中读取更加容易。无需com互操作。也许这可以帮到你。这个例子在c#中,但是包也可以和vb.net一起使用。



ExcelDataReader包的其他帮助方法 [ ^ ]



祝你好运!
You cannot simply start a process and use it as xlWorkBook in vbs style. From vb.net you would need setup com interop yourself. But... I published a helper for use with ExcelDataReader, called ExelDataReaderHelper. It makes it even more easy to read from excel files. without the need for com interop. Maybe this can help you out. The example is in c# but the package should work fine with vb.net also.

Additional Helper Methods to the ExcelDataReader Package[^]

Good luck!


这篇关于如何在一个工作簿中打印所有工作表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆