How can I export the data of sfdatagrid to txt?

The export method of sfdatagrid seems to have html and pdf.
I want to export as a tab-delimited txt file.
Is there a way?

3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team May 21, 2021 01:11 PM UTC

Hi nam ki hun,

Thank you for contacting Syncfusion support.

Your requirement can be achieved export the SfDataGrid into Excel. The exported workbook can be saved as txt file by using the SaveAs method. Please refer the below code snippet, 
private void BtnExportExcel_Click(object sender, EventArgs e) 
{ 
            var options = new ExcelExportingOptions(); 
            options.ExcelVersion = ExcelVersion.Excel2013; 
            var excelEngine = sfDataGrid.ExportToExcel(sfDataGrid.View, options); 
            var workBook = excelEngine.Excel.Workbooks[0]; 
            workBook.SaveAs("Sample.txt", "\t");             
}   

UG Link: https://help.syncfusion.com/windowsforms/datagrid/exporttoexcel#export-to-csv

Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 


Marked as answer

NK nam ki hun June 8, 2021 07:54 AM UTC

Thank you.
solved ^^


VS Vijayarasan Sivanandham Syncfusion Team June 9, 2021 05:07 AM UTC

Hi nam ki hun,

Thanks for the update.

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.

Regards, 
Vijayarasan S 


Loader.
Up arrow icon