在Xp和Vista中的选定打印机中打印Excel文件 [英] Print Excel File In Selected Printer in Xp and Vista
问题描述
我已经编写了打印任何文件的示例应用程序,但它不适用于Xp和Vista上选定打印机中的excel和.doc。
以下是示例代码:
I have written a sample application of print any file but it does not work for excel and .doc in selected printer on Xp and Vista.
The following is a sample code:
处理p = 新 处理();
如果 ( 此 .printDialog1.ShowDialog()== DialogResult.OK)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = sFilePath;
info.CreateNoWindow = true ;
info.UseShellExecute = true ;
$
  // info。 Arguments = this.printDialog1.PrinterSettings.PrinterName;
         
info.Arguments = " \" \\\\ + Dns.GetHostName()+" \\ " + printDialog1.PrinterSettings.PrinterName +" \ " " ;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
       
p.StartInfo = info;
bool sdfvgfs = p.Start();
p.Close();
}
Process p = new Process();
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = sFilePath;
info.CreateNoWindow = true;
info.UseShellExecute = true;
//info.Arguments = this.printDialog1.PrinterSettings.PrinterName;
info.Arguments = "\"\\\\" + Dns.GetHostName() + "\\" + printDialog1.PrinterSettings.PrinterName + "\"";
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo = info;
bool sdfvgfs= p.Start();
p.Close();
}
有人知道解决方案吗?
谢谢!
Please anybody know about solution?
Thank You!
推荐答案
Hi Kailas,
感谢您在MSDN论坛上发帖。
您是否在Excel或Word加载项中运行代码段?或者你在Winform应用程序中使用它?
祝你有个美好的一天,
Tom
这篇关于在Xp和Vista中的选定打印机中打印Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!