how to show the textfile data into datagridview in c#
i have one text file with me.i have to export the file in datagridview is it possible
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lacy MichellePosted Dec 18, 2012, 2:22 AM
OpenFileDialog dialog = new OpenFileDialog();dialog.Filter = "CSV document(*.csv)|*.csv";DialogResult result = dialog.ShowDialog();if (result == DialogResult.OK){string csvFile = dialog.FileName;Workbook workbook = new Workbook();workbook.LoadFromFile(@"D:\my file\csvtodatatable.csv", ",");Worksheet worksheet = workbook.Worksheets[0];System.Data.DataTable t = worksheet.ExportDataTable();this.dataGridView1.DataSource = t;
}
You can see details here:
CSV to Datatable
Satyapriya NayakPosted Dec 15, 2012, 2:08 AM