What methods can export excel file from stored procedure with parameters which input from web form?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ABC

    What methods can export excel file from stored procedure with parameters which input from web form?

    What methods can export excel file from stored procedure with parameters
    which input from web form?




  • Jason Hales

    #2
    Re: What methods can export excel file from stored procedure with parameters which input from web form?

    You're going to have to do a lot of this yourself - there's nothing
    built into the Frawework to support this althought here are many third
    party components that can help with creating Excel files

    I've used the Microsoft.Offic e.Interop.Excel namespace inside
    Microsoft.Offic e.Interop.Excel .dll.
    You'll need to download and install Office Primary Interop Assemblies.
    See


    I've used it in a Windows app to open Excel and write to cells.

    The trouble is these aren't meant to be used as server side components.
    Office 2006 contains Excel object model that is decoupled from the UI
    and intended for server-side use.

    Comment

    • CharlesA

      #3
      RE: What methods can export excel file from stored procedure with para

      one method to do it...

      bring the parametrized data back into a datagrid and add a 'save to excel'
      button on your form

      the following code in your webform:
      (you have to use your own datagrid's name in the top btnExportToExce l_Click,
      the ClearControl method takes out troublesome controls from the datagrid (in
      memory) and when it's done it calls the datagrid's RenderControl Method, a
      File save as dialog is thrown up and you're there)

      if your dataset is too large, this might not be an ideal method, but it
      works fine for exporting datagrid data from a web page



      private void btnExportToExce l_Click(object sender, System.EventArg s e)
      {
      //export to excel

      Response.Clear( );
      Response.Buffer = true;
      Response.Conten tType = "applicatio n/vnd.ms-excel";
      Response.Charse t = "";
      this.EnableView State = false;

      System.IO.Strin gWriter oStringWriter = new System.IO.Strin gWriter();
      System.Web.UI.H tmlTextWriter oHtmlTextWriter = new
      System.Web.UI.H tmlTextWriter(o StringWriter);

      this.ClearContr ols([enter your datagrid's name here]);
      [Enter your datagrid's name here].RenderControl( oHtmlTextWriter );

      Response.Write( oStringWriter.T oString());

      Response.End();

      }

      private void ClearControls(C ontrol control)
      {
      for (int i=control.Contr ols.Count -1; i>=0; i--)
      {
      ClearControls(c ontrol.Controls[i]);
      }

      if (!(control is TableCell))
      {
      if (control.GetTyp e().GetProperty ("SelectedItem" ) != null)
      {
      LiteralControl literal = new LiteralControl( );
      control.Parent. Controls.Add(li teral);
      try
      {
      literal.Text =
      (string)control .GetType().GetP roperty("Select edItem").GetVal ue(control,null );
      }
      catch
      {
      }
      control.Parent. Controls.Remove (control);
      }
      else
      if (control.GetTyp e().GetProperty ("Text") != null)
      {
      LiteralControl literal = new LiteralControl( );
      control.Parent. Controls.Add(li teral);
      literal.Text =
      (string)control .GetType().GetP roperty("Text") .GetValue(contr ol,null);
      control.Parent. Controls.Remove (control);
      }
      }
      return;
      }


      good luck
      CharlesA

      Comment

      • Steve C. Orr [MVP, MCSD]

        #4
        Re: What methods can export excel file from stored procedure with parameters which input from web form?

        There are a variety of ways to export data to Excel, most of which are
        detailed here:
        HALOJP merupakan situs toto online terlengkap dan terpercaya 2025 yang menyediakan akses cepat ke berbagai pasaran resmi, fitur lengkap, serta peluang menang tinggi bagi setiap pemain hanya dalam satu platform terbaik.


        If you want a more automatic approach, you might try one of these
        components:
        HALOJP merupakan situs toto online terlengkap dan terpercaya 2025 yang menyediakan akses cepat ke berbagai pasaran resmi, fitur lengkap, serta peluang menang tinggi bagi setiap pemain hanya dalam satu platform terbaik.

        HALOJP merupakan situs toto online terlengkap dan terpercaya 2025 yang menyediakan akses cepat ke berbagai pasaran resmi, fitur lengkap, serta peluang menang tinggi bagi setiap pemain hanya dalam satu platform terbaik.

        HALOJP merupakan situs toto online terlengkap dan terpercaya 2025 yang menyediakan akses cepat ke berbagai pasaran resmi, fitur lengkap, serta peluang menang tinggi bagi setiap pemain hanya dalam satu platform terbaik.


        You could also consider Crystal Reports or the new VSTO:


        --
        I hope this helps,
        Steve C. Orr, MCSD, MVP
        HALOJP merupakan situs toto online terlengkap dan terpercaya 2025 yang menyediakan akses cepat ke berbagai pasaran resmi, fitur lengkap, serta peluang menang tinggi bagi setiap pemain hanya dalam satu platform terbaik.



        "ABC" <abc@abc.com> wrote in message
        news:OaR$ArkUGH A.5704@TK2MSFTN GP10.phx.gbl...[color=blue]
        > What methods can export excel file from stored procedure with parameters
        > which input from web form?
        >
        >
        >
        >[/color]


        Comment

        Working...