Datagrid to Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JES
    New Member
    • Jun 2006
    • 1

    Datagrid to Excel

    I am trying to export a datagrid to Excel. Via web help, I'm 90% there. My
    only problem is that I would like to remove one column from the export. I've been successful at removing the data portion of the column, but I can't get rid of the heading. Any help would be appreciated.
  • hakeemkazmi
    New Member
    • Sep 2007
    • 3

    #2
    hi thr,i can help u this extent that you can remove the data waht eveer in column but even i am unable to completely remove column.try this or if you got any idea please forward to me also.but this is for the fields like buttonfields or linkfields.

    private void PrepareGridView ForExport(Contr ol gv)
    {

    Button lb = new Button();

    Literal l = new Literal();

    string name = String.Empty;

    for (int i = 0; i < gv.Controls.Cou nt; i++)
    {

    if (gv.Controls[i].GetType() == typeof(Button))
    {

    l.Text = (gv.Controls[i] as Button).Text;

    gv.Controls.Rem ove(gv.Controls[i]);

    }
    else
    if (gv.Controls[i].HasControls())
    {

    PrepareGridView ForExport(gv.Co ntrols[i]);

    }
    }




    Originally posted by JES
    I am trying to export a datagrid to Excel. Via web help, I'm 90% there. My
    only problem is that I would like to remove one column from the export. I've been successful at removing the data portion of the column, but I can't get rid of the heading. Any help would be appreciated.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Again moved to .NET forum.
      And guys let's make sure we all use code tags when posting code in the forums.

      Comment

      • insanomania911
        New Member
        • Sep 2007
        • 2

        #4
        But how do you export it at first place to Excel??

        I tried all the methods (codings) available online and none worked since I can't refrence to the PIA's (Interop) related to Microsoft Office.

        Is there any other way around it?

        Thanks,

        Comment

        • Shashi Sadasivan
          Recognized Expert Top Contributor
          • Aug 2007
          • 1435

          #5
          Please see the thread,
          This question was asked before


          Hope this also deletes the header

          cheers

          Comment

          Working...