Click here to Skip to main content
15,886,199 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Visual Basic.net Pin
Hermaine18-Apr-12 22:54
Hermaine18-Apr-12 22:54 
GeneralRe: Visual Basic.net Pin
Vipin_Arora19-Apr-12 2:23
Vipin_Arora19-Apr-12 2:23 
QuestionExport to Excel with number of columns unknown in advance Pin
biop.codeproject18-Apr-12 19:52
biop.codeproject18-Apr-12 19:52 
AnswerRe: Export to Excel with number of columns unknown in advance Pin
Hermaine18-Apr-12 21:09
Hermaine18-Apr-12 21:09 
AnswerRe: Export to Excel with number of columns unknown in advance Pin
ZurdoDev19-Apr-12 6:37
professionalZurdoDev19-Apr-12 6:37 
GeneralRe: Export to Excel with number of columns unknown in advance Pin
biop.codeproject19-Apr-12 16:49
biop.codeproject19-Apr-12 16:49 
AnswerRe: Export to Excel with number of columns unknown in advance Pin
ZurdoDev20-Apr-12 1:53
professionalZurdoDev20-Apr-12 1:53 
AnswerRe: Export to Excel with number of columns unknown in advance Pin
vvashishta24-Apr-12 18:55
vvashishta24-Apr-12 18:55 
Try This...it will work as per your requirement:

protected void cmdExport_Click(object sender, EventArgs e)
{
clsDataAcess oDataAccess = new clsDataAccess();
oDT = new DataTable();
oConst = new clsConstMaster();
string filename = string.Empty;
try
{
oDT = oDataAccess.GetCustomerWholeInformation(Parameter To function Here);

if (oDT.Rows.Count > 0)
{
filename = "CustomerInformationFromMaster.xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);

DataGrid dg = new DataGrid();
dg.DataSource = oDT;
dg.DataBind();

dg.HeaderStyle.BackColor = System.Drawing.Color.LightGray;
dg.HeaderStyle.Font.Bold = true;
foreach (DataGridItem i in dg.Items)
{
foreach (TableCell tc in i.Cells)
{
tc.Attributes.Add("class", "text");
//tc.BackColor = System.Drawing.Color.Blue;
}
}
dg.RenderControl(hw);
string style = @" .text { mso-number-format:\@; } ";

Response.Write(style);
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
}
}
catch (Exception ex)
{
MessageBox(ex.Message.ToString());
}
}
public override void VerifyRenderingInServerForm(Control control)
{
}
- Happy Coding -
Vishal Vashishta

Questionborder for the repeater control Pin
indian14318-Apr-12 18:58
indian14318-Apr-12 18:58 
AnswerRe: border for the repeater control Pin
Reza Ahmadi19-Apr-12 2:07
Reza Ahmadi19-Apr-12 2:07 
AnswerRe: border for the repeater control Pin
jkirkerx19-Apr-12 8:49
professionaljkirkerx19-Apr-12 8:49 
QuestionVB.net Pin
Hermaine18-Apr-12 18:48
Hermaine18-Apr-12 18:48 
AnswerRe: VB.net Pin
biop.codeproject18-Apr-12 19:54
biop.codeproject18-Apr-12 19:54 
GeneralRe: VB.net Pin
Hermaine18-Apr-12 20:52
Hermaine18-Apr-12 20:52 
AnswerRe: VB.net Pin
Abhinav S18-Apr-12 20:50
Abhinav S18-Apr-12 20:50 
GeneralRe: VB.net Pin
Hermaine18-Apr-12 20:58
Hermaine18-Apr-12 20:58 
AnswerRe: VB.net Pin
ZurdoDev19-Apr-12 6:39
professionalZurdoDev19-Apr-12 6:39 
AnswerRe: VB.net Pin
Vipin_Arora19-Apr-12 22:30
Vipin_Arora19-Apr-12 22:30 
QuestionWhen opening a SSRS report in visual stusio, gives error unable get IVSDDESIGNER SERVICE Pin
nainakarri18-Apr-12 18:14
nainakarri18-Apr-12 18:14 
QuestionGet and set the value of a literal in the list item in unordered list - jquery Pin
indian14318-Apr-12 13:03
indian14318-Apr-12 13:03 
AnswerRe: Get and set the value of a literal in the list item in unordered list - jquery Pin
jkirkerx18-Apr-12 18:28
professionaljkirkerx18-Apr-12 18:28 
GeneralRe: Get and set the value of a literal in the list item in unordered list - jquery Pin
indian14318-Apr-12 18:46
indian14318-Apr-12 18:46 
GeneralRe: Get and set the value of a literal in the list item in unordered list - jquery Pin
jkirkerx18-Apr-12 19:00
professionaljkirkerx18-Apr-12 19:00 
GeneralRe: Get and set the value of a literal in the list item in unordered list - jquery Pin
indian14319-Apr-12 5:55
indian14319-Apr-12 5:55 
Questionpdf rendering options Pin
indian14318-Apr-12 11:48
indian14318-Apr-12 11:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.