My code as follows
string connectionString = ConfigurationManager.ConnectionStrings["Connectionstring"].ConnectionString;
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
sqlConnection.Open();
if (reader.HasRows)
{
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
fileOutput.AutoFlush = true;
fileOutput.Write(reader[i].ToString() + "\t");
}
}
fileOutput.Write("\n");
}
}
sqlConnection.Close();
}
when i write the above and run in excel data will be download as follows
1 suresh 988789899 chennai IN 1
2 rajeshr 988788799 chennai IN 2
3 mootrhi 988787699 chennai Out 3
id Name Mobile Place Type Cityid
1 suresh 988789899 chennai IN 1
2 rajeshr 988788799 chennai IN 2
3 mootrhi 988787699 chennai Out 3
but in excel the above column name is not coming in excel when i download.
id Name Mobile Place Type Cityid
the above column name is not showing in excel when i download.
what is the mistake in my above code.
1 Reply
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.
Manas MohapatraPosted Aug 26, 2016, 2:47 PM