Impossible to put a specific separator/delimiter for export csv on sfgrid
Hello,
I have a problem on my datagrid , when im trying to export data from the grid , im obtaining this strange data format:
because there are no properties delimiter or Separator in ExcelExportProperties im also have to do a new custom method
to allow export data from there problematics :
- No delimiter available for french format column in csv export
- Limit of 1000 lines when i export the data from data manager
have you got an idea to correct all this errors ?
Hi
Adrien,
Based on your requirement, we don’t have direct support, so we suggest a
workaround to your requirement. We have achieved your requirement by exporting
the Grid data to a csv with different delimiters. We have used the Syncfusion
ASP.NET Core method to export the data to a CSV file with a (;) semicolon
delimiter. We also attached the sample in the ticket for your reference.
Refer the below code example.
|
@using Syncfusion.XlsIO; @using System.IO; @inject IJSRuntime Runtime;
<SfButton OnClick="CsvExport" Content="CSV Export"></SfButton> <SfGrid @ref="DefaultGrid" DataSource="@Orders" AllowSorting="true" AllowExcelExport="true" AllowPaging="true"> . .. .. . . . . </SfGrid>
@code{ private SfGrid<Order> DefaultGrid;
public List<Order> Orders { get; set; }
public async void CsvExport() { using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0];
//Import the data to worksheet IList<Order> reports = Orders; // pass the datasoruce to csvexport worksheet.ImportData(reports, 2, 1, true);
MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream,";"); // save the workbook with different delimiter //to download the memory stream as file await Runtime.InvokeVoidAsync("exportSave", new object[] { "export.csv", Convert.ToBase64String(stream.ToArray()) }); } } } [export.js]
function exportSave(filename, bytesBase64) { var link = document.createElement('a'); link.download = filename;link.rel='nofollow' href = "data:application/octet-stream;base64," + bytesBase64; document.body.appendChild(link); // Needed for Firefox link.click(); document.body.removeChild(link);}
|
Note: above solution is a workaround so that is has some limitations.
Refer the below UG documentation for your reference
https://help.syncfusion.com/file-formats/xlsio/working-with-excel-worksheet#save-worksheet-as-csv
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CSVExport_
Regards,
Prathap Senthil