Hai
I am exporting the data from sqlserver to excel .
Is it possible to bold the headings and the set the document only to be read only
Code:
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Iwens_Database;User ID=a;Password=123;Integrated Security=SSPI;");
sqlquery = "SELECT E_id, E_Name, E_Address, E_Contact_No, E_Email, DOEn, E_noi, E_coursename, E_year, E_companyname, E_others, E_design, E_Selected, E_Followup FROM dbo.Enquiry_table";
SqlDataAdapter sda = new SqlDataAdapter(sqlquery, con);
DataTable dt = new DataTable();
sda.Fill(dt);
string attachment = "attachment; filename=enquiryed.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(tab + dc.ColumnName);
tab = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
tab = "";
for (i = 0; i < dt.Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
}
Kindly highlight the change you have made