Back to Devexpress

XtraReport.SaveLayoutToXml(String) Method

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-dot-savelayouttoxml-x28-system-dot-string-x29.md

latest7.7 KB
Original Source

XtraReport.SaveLayoutToXml(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Saves the report in XML format to the specified file.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public void SaveLayoutToXml(
    string fileName
)
vb
Public Sub SaveLayoutToXml(
    fileName As String
)

Parameters

NameTypeDescription
fileNameString

A String that is the name of the file to which to save the report.

|

Remarks

Use the SaveLayoutToXml and XtraReport.LoadLayoutFromXml methods to store reports in XML format.

Review the following topics for more information:

The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveLayoutToXml(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-web-customize-web-report-wizard/CS/MvcWizardCustomization/ReportStorageWebExtension.cs#L58

csharp
// This method is called only after the IsValidUrl and CanSetData methods are called.
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
}

reporting-web-forms-designer-file-management-dialog/CS/T227679/FilesystemReportStorageWebExtension.cs#L78

csharp
throw new NotSupportedException("Saving is not allowed."); //Comment this line to enable saving
    report.SaveLayoutToXml(filePath);
}

reporting-web-forms-localization/CS/SubstituteLocalizationStringsExample/Services/ReportStorageWebExtension.cs#L67

csharp
// This method is called only after the IsValidUrl and CanSetData methods are called.
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
}

reporting-web-forms-report-designer-add-data-sources/CS/WebApplication1/ReportStorageWebExtension1.cs#L56

csharp
{
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url + FileExtension));
}

reporting-asp-net-core-drill-through/CS/Startup.cs#L50

csharp
foreach(var report in PredefinedReports.ReportsFactory.Reports) {
    report.Value().SaveLayoutToXml(Path.Combine(env.ContentRootPath, CustomReportProviderAsync.MyReportsDirectoryName, report.Key + ".repx"));
}

reporting-web-forms-designer-file-management-dialog/VB/T227679/FilesystemReportStorageWebExtension.vb#L77

vb
Throw New NotSupportedException("Saving is not allowed.") 'Comment this line to enable saving
    report.SaveLayoutToXml(filePath)
Catch ex As Exception

reporting-web-forms-localization/VB/SubstituteLocalizationStringsExample/Services/ReportStorageWebExtension.vb#L64

vb
' This method is called only after the IsValidUrl and CanSetData methods are called.
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url & FileExtension))
End Sub

reporting-web-forms-report-designer-add-data-sources/VB/WebApplication1/ReportStorageWebExtension1.vb#L43

vb
Public Overrides Sub SetData(ByVal report As DevExpress.XtraReports.UI.XtraReport, ByVal url As String)
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url & FileExtension))
End Sub

reporting-mvc-customized-parameter-editor/VB/ParameterEditorAspNetMvcExample/Services/CustomReportStorageWebExtension.vb#L78

vb
If Not IsWithinReportsFolder(url, reportDirectory) Then Throw New FaultException(New FaultReason("Invalid report name."), New FaultCode("Server"), "GetData")
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url & FileExtension))
End Sub

reporting-mvc-display-information-in-xrpageinfo/VB/WebDocumentViewer_UserName_VB/Services/CustomReportStorageWebExtension.vb#L80

vb
If Not IsWithinReportsFolder(url, reportDirectory) Then Throw New FaultException(New FaultReason("Invalid report name."), New FaultCode("Server"), "GetData")
    report.SaveLayoutToXml(Path.Combine(reportDirectory, url & FileExtension))
End Sub

See Also

Store Report Layouts and Documents

XtraReport Class

XtraReport Members

DevExpress.XtraReports.UI Namespace