xtrareports-405394-feature-guide-to-devexpress-reports-use-report-controls-manipulate-report-controls-hide-report-controls-on-printouts-and-in-exported-documents.md
Use CanPublishOptions to hide report controls in exported documents and printouts. The XRControl.CanPublishOptions property allows you to access the CanPublishOptions object. Specify settings to hide a report control on printouts or when exported to a document in a certain format.
The following formats are available:
CanPublishOptions.CsvSpecifies report control visibility when exporting to CSV.CanPublishOptions.DocxSpecifies report control visibility when exporting to DOCX.CanPublishOptions.HtmSpecifies report control visibility when exporting to HTM.CanPublishOptions.ImageSpecifies report control visibility when exporting as an image.CanPublishOptions.MhtSpecifies report control visibility when exporting to MHT.CanPublishOptions.PdfSpecifies report control visibility when exporting to PDF.CanPublishOptions.PrintingSpecifies report control visibility on printouts.CanPublishOptions.RtfSpecifies report control visibility when exporting to RTF.CanPublishOptions.TxtSpecifies report control visibility when exporting to TXT.CanPublishOptions.XlsSpecifies report control visibility when exporting to XLS.CanPublishOptions.XlsSpecifies report control visibility when exporting to XLS.CanPublishOptions.AllFormatsSpecifies whether the control is visible on printouts and in all exported documents.
To hide a report control on printouts and in all exported documents, set CanPublishOptions.AllFormats to false.
The following code snippet excludes page information (the XRPageInfo instance) when exporting a report to XLS, XLSX, and CSV formats:
using DevExpress.XtraReports.UI;
// ...
XtraReport report = new XtraReport();
DetailBand detailBand = new DetailBand();
report.Bands.Add(detailBand);
XRPageInfo xrPageInfo1 = new XRPageInfo{
// Add content.
};
detailBand.Controls.Add(xrPageInfo1);
// Hide xrPageInfo1 from XLS, XLSX, and CSV formats.
xrPageInfo1.CanPublishOptions.Xlsx = false;
xrPageInfo1.CanPublishOptions.Xls = false;
xrPageInfo1.CanPublishOptions.Csv = false;
Imports DevExpress.XtraReports.UI
' ...
Private report As New XtraReport()
Private detailBand As New DetailBand()
report.Bands.Add(detailBand)
Dim xrPageInfo1 As XRPageInfo = New XRPageInfo From { }
detailBand.Controls.Add(xrPageInfo1)
' Hide xrPageInfo1 from XLS, XLSX, and CSV formats.
xrPageInfo1.CanPublishOptions.Xlsx = False
xrPageInfo1.CanPublishOptions.Xls = False
xrPageInfo1.CanPublishOptions.Csv = False
You can also specify CanPublishOptions in the Properties grid:
The following image illustrates the resulting XLXS document with and without page information: