From 55e81bc619b82c59645fe8b00eac772100f5a988 Mon Sep 17 00:00:00 2001 From: SanjayKumarSuresh Date: Tue, 16 Jun 2026 19:18:36 +0530 Subject: [PATCH 1/5] 1033941: Encoding UG Docs --- blazor/datagrid/excel-export-options.md | 116 ++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/blazor/datagrid/excel-export-options.md b/blazor/datagrid/excel-export-options.md index 01b55f903f..b11709d2c7 100644 --- a/blazor/datagrid/excel-export-options.md +++ b/blazor/datagrid/excel-export-options.md @@ -21,6 +21,7 @@ The export behavior can be customized using the [ExcelExportProperties](https:// * Exporting multiple Grids. * Customizing data using queries. * Defining delimiters for CSV export. +* Encoding support for CSV export. * Applying themes. ## Export current page records @@ -1135,6 +1136,121 @@ public class OrderData {% previewsample "https://blazorplayground.syncfusion.com/embed/VtrxNHZhrfXTmOyO?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} +## Encoding support for CSV Exporting + +The Syncfusion Blazor DataGrid provides support for specifying encoding in exported CSV documents. This capability enables customization of the character encoding format to meet specific requirements. To configure encoding, include the **System.Text** namespace in the application. This namespace provides access to various encoding types. For detailed information about supported encoding formats, refer to the official Microsoft documentation [here](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-10.0). + +> By default, the **Encoding.UTF8** type is used to export the CSV document. + +To customize the encoding type, use the **Encoding** property inside the [ExcelExportProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.ExcelExportProperties.html) class, and provide the customization using the Encoding Enum which derives from the System.Text namespace. Please refer the below sample for implementation. + + +{% tabs %} +{% highlight razor tabtitle="Index.razor" %} + + +@using Syncfusion.Blazor.Grids + + + + + + + + + + + + +@code +{ + SfGrid? Grid; + public List? GridData { get; set; } + + protected override void OnInitialized() + { + GridData = OrdersDetails.GetAllRecords(); + } + + public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args) + { + if (this.Grid != null) + { + if (args.Item.Id == "Grid_pdfexport") + { + this.Grid.ExportToPdfAsync(); + } + else if (args.Item.Id == "Grid_excelexport") + { + this.Grid.ExportToExcelAsync(); + } + else + { + this.Grid.ExportToCsvAsync(new ExcelExportProperties + { + Encoding = System.Text.Encoding.UTF8, + }); + } + } + } +} + +{% endhighlight %} + +{% highlight c# tabtitle="OrderDetails.cs" %} + + public class OrdersDetails + { + public OrdersDetails() + { + } + public OrdersDetails(int OrderID, string CustomerId, int EmployeeId, double Freight, bool Verified, DateTime OrderDate, string ShipCity, string ShipName, string ShipCountry, DateTime ShippedDate, string ShipAddress, string Email) + { + this.OrderID = OrderID; + this.CustomerID = CustomerId; + this.EmployeeID = EmployeeId; + this.Freight = Freight; + this.ShipCity = ShipCity; + this.Verified = Verified; + this.OrderDate = OrderDate; + this.ShipName = ShipName; + this.ShipCountry = ShipCountry; + this.ShippedDate = ShippedDate; + this.ShipAddress = ShipAddress; + this.Email = Email; + } + public static List GetAllRecords() + { + List order = new List(); + int code = 10000; + for (int i = 1; i <= 15; i++) + { + order.Add(new OrdersDetails(code + 1, "€ ALFKI", i + 0, Math.Round((2.3 * i), 2), false, new DateTime(1991, 05, 15), "Berlin", "Simons bistro", "Denmark", new DateTime(1996, 7, 16), "Kirchgasse 6", "alfki@domain.com")); + order.Add(new OrdersDetails(code + 2, "€ ANATR", i + 2, Math.Round((3.3 * i), 2), true, new DateTime(1990, 04, 04), "Madrid", "Queen Cozinha", "Brazil", new DateTime(1996, 9, 11), "Avda. Azteca 123", "anatr@domain.com")); + order.Add(new OrdersDetails(code + 3, "¤ ANTON", i + 1, Math.Round((4.3 * i), 2), false, new DateTime(1957, 11, 30), "Cholchester", "Frankenversand", "Germany", new DateTime(1996, 10, 7), "Carrera 52 con Ave. Bolívar #65-98 Llano Largo", "anton@domain.com")); + order.Add(new OrdersDetails(code + 4, "¤ BLONP", i + 3, Math.Round((5.3 * i), 2), true, new DateTime(1930, 10, 22), "Marseille", "Ernst Handel", "Austria", new DateTime(1996, 12, 30), "Magazinweg 7", "blonp@domain.com")); + order.Add(new OrdersDetails(code + 5, "BOLID", i + 4, Math.Round((6.3 * i), 2), false, new DateTime(1953, 02, 18), "Tsawassen", "Hanari Carnes", "Switzerland", new DateTime(1997, 12, 3), "1029 - 12th Ave. S.", "bolid@domain.com")); + code += 5; + } + return order; + } + public int? OrderID { get; set; } + public string? CustomerID { get; set; } + public int? EmployeeID { get; set; } + public double? Freight { get; set; } + public string? ShipCity { get; set; } + public bool Verified { get; set; } + public DateTime? OrderDate { get; set; } + public string? ShipName { get; set; } + public string? ShipCountry { get; set; } + public DateTime? ShippedDate { get; set; } + public string? ShipAddress { get; set; } + public string? Email { get; set; } + } + +{% endhighlight %} +{% endtabs %} + ## Conditional cell formatting The Blazor DataGrid supports conditional formatting of cells in the exported Excel document. This feature enables customizing the appearance of specific cells based on values or defined criteria. From 15d6d03987373d35374a08cbb021400cdece2e7a Mon Sep 17 00:00:00 2001 From: SanjayKumarSuresh Date: Wed, 17 Jun 2026 12:07:46 +0530 Subject: [PATCH 2/5] 1033941: Encoding UG Docs --- blazor/datagrid/excel-export-options.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/blazor/datagrid/excel-export-options.md b/blazor/datagrid/excel-export-options.md index b11709d2c7..94b6ac620d 100644 --- a/blazor/datagrid/excel-export-options.md +++ b/blazor/datagrid/excel-export-options.md @@ -1138,20 +1138,28 @@ public class OrderData ## Encoding support for CSV Exporting -The Syncfusion Blazor DataGrid provides support for specifying encoding in exported CSV documents. This capability enables customization of the character encoding format to meet specific requirements. To configure encoding, include the **System.Text** namespace in the application. This namespace provides access to various encoding types. For detailed information about supported encoding formats, refer to the official Microsoft documentation [here](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-10.0). +The Syncfusion Blazor DataGrid supports specifying encoding for exported CSV documents. This capability enables customization of the character encoding format to meet specific requirements. To configure encoding, include the **System.Text** namespace in the application. This namespace provides access to various encoding types. For detailed information about supported encoding formats, refer to the official Microsoft documentation [here](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-10.0). + +### When to use custom encoding + +- When exporting data with special characters or symbols. + +- When integrating with legacy systems requiring specific encodings. + +- When opening CSV files in software that does not default to UTF-8. > By default, the **Encoding.UTF8** type is used to export the CSV document. -To customize the encoding type, use the **Encoding** property inside the [ExcelExportProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.ExcelExportProperties.html) class, and provide the customization using the Encoding Enum which derives from the System.Text namespace. Please refer the below sample for implementation. +To customize the encoding type, use the **Encoding** property inside the [ExcelExportProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.ExcelExportProperties.html) class, and provide the customization using the **System.Text.Encoding** class which derives from the System.Text namespace. Refer to the following example. {% tabs %} {% highlight razor tabtitle="Index.razor" %} - @using Syncfusion.Blazor.Grids +@using System.Text - + @@ -1176,11 +1184,7 @@ To customize the encoding type, use the **Encoding** property inside the [ExcelE { if (this.Grid != null) { - if (args.Item.Id == "Grid_pdfexport") - { - this.Grid.ExportToPdfAsync(); - } - else if (args.Item.Id == "Grid_excelexport") + if (args.Item.Id == "Grid_excelexport") { this.Grid.ExportToExcelAsync(); } @@ -1251,6 +1255,8 @@ To customize the encoding type, use the **Encoding** property inside the [ExcelE {% endhighlight %} {% endtabs %} + + ## Conditional cell formatting The Blazor DataGrid supports conditional formatting of cells in the exported Excel document. This feature enables customizing the appearance of specific cells based on values or defined criteria. From 3e4d734d38e0f76be0598a7b882196fa59b7af6e Mon Sep 17 00:00:00 2001 From: SanjayKumarSuresh Date: Wed, 17 Jun 2026 13:29:43 +0530 Subject: [PATCH 3/5] 1033941: Encoding UG Docs --- blazor/datagrid/excel-export-options.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/blazor/datagrid/excel-export-options.md b/blazor/datagrid/excel-export-options.md index 94b6ac620d..02e2020d01 100644 --- a/blazor/datagrid/excel-export-options.md +++ b/blazor/datagrid/excel-export-options.md @@ -1136,7 +1136,7 @@ public class OrderData {% previewsample "https://blazorplayground.syncfusion.com/embed/VtrxNHZhrfXTmOyO?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} -## Encoding support for CSV Exporting +## Encoding support for CSV Export The Syncfusion Blazor DataGrid supports specifying encoding for exported CSV documents. This capability enables customization of the character encoding format to meet specific requirements. To configure encoding, include the **System.Text** namespace in the application. This namespace provides access to various encoding types. For detailed information about supported encoding formats, refer to the official Microsoft documentation [here](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-10.0). @@ -1150,8 +1150,7 @@ The Syncfusion Blazor DataGrid supports specifying encoding for exported CSV doc > By default, the **Encoding.UTF8** type is used to export the CSV document. -To customize the encoding type, use the **Encoding** property inside the [ExcelExportProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.ExcelExportProperties.html) class, and provide the customization using the **System.Text.Encoding** class which derives from the System.Text namespace. Refer to the following example. - +To configure the encoding, handle the [OnToolbarClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridEvents-1.html#Syncfusion_Blazor_Grids_GridEvents_1_OnToolbarClick) event and invoke the [ExportToCsvAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_ExportToCsvAsync_Syncfusion_Blazor_Grids_ExcelExportProperties_) method with the **Encoding** property set in the [ExcelExportProperties](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.ExcelExportProperties.html) object and provide the customization using the **System.Text.Encoding** class which derives from the **System.Text** namespace. Refer to the following example. {% tabs %} {% highlight razor tabtitle="Index.razor" %} @@ -1159,7 +1158,7 @@ To customize the encoding type, use the **Encoding** property inside the [ExcelE @using Syncfusion.Blazor.Grids @using System.Text - + @@ -1188,7 +1187,7 @@ To customize the encoding type, use the **Encoding** property inside the [ExcelE { this.Grid.ExportToExcelAsync(); } - else + else if (args.Item.Id == "Grid_csvexport") { this.Grid.ExportToCsvAsync(new ExcelExportProperties { From bfc2b4a2243f1d621f2d495da758a93c6267bfcb Mon Sep 17 00:00:00 2001 From: SanjayKumarSuresh Date: Wed, 17 Jun 2026 13:47:44 +0530 Subject: [PATCH 4/5] 1033941: Changes made --- blazor/datagrid/excel-export-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blazor/datagrid/excel-export-options.md b/blazor/datagrid/excel-export-options.md index 02e2020d01..00a835bca0 100644 --- a/blazor/datagrid/excel-export-options.md +++ b/blazor/datagrid/excel-export-options.md @@ -1254,7 +1254,7 @@ To configure the encoding, handle the [OnToolbarClick](https://help.syncfusion.c {% endhighlight %} {% endtabs %} - +> Note: The `ExcelExportProperties` class is also used for configuring CSV export options, including encoding ## Conditional cell formatting From e84046901f337e1b77d148e5974efbb089d6ded8 Mon Sep 17 00:00:00 2001 From: sanjaykumar-suresh <93911504+sanjaykumar-suresh@users.noreply.github.com> Date: Wed, 17 Jun 2026 17:48:44 +0530 Subject: [PATCH 5/5] 1033941: Header Casing changes --- blazor/datagrid/excel-export-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blazor/datagrid/excel-export-options.md b/blazor/datagrid/excel-export-options.md index 00a835bca0..fcf4523aec 100644 --- a/blazor/datagrid/excel-export-options.md +++ b/blazor/datagrid/excel-export-options.md @@ -1136,7 +1136,7 @@ public class OrderData {% previewsample "https://blazorplayground.syncfusion.com/embed/VtrxNHZhrfXTmOyO?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} -## Encoding support for CSV Export +## Encoding support for CSV export The Syncfusion Blazor DataGrid supports specifying encoding for exported CSV documents. This capability enables customization of the character encoding format to meet specific requirements. To configure encoding, include the **System.Text** namespace in the application. This namespace provides access to various encoding types. For detailed information about supported encoding formats, refer to the official Microsoft documentation [here](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-10.0).