Home » excel » winforms – Show excel like data in c#

winforms – Show excel like data in c#

Posted by: admin May 14, 2020 Leave a comment


I made a program that generates some data and want to show it in a grid like fashion like excel. What control should I use? I also want the user to be able to change the details if he wants to (like a textbox).

As an option step, is it possible to export this data to excel?


This is using c# and winforms

How to&Answers:

what about DataGridView?
make sure you set the DataSource…

DataTable dt = new DataTable();
//generate your data
dataGridView1.DataSource = dt;


I strongly recommend you use c# with WPF, its rich UI element and plug-in are perfect for your purpose, you can use datagrid control to show your data in the excel fashion.

The excel export is simple, just use Microsoft.Office.Interop.Excel class.


You can use MS Office Excel activeX control to view/edit excel documents.

Also Excel Viewer is an option.


Looks like question #1 is answered, so I’ll take a stab at question #2.

You can always save the gridview contents to a .CSV file format (comma separated values). Excel will automagically read that information into its workbook.