从winform直接将水晶报告导出为pdf [英] Export crystal report directly to pdf from winform
问题描述
我使用两个存储过程,一个用于主报告,另一个用于子报告。下面是代码。
private void LoadSalesOrderReport()
{
string Type = gvQuotationDetails.Rows [QuoteIndex] .Cells [Type]。EditedFormattedValue.ToString();
FilePath = ConfigurationManager.AppSettings [EMP_IMG_PATH]。ToString()+\\+ ValQuoteID.ToString()+。pdf;
DeleteExistingFile(FilePath);
try
{
AccountsPayableMaster objAPM = new AccountsPayableMaster();
QuotationReport obj = new QuotationReport();
objReportDocument.Load(Application.StartupPath + @\ rptQuotationReport.rpt );
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails(SD_SalesOrderReport; 1);
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails(SD_GetBatchReportDetails; 1);
obj .crysQuotationReport.ReportSource = objReportDocument;
objReportDocument.SetParameterValue(@ QuoteID,ValQuoteID);
objReportDocument.SetParameterValue(Type, - + Type.ToUpper()+ - );
objReportDocument.SetParameterValue(@ QuoteID,ValQuoteID,objReportDocument.Subreports [0] .Name.ToString());
string [] Print = objAPM.GetPrintDetails();
SetPrintParameters(objReportDocument,Print);
obj.Show();
objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat,FilePath);
}
catch(exception ex)
{
MessageBox.Show(ex.Message);
}
OpenPdfFile();
}
private void OpenPdfFile()
{
try
{
Process.Start(FilePath);
}
catch(exception ex)
{
MessageBox.Show(请安装MicrosoftOffice / Pdf Reader查看文件,,MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
代码工作正常。但问题是。当我点击前端的按钮直接显示pdf。水晶报告表格也显示,我知道我在我的代码中使用** obj.Show **的原因。我试图评论它,但它抛出一个error.Can任何人都建议我的代码中的更改直接显示pdf而不是crystalreport表单。
Prathap Gangireddy写道:嗨Sandeep,当我评论obj.show()时。它给出了一个错误,如错误的登录参数,当我取消注释它工作正常。
您必须动态地将登录详细信息应用于报表运行时。
C#Crystal Reports动态登录参数 [ ^ ]
Hi,
I am using two stored procedures, one for main report and another for subreport.Below is the code.
private void LoadSalesOrderReport() { string Type = gvQuotationDetails.Rows[QuoteIndex].Cells["Type"].EditedFormattedValue.ToString(); FilePath = ConfigurationManager.AppSettings["EMP_IMG_PATH"].ToString() + "\\"" + ValQuoteID.ToString() + ".pdf"; DeleteExistingFile(FilePath); try { AccountsPayableMaster objAPM = new AccountsPayableMaster(); QuotationReport obj = new QuotationReport(); objReportDocument.Load(Application.StartupPath + @"\rptQuotationReport.rpt"); obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1"); obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1"); obj.crysQuotationReport.ReportSource = objReportDocument; objReportDocument.SetParameterValue("@QuoteID", ValQuoteID); objReportDocument.SetParameterValue("Type","-"+ Type.ToUpper()+"-"); objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,objReportDocument.Subreports[0].Name.ToString()); string[] Print = objAPM.GetPrintDetails(); SetPrintParameters(objReportDocument, Print); obj.Show(); objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath); } catch (Exception ex) { MessageBox.Show(ex.Message); } OpenPdfFile(); } private void OpenPdfFile() { try { Process.Start(FilePath); } catch (Exception ex) { MessageBox.Show("Please install MicrosoftOffice/Pdf Reader to view files", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
The code is working fine.But the problem is. when i click the button in front end to show the pdf directly.The crystal report form is also displayed and I know the reason as I am using **obj.Show** in my code.I tried to comment it but it throws an error.Can any one advise changes in my code to directly display the pdf and not the crystalreport form.
Prathap Gangireddy wrote:Hi Sandeep, When I am commenting out obj.show(). It gives an error like incorrect logon parameters and when i uncomment it works fine.
You have to apply logon details to reports run time dynamically.
C# Crystal Reports Dynamic Logon parameters[^]
这篇关于从winform直接将水晶报告导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!