Posted 5 April 2023, 10:56 pm EST
Hello,
I am using this method to export FlexGrid data to a CSV file for a Blazor server application.
private async Task HandleExcelExport(ClickEventArgs args)
{
using var stream = new MemoryStream();
_planValuesGrid.Save(stream, GridFileFormat.Csv, Encoding.UTF8, GridSaveOptions.SaveHeaders);
var fileName = "export.csv";
var fileContent = Encoding.UTF8.GetString(stream.GetBuffer());
await JSRuntime.InvokeVoidAsync("blazorInterop.saveFlexGridAsFile", fileName, fileContent);
}
As well as this JavaScript function:
//ComponentOne Blazor grid.
blazorInterop.saveFlexGridAsFile = function (filename, bytesBase64) {
var link = document.createElement('a');
link.download = filename;
link.href = "data:application/octet-stream;base64," + bytesBase64;
//Needed for Firefox.
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
However if executing I receive the browser download error: “Couldn’t download - Network issue”. I tried locally on MacOS as well as published to Azure.
Thank you
Daniel