Skip to content

Commit 955f29a

Browse files
SvetlanaMikheevaDevExpressExampleBotDevExpressExampleBot
authored
Update to v25.1 (#8)
* change a theme * change formats available for export * update the version * Created a new file CODEOWNERS [skip ci] * README auto update [skip ci] * fix theme adding --------- Co-authored-by: DevExpressExampleBot <[email protected]> Co-authored-by: DevExpressExampleBot <[email protected]>
1 parent be975ce commit 955f29a

File tree

8 files changed

+34
-32
lines changed

8 files changed

+34
-32
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
<Router AppAssembly="@typeof(Program).Assembly">
1+
<Router AppAssembly="@typeof(Program).Assembly">
32
<Found Context="routeData">
43
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
54
</Found>
@@ -8,4 +7,4 @@
87
<p>Sorry, there's nothing at this address.</p>
98
</LayoutView>
109
</NotFound>
11-
</Router>
10+
</Router>

CS/GridExportingWithReports/GridExportingWithReports.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88
<ItemGroup>
9-
<PackageReference Include="DevExpress.Blazor" Version="24.2.1-alpha-24207" />
10-
<PackageReference Include="DevExpress.Reporting.Core" Version="24.2.1-alpha-24207" />
9+
<PackageReference Include="DevExpress.Blazor" Version="25.1.3" />
10+
<PackageReference Include="DevExpress.Reporting.Core" Version="25.1.3" />
1111
</ItemGroup>
1212
<ItemGroup>
1313
<Folder Include="wwwroot\images\" />
1414
</ItemGroup>
15-
</Project>
15+
</Project>

CS/GridExportingWithReports/Helpers/ExportMiddleware.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public ExportMiddleware(WeatherForecastService _weatherForecastService) {
1717
weatherForecastService = _weatherForecastService;
1818
}
1919
public Task InvokeAsync(HttpContext context, RequestDelegate next) {
20-
if (context.Request.Path.ToString().StartsWith("/exportPdf")) {
21-
return ExportResult(pdf, GetOptionsFromQuery(context.Request.QueryString.ToString()), context);
20+
if (context.Request.Path.ToString().StartsWith("/exportMht")) {
21+
return ExportResult(mht, GetOptionsFromQuery(context.Request.QueryString.ToString()), context);
2222
}
23-
else if (context.Request.Path.ToString().StartsWith("/exportXlsx")) {
24-
return ExportResult(xlsx, GetOptionsFromQuery(context.Request.QueryString.ToString()), context);
23+
else if (context.Request.Path.ToString().StartsWith("/exportHtml")) {
24+
return ExportResult(html, GetOptionsFromQuery(context.Request.QueryString.ToString()), context);
2525
}
2626
else if (context.Request.Path.ToString().StartsWith("/exportDocx")) {
2727
return ExportResult(docx, GetOptionsFromQuery(context.Request.QueryString.ToString()), context);
@@ -38,8 +38,8 @@ private DataSourceLoadOptionsBase GetOptionsFromQuery(string query) {
3838
});
3939
return options;
4040
}
41-
private readonly string pdf = "pdf";
42-
private readonly string xlsx = "xlsx";
41+
private readonly string mht = "mht";
42+
private readonly string html = "html";
4343
private readonly string docx = "docx";
4444
private async Task ExportResult(string format, DataSourceLoadOptionsBase dataOptions, HttpContext context) {
4545
XtraReport report = new XtraReport();
@@ -50,10 +50,10 @@ private async Task ExportResult(string format, DataSourceLoadOptionsBase dataOpt
5050
ReportHelper.CreateReport(report, new string[] { "TemperatureC", "TemperatureF", "Summary", "Date" });
5151
report.CreateDocument();
5252
using (MemoryStream fs = new MemoryStream()) {
53-
if (format == pdf)
54-
report.ExportToPdf(fs);
55-
else if (format == xlsx)
56-
report.ExportToXlsx(fs);
53+
if (format == mht)
54+
report.ExportToMht(fs);
55+
else if (format == html)
56+
report.ExportToHtml(fs);
5757
else if (format == docx)
5858
report.ExportToDocx(fs);
5959
context.Response.Clear();

CS/GridExportingWithReports/Pages/Index.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ else {
4141
{
4242
string baseUri = NavigationManager.BaseUri.ToString();
4343
exportUrlInfo.Clear();
44-
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportPdf"), "Export PDF"));
45-
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportXlsx"), "Export XLSX"));
46-
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportDocx"), "Export DOCX"));
44+
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportMht"), "Export to MHT"));
45+
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportHtml"), "Export to HTML"));
46+
exportUrlInfo.Add(Tuple.Create(loadOptions.ConvertToGetRequestUri(baseUri + "exportDocx"), "Export to DOCX"));
4747
}
4848
var t = 0;
4949
};

CS/GridExportingWithReports/Pages/_Layout.cshtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using Microsoft.AspNetCore.Components.Web
2+
@using DevExpress.Blazor
23
@namespace GridExportingWithReports.Pages
34
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
45

@@ -8,8 +9,11 @@
89
<meta charset="utf-8" />
910
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1011
<base href="~/" />
11-
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.css" rel="stylesheet" />
12-
12+
13+
@foreach(var file in Themes.Fluent.GetFilePaths()) {
14+
<link href="@file" rel="stylesheet" />
15+
}
16+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
1317
<link href="~/css/site.css" rel="stylesheet" />
1418
<link href="GridExportingWithReports.styles.css" rel="stylesheet" />
1519
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />

Readme.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
66
<!-- default badges end -->
77

8-
# Grid for Blazor - How to Export Data to PDF, XLSX, and DOCX formats in a server application
8+
# Blazor Grid - How to Export Data to DOCX, HTML, and MHT formats in a server application
99

10-
The [Grid](https://docs.devexpress.com/Blazor/403143/grid) component allows you to [export data](https://demos.devexpress.com/blazor/Grid/Export/DataAwareExport) to XLS, XLSX, and CSV file formats. You can also use DevExpress Reporting tools to implement export to different formats (PDF, XLSX, and DOCX). This example illustrates how to do this in a Blazor Server application.
10+
The [Grid](https://docs.devexpress.com/Blazor/403143/grid) component allows you to [export data](https://demos.devexpress.com/blazor/Grid/Export/DataAwareExport) to PDF, XLS, XLSX, and CSV file formats. You can also use DevExpress Reporting tools to implement export to different formats (DOCX, HTML, and MHT). This example illustrates how to do this in a Blazor Server application.
1111

12-
![Exported PDF](images/exported-pdf.png)
12+
![Exported Docx](images/exported-docx.png)
1313

1414
The `DxGrid` component is bound to an [IQueryable<T>](https://docs.microsoft.com/en-us/dotnet/api/system.linq.iqueryable-1) data collection (use the [GridDevExtremeDataSource](https://docs.devexpress.com/Blazor/DevExpress.Blazor.GridDevExtremeDataSource-1)). The [CustomizeLoadOptions](https://docs.devexpress.com/Blazor/DevExpress.Blazor.GridDevExtremeDataSource-1.CustomizeLoadOptions) property is used to obtain information about the grid's state.
1515

1616
To export information, apply the [ExportMiddleware](./CS/GridExportingWithReports/Helpers/ExportMiddleware.cs) type to the application request pipeline. The **ExportMiddleware** handles requests. The response returns the file of the corresponding type.
1717

1818
The [ExportButtons](./CS/GridExportingWithReports/Shared/ExportButtons.razor) component contains export buttons. Each export button contains an [URI to this project](./CS/GridExportingWithReports/Pages/Index.razor#L32), and the URI contains the Grid options. The created report contains only data that is visible in the grid after sort and filter operations. The **ExportMiddleware** processes the request with the URI.
1919

20-
Use the [ReportHelper.CreateReport](./CS/GridExportingWithReports/Helpers/ReportHelper.cs#L9) method with the [ExportToPdf(String)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToPdf(System.String-DevExpress.XtraPrinting.PdfExportOptions))/[ExportToXlsx(Stream)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToXls(System.IO.Stream-DevExpress.XtraPrinting.XlsExportOptions))/[ExportToDocx(Stream)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToDocx(System.IO.Stream-DevExpress.XtraPrinting.DocxExportOptions)) methods to create a report that is exported to the file of the corresponding type.
20+
Use the [ReportHelper.CreateReport](./CS/GridExportingWithReports/Helpers/ReportHelper.cs#L9) method with the [ExportToDocx(Stream)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToDocx(System.IO.Stream-DevExpress.XtraPrinting.DocxExportOptions))/[ExportToHtml(Stream)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToHtml(System.IO.Stream-DevExpress.XtraPrinting.HtmlExportOptions))/[ExportToMht(String)](https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToMht(System.String-DevExpress.XtraPrinting.MhtExportOptions)) methods to create a report that is exported to the file of the corresponding type.
2121

2222
<!-- default file list -->
2323

@@ -37,13 +37,12 @@ Use the [ReportHelper.CreateReport](./CS/GridExportingWithReports/Helpers/Report
3737

3838
## More Examples
3939

40-
[Grid for Blazor - How to use DevExpress Reporting tools to implement export in a WASM application](https://github.com/DevExpress-Examples/blazor-webassembly-dxdatagrid-export)
41-
42-
[How to use DevExpress Reporting Components in Blazor applications](https://github.com/DevExpress-Examples/how-to-use-reporting-components-in-blazor-applications)
40+
* [Grid for Blazor - How to use DevExpress Reporting tools to implement export in a WASM application](https://github.com/DevExpress-Examples/blazor-webassembly-dxdatagrid-export)
41+
* [How to use DevExpress Reporting Components in Blazor applications](https://github.com/DevExpress-Examples/how-to-use-reporting-components-in-blazor-applications)
4342
<!-- feedback -->
44-
## Does this example address your development requirements/objectives?
45-
46-
[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=blazor-server-dxgrid-export&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=blazor-server-dxgrid-export&~~~was_helpful=no)
47-
43+
## Does this example address your development requirements/objectives?
44+
45+
[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=blazor-server-dxgrid-export&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=blazor-server-dxgrid-export&~~~was_helpful=no)
46+
4847
(you will be redirected to DevExpress.com to submit your response)
4948
<!-- feedback end -->

images/exported-docx.png

25.7 KB
Loading

images/exported-pdf.png

-28.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)