Export Blazor Grid to Server Folder location

Is it possible we can export Blazor Grid targetting to a Server Folder location?


5 Replies

RN Rahul Narayanasamy Syncfusion Team December 20, 2021 01:12 PM UTC

Hi Jaish, 

Greetings from Syncfusion. 

We have validated your query and we suspect that you want to specify the export directory location for the exported document. If yes, then we have considered you query as a new feature “Provide Local save export options support in Grid Export”. We are always trying to make our products better and feature requests like yours are a key part of our product growth efforts. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. The feature will be included in any of our upcoming releases. Until then we appreciate your patience. 
  
You can also communicate with us regarding the open features any time using our Feature Report page and you can track the status of your requirement by using the below feedback link.  
  
 
If it is not your requirement or if we misunderstood your requirement, then could you please share more details about your requirement.  
 
Please let us know if you have any concerns. 
  
Regards,  
Rahul 
 



JM Jaish Mathews December 20, 2021 02:22 PM UTC

Hello,


Thanks for the response. I am looking a path local to Server not browser. I use below code to get server path.


string rootPath = env.ContentRootPath;


If you also Ref. same path and not a future at present, you suggesting syncfusion Excel component for this requirement to meet? 



VN Vignesh Natarajan Syncfusion Team December 21, 2021 08:54 AM UTC

Hi Jaish,  
 
Thanks for the update.  
 
Query: “ am looking a path local to Server not browser. I use below code to get server path. 
 
We have analyzed your query and we suspect that you want to export the Grid data to directly to server path. Currently we have support to export the Grid document to excel, pdf and CSV format alone and that too by downloading the file to default download folder. Hence we do not have support for your requirement.  
 
As an alternative, we suggest you to export the Grid data to MemoryStream and save the memorystream in your Server Folder. If you are fine to achieve your requirement by storing the Grid data to MemoryStream, kindly get back to us. We will prepare a sample solution and update you.   
 
If we misunderstood your query, kindly share more details about your requirement.  
 
Regards, 
Vignesh Natarajan 



JM Jaish Mathews December 21, 2021 09:23 AM UTC

Yes. That would help, From browser, selected Grid data Memory Stream to send to  an API would do my requirement.. I need this data to attach as a file from my API during a mail send. How data reaching to API not a matter.



RN Rahul Narayanasamy Syncfusion Team December 22, 2021 01:32 PM UTC

Hi Jaish, 

Thanks for the update. 

We have validated your query and based on your request we have saved the Grid data to memory stream in the below sample. You can use this memory stream in your server location. Find the below code snippets and sample for your reference. 

@using Syncfusion.XlsIO; 
@using System.IO; 
 
<SfButton OnClick="CsvExport" Content="CSV Export"></SfButton> 
<SfGrid @ref="DefaultGrid" DataSource="@Orders" AllowSorting="true" AllowExcelExport="true" AllowPaging="true"> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</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 
 
             
        } 
    } 
} 


Please let us know if you have any concerns. 

Regards, 
Rahul 


Loader.
Up arrow icon