Posted 8 May 2018, 1:51 am EST
Hi,
We are using the latest FlexReport (4.0.20181.303) and i couldn’t figure out how to export thw report to an XPS stream?
How can this be achieved?
Guy.
Forums Home / ComponentOne / WinForms Edition
Posted by: Guy on 8 May 2018, 1:51 am EST
Posted 8 May 2018, 1:51 am EST
Hi,
We are using the latest FlexReport (4.0.20181.303) and i couldn’t figure out how to export thw report to an XPS stream?
How can this be achieved?
Guy.
Posted 8 May 2018, 5:01 am EST
Hello Guy,
To obtain a report in xps format, you can print it using “Microsoft XPS Document Writer”, by calling the below mentioned method:
private void GetPrintOptions()
{
C1PrintOptions result = new C1PrintOptions();
result.PrinterSettings = new PrinterSettings();
result.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
c1FlexReport1.Print(result);
}
Let us know if this helps.
Best Regards,
Esha
Posted 8 May 2018, 7:08 am EST
Hi Esha,
Thank you for the quick response.
However - this does not help me…
I Need to export the report to an XPS stream/file SILENTLY - without user interaction. Printing to ‘Microsoft XPS Document Writer’ requires human interaction & involvement.
Can’t XPS be achieved like rendering to PDF?
Guy.
Posted 8 May 2018, 12:49 pm EST
We had been using the following “trick” in situations like these.
Generate a new printer with a generated local port. When asked for the name of the port enter a filename, for example “c:\del\test.xps”
Name the printer as you like and use the printer driver you need.
Simply print to the printer and if needed del/rename/move the file.
In a multiuser environment you need a “per place printer with an extra file per place”
Posted 9 May 2018, 2:01 am EST
Hello Guy,
As stated by Andreas, you can add a new local printer and set its local port as the path specified for the xps file to be generated. Further, you can choose the driver as, say “Microsoft XPS Document Writer v4” and use this printer while printing the report. This way, you will not be prompted to enter the file name for creating xps document.
[quote]Can’t XPS be achieved like rendering to PDF?
[/quote]
Sorry, but that is not possible.
Please inform if you need any further assistance.
Thanks,
Esha
Posted 31 May 2018, 2:21 am EST
Dear Esha,
I’m reffering you to your own documentation at
http://helpcentral.componentone.com/nethelp/FlexReport/C1.Win.FlexReport.4~C1.Win.FlexReport.C1FlexReport.html
Where it clearly states:
C1FlexReport Class
Generates data-based banded reports that can be rendered to printer, preview, or exported to various portable formats (including * “XPS”
, HTML, PDF and other)
Our choice of product comes from its declared capabilities.
Please instruct on exporting to XPS.
Thank you,
Guy.
Posted 1 June 2018, 12:22 am EST
Hello Guy,
Apologies for not being able to guide you accurately at first.
You can make use of the ExportToXps method of C1FlexViewer to export the document loaded in it to an XPS file, silently. Two of its overloads are mentioned here:
http://help.grapecity.com/componentone/NetHelp/FlexReport/webframe.html#C1.Win.FlexViewer.4~C1.Win.FlexViewer.C1FlexViewer~ExportToXps.html
The code would look something like this:
C1FlexViewer1.DocumentSource = C1FlexReport1;
C1FlexViewer1.ExportToXps("test.oxps");
Hope it helps.
Thanks,
Esha
Posted 3 June 2018, 9:49 am EST
Hi Esha,
Thank you for your reply.
It Helps - However there are 2 main issues:
We need the ability to export the report to XPS without C1FlexViewer (as stated in C1FlexReport documentation) - Silently & Efficiently…
Please provide an example of exporting a C1FlexReport to XPS.
Thank you,
Guy.
Posted 4 June 2018, 12:10 am EST
Hello Guy,
We are investigating if we can find another way out for the XPS export that’s both silent and efficient.
We will soon get back to you with a response.
Thanks for your cooperation,
Esha
Posted 5 June 2018, 5:26 am EST
Hello,
As per the development team, XPS export is not supported and is a limitation for now.
We’ll get the documentation corrected to avoid confusion.
Thanks,
Esha
Posted 8 June 2018, 7:40 am EST
Hi Esha,
That is a BIG disappointment. We do not expect a vendor to ‘correct’ documentation to cover up functionalities that were “part of the product”.
We rely on these declerations of functionality when we choose our product vendors. We will take this policy into considiration in our future choices.
Regarding XPS exporting via FlexViewer & Landscape? Is there an answer for that? - if the report layout states it is landscape the result XPS is always portrait…
Guy.
Posted 12 June 2018, 5:48 am EST
Guy,
We understand your concern and deeply regret the issue you are facing. We are in discussion with the development team over the case and will get back to you once it is done.
Best Regards,
Esha
Posted 14 June 2018, 7:02 am EST
Hello Guy,
As per the development team, the issue related to silent XPS export from C1FlexReport is a limitation. We are sorry for the inconvenience.
Regarding XPS exporting via FlexViewer & Landscape? Is there an answer for that? - if the report layout states it is landscape the result XPS is always portrait…
This will be fixed with 18v2 builds. We will let you know once the builds containing the fix is released.
Thanks,
Esha
Posted 5 July 2018, 11:13 pm EST
Hello Guy,
With the latest 4.0.20182.314 builds, you can export to XPS by maintaining the landscape orientation, with a method like this:
private void ExportToXps()
{
var rpt = new C1.Win.FlexReport.C1FlexReport();
// load the report definition
rpt.Load(@"..\..\MyReports\Report1.flxr", "Accounts");
// change orientation to landscape
var ps = rpt.PageSettings;
ps.Landscape = true;
rpt.PageSettings = ps;
// generate the report
rpt.Render();
// create a C1FlexViewerPane without hosting it anywhere
using (var fv = new C1.Win.FlexViewer.C1FlexViewerPane())
{
// access the Handle property to initialize C1FlexViewerPane
if (fv.Handle != IntPtr.Zero)
{
fv.DocumentSource = rpt;
fv.ExportToXps(@"c:\accounts.oxps");
}
}
rpt.Dispose();
}
Please download build 314 from the below mentioned link:
http://prerelease.componentone.com/dotnet20/C1WinForms/2018-T2/C1WinForms.2_2.0.20182.314.zip
http://prerelease.componentone.com/dotnet40/C1WinForms/2018-T2/C1WinForms.4_4.0.20182.314.zip
Best Regards,
Esha