User-914536974 posted
I've used Excel component from
devtriogroup.com. Using it you will be able to
export data from MySQL to EXCEL easily.
Here's a sipet of my c# code:
// create an excel file
var wb = new DTG.Spreadsheet.ExcelWorkbook();
var excel = wb.Worksheets.Add("Sheet1");
// database connection
string MyConString = "SERVER=localhost;" +
"DATABASE=mydatabase;" +
"UID=testuser;" +
"PASSWORD=testpassword;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from mycustomers";
connection.Open();
Reader = command.ExecuteReader();
// Fill the excel worksheet
int row = 0;
while (Reader.Read())
{
for (int col = 0; col < Reader.FieldCount; col++)
excel.Cells[row, col].Value = Reader.GetValue(i).ToString();
row++;
}
connection.Close();
Hope it will help you.