string filePath = AppDomain.CurrentDomain.BaseDirectory + fileName;
string toFilePath = AppDomain.CurrentDomain.BaseDirectory + toFileName;
using (CrystalDecisions.CrystalReports.Engine.ReportDocument rd =
new CrystalDecisions.CrystalReports.Engine.ReportDocument())
{
rd.Load(filePath);
try
{
rd.SetDataSource(dataSource);
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = printerName;//"
printerSettings.PrintFileName = fileName;
PageSettings pageSettings = new PageSettings();
rd.PrintToPrinter(printerSettings, pageSettings, false);
CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
CrystalDecisions.Shared.DiskFileDestinationOptions diskOpts =
CrystalDecisions.Shared.ExportOptions.CreateDiskFileDestinationOptions();
exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
exportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
diskOpts.DiskFileName = toFilePath;
exportOpts.ExportDestinationOptions = diskOpts;
rd.Export(exportOpts);
}
catch (Exception ex)
{
WriteLog.ExLog(MethodBase.GetCurrentMethod().Name, ex.Message);
}
finally
{
rd.Close();
rd.Dispose();
}
}
資料方面沒有問題,列印多張的情況下會報例外。GDI一般性錯誤
uj5u.com熱心網友回復:
自己頂,能幫解決請大佬喝卡布奇諾轉載請註明出處,本文鏈接:https://www.uj5u.com/net/270246.html
標籤:C#
