Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2b4708b
docs(grid): document pdf export
ntacheva Jan 7, 2025
1f63941
chore(grid): updated export articles
ntacheva Jan 10, 2025
8bff13d
chore(Grid): update pdf export article and examples
ntacheva Jan 14, 2025
c4e5888
chore(grid): update export events
ntacheva Jan 14, 2025
0693df0
chore(grid): final updates
ntacheva Jan 14, 2025
8c2a1bb
Merge branch 'master' into document-pdf-export
ntacheva Jan 14, 2025
4dcc00d
chore(grid): final
ntacheva Jan 14, 2025
d124154
Update components/grid/export/csv.md
ntacheva Jan 27, 2025
891526f
Update components/grid/export/csv.md
ntacheva Jan 27, 2025
6666346
Update components/grid/export/events.md
ntacheva Jan 27, 2025
060ef54
Update components/grid/export/excel.md
ntacheva Jan 27, 2025
1f01e33
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
2b49f77
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
8aa616f
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
56bdcec
Update components/grid/export/excel.md
ntacheva Jan 27, 2025
0a25374
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
6f1eb00
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
822019c
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
3e964d0
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
710e906
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
803d997
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
32dbc68
Update components/grid/export/pdf.md
ntacheva Jan 27, 2025
68ca24e
Update components/grid/export/pdf.md
ntacheva Jan 29, 2025
1fd3daa
chore(Grid): address feedback
ntacheva Jan 29, 2025
6b0cc76
Merge branch 'master' into document-pdf-export
ntacheva Jan 29, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(grid): final updates
  • Loading branch information
