Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

Currently i'm doing Export to Excel concept. I know how to do this upto now it's working fine . But what is my question is ...

After Clicking the Exporting button one excel sheet is opened and display the total data in that but i want formated cells also...

for ex: i have a columns like ( doc, date,serial no )

now i want

doc -- uneditable mode
date -- text format
serial no -- text format


how to achieve this ....

can anyone help me out of this....

Note: Upto Now i'm doing Export DataTable data to Excel , i'm not using Grid controls

Previously i never use Interop Classes...
I tried for this past 3 days onwords can you please help me out of this to satisfy my requirement..

C#
string  attachment = "attachment; filename=EMS_BnF_Update.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dsExcelUpdate.Tables[0].Columns)
{
    Response.Write(tab + dc.ColumnName);
    tab = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dsExcelUpdate.Tables[0].Rows)
{
    tab = "";
    for (i = 0; i < dsExcelUpdate.Tables[0].Columns.Count; i++)
    {
        Response.Write(tab + dr[i].ToString());
        tab = "\t";
    }
    Response.Write("\n");
}
Response.End();
Posted
Updated 22-Apr-13 18:12pm
v3

Hi
try this solution
http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm[^]
you should get some great tutorials there. I hope it helps
 
Share this answer
 
You cannot format the cells without either using Interop or some heavy custom excel writer. The easiest method is this:
http://support.microsoft.com/kb/302084[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900