You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/grid/export/csv.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,8 +99,10 @@ Optionally, you can also set the `GridCsvExport` tag settings under the `GridExp
99
99
100
100
You can programmatically invoke the export feature of the Grid, by using the following methods exposed on the `@ref` of the Grid:
101
101
102
-
*`SaveAsCsvFileAsync` - `ValueTask` - sends the exported CSV file to the browser for download
103
-
*`ExportToCsvAsync` - `Task<MemoryStream>` - returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance.
102
+
| Method | Type | Description |
103
+
| --- | --- | --- |
104
+
|`SaveAsCsvFileAsync`|`ValueTask`| sends the exported CSV file to the browser for download. |
105
+
|`ExportToCsvAsync`|`Task<MemoryStream>`| returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance. |
104
106
105
107
>note The same methods are exposed for exporting an [Excel file]({%slug grid-export-excel%}#programmatic-export).
Copy file name to clipboardExpand all lines: components/grid/export/events.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,11 @@ You can customize the files exported to Excel and CSV by using the [OnBeforeExpo
17
17
-[OnBeforeExport](#onbeforeexport)
18
18
-[For Excel Export](#for-excel-export)
19
19
-[For CSV Export](#for-csv-export)
20
+
-[For PDF Export](#for-pdf-export)
20
21
-[OnAfterExport](#onafterexport)
21
22
-[For Excel Export](#for-excel-export-1)
22
23
-[For CSV Export](#for-csv-export-1)
24
+
-[For PDF Export](#for-pdf-export)
23
25
24
26
## OnBeforeExport
25
27
@@ -251,6 +253,10 @@ To export a hidden Grid column that has its `Visible` parameter set to `false`,
251
253
}
252
254
````
253
255
256
+
### For Pdf Export
257
+
258
+
xzxz
259
+
254
260
## OnAfterExport
255
261
256
262
The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and before the generated file is provided to the user. You can use the event to make changes to the exported file. The event handler receives a `GridAfterExcelExportEventArgs` or `GridAfterCsvExportEventArgs` object, depending on the type of export, which provides the following fields:
@@ -405,6 +411,9 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
Copy file name to clipboardExpand all lines: components/grid/export/excel.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,8 +99,10 @@ Optionally, you can also set the `GridExcelExport` tag settings under the `GridE
99
99
100
100
You can programmatically invoke the export feature of the Grid, by using the following methods exposed on the `@ref` of the Grid:
101
101
102
-
*`SaveAsExcelFileAsync` - `ValueTask` - sends the exported excel file to the browser for download.
103
-
*`ExportToExcelAsync` - `Task<MemoryStream>` - returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance.
102
+
| Method | Type | Description |
103
+
| --- | --- | --- |
104
+
|`SaveAsExcelFileAsync`|`ValueTask`| sends the exported excel file to the browser for download. |
105
+
|`ExportToExcelAsync`|`Task<MemoryStream>`| returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance. |
104
106
105
107
>note The same methods are exposed for exporting a [CSV file]({%slug grid-export-csv%}#programmatic-export).
Copy file name to clipboardExpand all lines: components/grid/export/pdf.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,24 +25,24 @@ When you click the Export button, your browser will receive the resulting file.
25
25
26
26
## Basics
27
27
28
-
To enable the Grid Pdf Export, add a [command button]({%slugcomponents/grid/columns/command%}) with the `PdfExport` command name to the [Grid toolbar]({%slugcomponents/grid/features/toolbar%}).
28
+
To enable the Grid Pdf Export, add a [command button](slug:components/grid/columns/command) with the `PdfExport` command name to the [Grid toolbar](slug:components/grid/features/toolbar).
29
29
30
30
````RAZOR.skip-repl
31
31
<GridToolBarTemplate>
32
32
<GridCommandButton Command="PdfExport" Icon="@SvgIcon.FilePdf">Export to Pdf</GridCommandButton>
33
33
</GridToolBarTemplate>
34
34
````
35
35
36
-
Optionally, you can also set the `GridPdfExport` tag settings under the `GridExport` tag to subscribe to [Grid export events]({%sluggrid-export-events%}) that allow further customizations of the exported columns/data or configure the Pdf export options:
36
+
Optionally, you can also set the `GridPdfExport` tag settings under the `GridExport` tag to subscribe to [Grid export events](slug:grid-export-events) that allow further customizations of the exported columns/data or configure the Pdf export options:
| Parameter | Type and Default Value | Description |
41
41
| --- | --- | --- |
42
42
|`FileName`|`string`| the name of the file. The grid will add the `.xslx` extension for you. |
43
43
|`AllPages`|`bool`| whether to export the current page only, or the entire data from the data source. |
44
-
|`PaperSize`|`GridPdfExportPaperSize` enum | The size of the paper for the xported file. |
45
-
|`PageOrientation`|`GridPdfExportPageOrientation` enum| The orientation of the page - portrait and landscape. |
44
+
|`PaperSize`|`GridPdfExportPaperSize` enum <br/> (`A4`) | The size of the paper for the xported file. |
45
+
|`PageOrientation`|`GridPdfExportPageOrientation` enum <br/> (`Portrait`)| The orientation of the page - portrait and landscape. |
46
46
47
47
>caption Export the Grid to Pdf - Example
48
48
@@ -105,8 +105,12 @@ Optionally, you can also set the `GridPdfExport` tag settings under the `GridExp
105
105
106
106
You can programmatically invoke the export feature of the Grid, by using the following methods exposed on the `@ref` of the Grid:
107
107
108
-
*`SaveAsPdfFileAsync` - `ValueTask` - sends the exported Pdf file to the browser for download.
109
-
*`ExportToPdfAsync` - `Task<MemoryStream>` - returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance.
|`SaveAsPdfFileAsync`|`ValueTask`| sends the exported Pdf file to the browser for download. |
113
+
|`ExportToPdfAsync`|`Task<MemoryStream>`| returns the exported data as a `MemoryStream`. The stream itself is finalized, so that the resource does not leak. To read and work with the stream, clone its available binary data to a new `MemoryStream` instance. |
110
114
111
115
>caption Invoke the export function from code
112
116
@@ -192,23 +196,27 @@ To customize the exported file, handle the `OnBeforeExport` or `OnAfterExport` e
192
196
193
197
The component allows you to control the data set that will be exported. It also provides built-in customization options for the columns such as `Width`, `Title` and more.
194
198
195
-
For more advanced customization (such as coloring the headers or bolding the titles) the Grid lets you get the `MemoryStream` of the file. Thus, you can customize it using the [`SpreadProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) or the [`SpreadStreamProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadstreamprocessing/overview) libraries that are available with your license. Find examples on how to [format the cells of the exported Pdf file with RadSpreadProcessing]({%sluggrid-kb-custom-cell-formatting-with-radspreadprocessing%}) and how to [format the cells of the exported Pdf file with RadSpreadStreamProcessing]({%slug grid-kb-custom-cell-formatting-with-radspreadstreamprocessing%}).
199
+
For more advanced customization (such as coloring the headers or bolding the titles) the Grid lets you get the `MemoryStream` of the file. Thus, you can customize it using the [`SpreadProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) or the [`SpreadStreamProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radspreadstreamprocessing/overview) libraries that are available with your license. Find examples on how to [format the cells of the exported Pdf file with RadSpreadProcessing](slug:grid-kb-custom-cell-formatting-with-radspreadprocessing) and how to [format the cells of the exported Pdf file with RadSpreadStreamProcessing](slug: grid-kb-custom-cell-formatting-with-radspreadstreamprocessing).
196
200
197
-
Read more about how to [customize the exported file]({%sluggrid-export-events%}).
201
+
Read more about how to [customize the exported file](slug:grid-export-events).
198
202
199
203
## Notes
200
204
201
205
The Pdf export has the following specifics:
202
206
207
+
* When exporting grid columns, the developer must provide column widths that are appropriate for exporting the data. While an Excel file allows resizing its columns, the PDF file format does not allow resizing the columns. The width of the column can be changed from the `OnBeforeExportEventArgs.Columns[0].Width property`, so developers have full control over this value (note that it can be different from the one defined in the corresponding grid column, thus ensuring flexibility to render the grid columns with one widths and export them in others).
208
+
* We do not recommend exporting columns without widths - while Excel has a default width for a column, PDF requires fixed dimensions. We recommend setting specific widths to all columns when exporting (note that this is unrelated to the width of the column of the grid as the export width can be configured in `OnBeforeExportEventArgs.Columns[0].Width` property.
203
209
* Pdf does not understand units different than `px` for the column `Width`, and if you use them (such as `rem` or `%`), it will fail to parse them and will render a collapsed (hidden) column with zero width.
204
-
* Templates are not exported, because there is no provision in the framework for getting them at runtime. If a column, header or group header/footer has a template or aggregates, it will be ignored. The headers will be the `Title` of the column, the data is the data from the `Field`. If you need additional information, see if you can add it in a Field in the model, or create your own Pdf file. Find a <ahref="https://feedback.telerik.com/blazor/1485764-customize-the-Pdf-file-before-it-gets-to-the-client"target="_blank">project example on how to generate your own exported file</a>. Find additional information on how to [export an image that is rendered in a Grid column template]({%slug grid-export-image-column-Pdf%}).
210
+
* When exporting grid columns, the developer must provide appropriate `PaperSize` and `PageOrientation` properties. For example, if you want to render 20 columns (100px each) in a A4 sheet, then this will yield unexpected results. The column dimensions in a PDF file are fixed, thus they cannot be resized as in Excel, which requires the developer to ensure proper export dimensions.
211
+
* Exporting to PDF in UI for Blazor is different from exporting in Kendo jQuery, where the full HTML is exported. The Blazor export to PDF will export the Grid to a table, similar to an Excel table. If you want [to export to PDF as HTML, you can use a custom approach](#custom-export).
212
+
* Templates are not exported, because there is no provision in the framework for getting them at runtime. If a column, header or group header/footer has a template or aggregates, it will be ignored. The headers will be the `Title` of the column, the data is the data from the `Field`. If you need additional information, see if you can add it in a Field in the model, or create your own Pdf file. Find a <ahref="https://feedback.telerik.com/blazor/1485764-customize-the-Pdf-file-before-it-gets-to-the-client"target="_blank">project example on how to generate your own exported file</a>. Find additional information on how to [export an image that is rendered in a Grid column template](slug:grid-export-image-column-Pdf).
The [Telerik Document Processing tools]({%slugdpl-in-blazor%}) that come with your Blazor license let you generate a PDF file based on the data in the grid.
219
+
The [Telerik Document Processing tools](slug:dpl-in-blazor) that come with your Blazor license let you generate a PDF file based on the data in the grid.
212
220
213
221
The following sample projects show two ways to implement a PDF export
214
222
@@ -221,5 +229,5 @@ You can also follow the feature request for <a href="https://feedback.telerik.co
221
229
222
230
## See Also
223
231
224
-
*[Blazor Grid]({%sluggrid-overview%})
232
+
*[Blazor Grid](slug:grid-overview)
225
233
*[Live Demo: Grid Pdf Export](https://demos.telerik.com/blazor-ui/grid/export-Pdf)
0 commit comments