ntacheva committed Jan 14, 2025
commit 0693df0c97c9e1a4847fdd6eaaba278d88c60207
24 changes: 15 additions & 9 deletions components/grid/export/csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ To enable the grid CSV Export, add a [command button]({%slug components/grid/col
</GridToolBarTemplate>
````

Optionally, you can also set the `GridCsvExport` tag settings under the `GridExport` tag to choose:
Optionally, you can also set the `GridCsvExport` tag settings under the `GridExport` tag to subscribe to the [Grid export events](slug:grid-export-events) that allow further customization of the exported columns/data or configure the CSV export options:

* `FileName` - the name of the file. The grid will add the `.csv` extension for you.
* `AllPages` - whether to export the current page only, or the entire data from the data source.
* Subscribe to [Grid export events]({%slug grid-export-events%}) that allow further customizations of the exported columns or data.
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)

| Parameter | Type and Default&nbsp;Value | Description |
| --- | --- | --- |

| `FileName` | `string` | The name of the file. The grid will add the `.csv` extension for you. |
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |

>caption Export the Grid to CSV - Example

Expand Down Expand Up @@ -67,8 +71,9 @@ Optionally, you can also set the `GridCsvExport` tag settings under the `GridExp
</TelerikGrid>

@code {
List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }
private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
Expand Down Expand Up @@ -148,16 +153,17 @@ You can programmatically invoke the export feature of the Grid, by using the fol

private MemoryStream exportedCSVStream { get; set; }

private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

private async Task GetTheDataAsAStream()
{
MemoryStream finalizedStream = await GridRef.ExportToCsvAsync();

exportedCSVStream = new MemoryStream(finalizedStream.ToArray());
}

List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
Expand Down
14 changes: 10 additions & 4 deletions components/grid/export/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can customize the files exported to Excel and CSV by using the [OnBeforeExpo
- [OnAfterExport](#onafterexport)
- [For Excel Export](#for-excel-export-1)
- [For CSV Export](#for-csv-export-1)
- [For PDF Export](#for-pdf-export)
- [For PDF Export](#for-pdf-export-1)

## OnBeforeExport

Expand Down Expand Up @@ -258,14 +258,14 @@ To export a hidden Grid column that has its `Visible` parameter set to `false`,
* `Columns` - `List<GridPdfExportColumn>` - a collection of all exportable columns in the Grid. These are all visible `GridColumn` instances. You can customize the following attributes of the Grid column before exporting it into PDF:

* `Width` - define the width of the column **in pixels**.
* `Title` - define the column title to be shown in the Excel file header.
* `Title` - define the column title to be shown in the PDF file header.
* `NumberFormat` - provide an PDF-compatible number/date format
* `Field` - set the data bound field of the column.

To export a hidden Grid column that has its `Visible` parameter set to `false`, you can manually define an instance of the `GridPdfExportColumn` in the handler for the `OnBeforeExport` event and add that column to the `args.Columns` collection.


* `Data` - `IEnumerable<object>` - assign a custom collection of data to be exported to Excel, [for example only the selected items in the Grid]({%slug grid-kb-export-selected-rows%}).
* `Data` - `IEnumerable<object>` - assign a custom collection of data to be exported to PDF, [for example only the selected items in the Grid]({%slug grid-kb-export-selected-rows%}).

* `isCancelled` - `bool` - cancel the `OnBeforeExcel` event by setting the `isCancelled` property to `true`.

Expand Down Expand Up @@ -390,6 +390,8 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo

* `Stream` - `MemoryStream` - The output of the Excel export as a memory stream. 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.

>caption Get the stream of the exported Excel file

````RAZOR Excel
@* Get the output of the excel export as a memory stream *@

Expand Down Expand Up @@ -465,6 +467,8 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo

* `Stream` - `MemoryStream` - The output of the CSV export 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.

>caption Get the stream of the exported CSV file

````RAZOR CSV
@* Get the output of the CSV export as a memory stream *@

Expand Down Expand Up @@ -536,10 +540,12 @@ The `OnAfterExport` event fires after [OnBeforeExport](#onbeforeexport) and befo
}
````

### For Pdf Export
### For PDF Export

* `Stream` - `MemoryStream` - The output of the PDF export as a memory stream. 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.

>caption Get the stream of the exported PDF file

````RAZOR
@* Get the output of the PDF export as a MemoryStream *@

Expand Down
23 changes: 14 additions & 9 deletions components/grid/export/excel.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ To enable the Grid Excel Export, add a [command button]({%slug components/grid/c
</GridToolBarTemplate>
````

Optionally, you can also set the `GridExcelExport` tag settings under the `GridExport` tag to choose:
Optionally, you can also set the `GridExcelExport` tag settings under the `GridExport` tag to subscribe to the [Grid export events](slug:grid-export-events) that allow further customization of the exported columns/data or configure the Excel export options:

* `FileName` - the name of the file. The grid will add the `.xslx` extension for you.
* `AllPages` - whether to export the current page only, or the entire data from the data source.
* Subscribe to [Grid export events]({%slug grid-export-events%}) that allow further customizations of the exported columns or data.
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)

| Parameter | Type and Default&nbsp;Value | Description |
| --- | --- | --- |
| `FileName` | `string` | The name of the file. The grid will add the `.xslx` extension for you. |
| `AllPages` | `bool` | Whether to export the current page only, or the entire data from the data source. |

>caption Export the Grid to Excel - Example

Expand Down Expand Up @@ -67,8 +70,9 @@ Optionally, you can also set the `GridExcelExport` tag settings under the `GridE
</TelerikGrid>

@code {
List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }
private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
Expand Down Expand Up @@ -149,16 +153,17 @@ You can programmatically invoke the export feature of the Grid, by using the fol

private MemoryStream exportedExcelStream { get; set; }

private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

private async Task GetTheDataAsAStream()
{
MemoryStream finalizedStream = await GridRef.ExportToExcelAsync();

exportedExcelStream = new MemoryStream(finalizedStream.ToArray());
}

List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
Expand Down
17 changes: 9 additions & 8 deletions components/grid/export/pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To enable the Grid PDF Export, add a [command button](slug:components/grid/colum
</GridToolBarTemplate>
````

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 customization of the exported columns/data or configure the PDF export options:
Optionally, you can also set the `GridPdfExport` tag settings under the `GridExport` tag to subscribe to the [Grid export events](slug:grid-export-events) that allow further customization of the exported columns/data or configure the PDF export options:

@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)

Expand Down Expand Up @@ -78,8 +78,9 @@ Optionally, you can also set the `GridPdfExport` tag settings under the `GridExp
</TelerikGrid>

@code {
List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }
private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
Expand Down Expand Up @@ -158,17 +159,17 @@ You can programmatically invoke the export feature of the Grid, by using the fol

private MemoryStream exportedPdfStream { get; set; }

private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

private async Task GetTheDataAsAStream()
{
MemoryStream finalizedStream = await GridRef.ExportToPdfAsync();

exportedPdfStream = new MemoryStream(finalizedStream.ToArray());
}

private List<SampleData> GridData { get; set; }

private bool ExportAllPages { get; set; }

protected override void OnInitialized()
{
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
Expand Down Expand Up @@ -198,7 +199,7 @@ To customize the exported file, handle the `OnBeforeExport` or `OnAfterExport` e

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.

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).
For more advanced customization the Grid lets you get the `MemoryStream` of the file. Thus, you can customize it using the [`PdfProcessing`](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/overview) library that is available with your license.

Read more about how to [customize the exported file](slug:grid-export-events).

Expand Down