Hi I am getting the data from Sql Server like

for about 1000 stores.
I need to put data in to excel file like as

and so on until now i have managed to code like as console application
if (reader.HasRows) {
while (reader.Read()) {
SqlDataAdapter da = new SqlDataAdapter("StoresWithProduct", connection);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@StoreID", reader.GetInt32(0));
DataSet ds = new DataSet();
da.Fill(ds, "table1");
foreach (DataRow dr1 in ds.Tables["table1"].Rows) {
Console.Write("Store Code:" + dr1["StoreCode"] + "\t");
foreach (DataRow dr in ds.Tables["table1"].Rows)
{
Console.Write(dr["itemNumber"]+"-" + dr["quantity"]+"\t\n");
}
break;
}
}
} else {
Console.WriteLine("No rows found.");
}
Console.ReadLine();
reader.Close();
connection.Close();
but not able to put into the excel file the way i want, any pointer will be appriciated.
Thanks
I would recommend looking at EPPlus
We’ve used this library extensively for generating complex Excel workbooks including pivot tables. Usage is very straightforward with plenty of examples and help on codeplex site.
I hope this helps!