Export to Excel,Read only,Bold heading in c#

Posted by Raja_89 under ASP.NET on 3/13/2013 | Points: 10 | Views : 659 | Status : [Member] | Replies : 1
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




Responses

Posted by: Satyapriyanayak on: 3/13/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://www.dotnetfunda.com/forums/thread13855-export-to-excelread-onlybold-heading-in-csharp.aspx

If this post helps you mark it as answer
Thanks

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response