HI
may i know have any sample to teach
How to print report direct, and print preview via an simple action?
thanks
Sze Yuan
We have closed this ticket because another page addresses its subject:
Documentation - Provide a help article on how to programmatically export a report to PDF, stream, print or attach it to email via a custom Action without showing the report previewHow to print report direct, and print preview via an simple action?
Answers approved by DevExpress Support
Hello,
Thank you for the question.
Here is the code you can use to get a report from an arbitrary place in your application:
C#IReportData reportData = ObjectSpace.FindObject<ReportData>(new BinaryOperator("Name", "MyReportName"));
if(reportData != null) {
using(IObjectSpace os = Application.CreateObjectSpace()) {
XafReport report = reportData.LoadXtraReport(os);
DoSomethingWithReport(report);
}
}
public void DoSomethingWithReport(report) {
//You can print it:
//ReportPrintTool printTool = new ReportPrintTool(report);
//printTool.Print();
//Or you can export it:
report.ExportToPdf("MyReport.pdf", report.ExportOptions.Pdf);
//etc.
}
If you want, you can access a ready report reference from WinReportServiceController.CustomShowPreview event arguments.
Let me know if I can help you further.
Thanks,
Dennis
P.S.
Can I make this ticket public? Also, can you please make your future tickets (if possible) public as well?
---------------
Check if Search Engine is able to answer questions faster than I do!
---------------
Hi,
I have tried this:
Dim reportData As IReportDataV2 = DirectCast(ObjectSpace.FindObject(Application.Modules.FindModule(Of ReportsModuleV2)().ReportDataType, New BinaryOperator("DisplayName", "Bill")), IReportDataV2)
Dim report = ReportDataProvider.ReportsStorage.LoadReport(reportData)
With report
report.RequestParameters = False
report.Parameters("p_key").Value = hdr.bill_hdr_key
Dim printTool As New ReportPrintTool(report)
printTool.Print()
End With
Why is it printing a blank report even if it has properly passed the value of the parameter? What am I missing?
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T319008: An empty report can be produced when loading a report data and printing XtraReport programmatically. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.