Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Export Access Reports

Export Access Reports

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andre Stroebel
    wrote on last edited by
    #1

    Hi all, I want to export reports in my database to snapshot viewer files. Access.ApplicationClass app = new Access.ApplicationClass(); app.AutomationSecurity = 1; app.OpenCurrentDatabase( "c:\\data\\Copy of ITS2005.mdb", false, "" ); app.DoCmd.OutputTo( Access.AcOutputObjectType.acOutputReport, "Licenced Fabricators", "Snapshot Format (*.snp)", "c:\\OMFS.snp", Type.Missing, Type.Missing, Type.Missing); app.DoCmd.Quit( Access.AcQuitOption.acQuitSaveNone ); This works perfectally fine in a windows form but the OpenCurrentDatabase just doesnt want to finish executing in ASP.NET Page. Any help would be appreciated! André.

    P 1 Reply Last reply
    0
    • A Andre Stroebel

      Hi all, I want to export reports in my database to snapshot viewer files. Access.ApplicationClass app = new Access.ApplicationClass(); app.AutomationSecurity = 1; app.OpenCurrentDatabase( "c:\\data\\Copy of ITS2005.mdb", false, "" ); app.DoCmd.OutputTo( Access.AcOutputObjectType.acOutputReport, "Licenced Fabricators", "Snapshot Format (*.snp)", "c:\\OMFS.snp", Type.Missing, Type.Missing, Type.Missing); app.DoCmd.Quit( Access.AcQuitOption.acQuitSaveNone ); This works perfectally fine in a windows form but the OpenCurrentDatabase just doesnt want to finish executing in ASP.NET Page. Any help would be appreciated! André.

      P Offline
      P Offline
      Pallavi Bhoite
      wrote on last edited by
      #2

      sorry but i dnt know if my answer will help u by any way or not. but i done xls report of database in my site. here is what i done earlier . there are two ways.. (but at final i used dataset and manually write .. to Responce. which is working fine and is Live)----- #region old code //Response.Clear(); //Response.Buffer= true; //Response.ContentType ="application/vnd.ms-excel"; //Response.Charset = ""; //this.EnableViewState = false; //System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); //this.ClearControls(Dgreport); //Dgreport.RenderControl(oHtmlTextWriter); //Response.Write(oStringWriter.ToString()); //Response.End(); #endregion ---------------------------------------------------- //try //{ #region old code diff way /*DataSet tempds2=new DataSet(); tempds2=getReportData(); if(!(tempds2.Tables[0].Rows.Count<=0)) { string fileName = "Report.xls"; string FullPath = Server.MapPath("\\")+fileName; tempds2.WriteXml(FullPath,XmlWriteMode.WriteSchema ); FileInfo file=new FileInfo(FullPath); if(file.Exists) { Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/vnd.ms-excel";//"application/octet-stream"; Response.WriteFile(file.FullName); } }*/ #endregion

      pallavi

      A 1 Reply Last reply
      0
      • P Pallavi Bhoite

        sorry but i dnt know if my answer will help u by any way or not. but i done xls report of database in my site. here is what i done earlier . there are two ways.. (but at final i used dataset and manually write .. to Responce. which is working fine and is Live)----- #region old code //Response.Clear(); //Response.Buffer= true; //Response.ContentType ="application/vnd.ms-excel"; //Response.Charset = ""; //this.EnableViewState = false; //System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); //this.ClearControls(Dgreport); //Dgreport.RenderControl(oHtmlTextWriter); //Response.Write(oStringWriter.ToString()); //Response.End(); #endregion ---------------------------------------------------- //try //{ #region old code diff way /*DataSet tempds2=new DataSet(); tempds2=getReportData(); if(!(tempds2.Tables[0].Rows.Count<=0)) { string fileName = "Report.xls"; string FullPath = Server.MapPath("\\")+fileName; tempds2.WriteXml(FullPath,XmlWriteMode.WriteSchema ); FileInfo file=new FileInfo(FullPath); if(file.Exists) { Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/vnd.ms-excel";//"application/octet-stream"; Response.WriteFile(file.FullName); } }*/ #endregion

        pallavi

        A Offline
        A Offline
        Andre Stroebel
        wrote on last edited by
        #3

        Thanx for the reply, Some questions, what exactly does this getReportData() method do and is it a custom method?? If your solution worked for u, can u perhaps supply he with a solution or code file plz? Otherwise dont you know of another way to export reports :sigh:

        P 1 Reply Last reply
        0
        • A Andre Stroebel

          Thanx for the reply, Some questions, what exactly does this getReportData() method do and is it a custom method?? If your solution worked for u, can u perhaps supply he with a solution or code file plz? Otherwise dont you know of another way to export reports :sigh:

          P Offline
          P Offline
          Pallavi Bhoite
          wrote on last edited by
          #4

          ya both the methods i given worked for me. the getReportData() is custom function wich return me dataset. and first method is useful if u want to export data u are seeing in datagrid (paging =true). but i moved to second because i wanted to export the whole dataset to xls not the page in datagrid. the third method i am using is not logical but works perfect for my clients requirement. take the data from database in dataset and simple generate the xls using . on 'export to excel' button click with javascript i open blank web form where on page load i write following code. u can pass dataset to this page or get datadet on this pageload. i hope u will get the useful from below-- Response.Clear(); Response.Buffer= true; StringBuilder responce_=new StringBuilder(); StringBuilder header=new StringBuilder(); header.Append(""+ ""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); if(!(tempds2.Tables[0].Rows.Count<=0)) { for(int i=0;i"); for(int j=0;j"+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+""); } else if(j==1 || j==2 ) { responce_.Append(""); } else if(j==3) { responce_.Append(""); } else { responce_.Append("");

          "+ ""+ "

          "+ "

          **

          " + "Customer Details Report "+ "

          **

          Customer ID

          Customer Name

          Address

          City

          Country

          Phone Number

          Mobile Number

          Fax Number

          Email

          Entry Date

          "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

          "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

          "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

          A 1 Reply Last reply
          0
          • P Pallavi Bhoite

            ya both the methods i given worked for me. the getReportData() is custom function wich return me dataset. and first method is useful if u want to export data u are seeing in datagrid (paging =true). but i moved to second because i wanted to export the whole dataset to xls not the page in datagrid. the third method i am using is not logical but works perfect for my clients requirement. take the data from database in dataset and simple generate the xls using . on 'export to excel' button click with javascript i open blank web form where on page load i write following code. u can pass dataset to this page or get datadet on this pageload. i hope u will get the useful from below-- Response.Clear(); Response.Buffer= true; StringBuilder responce_=new StringBuilder(); StringBuilder header=new StringBuilder(); header.Append(""+ ""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); header.Append(""); if(!(tempds2.Tables[0].Rows.Count<=0)) { for(int i=0;i"); for(int j=0;j"+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+""); } else if(j==1 || j==2 ) { responce_.Append(""); } else if(j==3) { responce_.Append(""); } else { responce_.Append("");

            "+ ""+ "

            "+ "

            **

            " + "Customer Details Report "+ "

            **

            Customer ID

            Customer Name

            Address

            City

            Country

            Phone Number

            Mobile Number

            Fax Number

            Email

            Entry Date

            "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

            "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

            "+tempds2.Tables[0].Rows[i].ItemArray[j].ToString()+"

            A Offline
            A Offline
            Andre Stroebel
            wrote on last edited by
            #5

            Hi, Thanks alot for your reply, this seems to be exactly what I am looking for!! I also think the second method is whit seems to be appropriate in this situation. :)

            P 1 Reply Last reply
            0
            • A Andre Stroebel

              Hi, Thanks alot for your reply, this seems to be exactly what I am looking for!! I also think the second method is whit seems to be appropriate in this situation. :)

              P Offline
              P Offline
              Pallavi Bhoite
              wrote on last edited by
              #6

              welcome..:)

              pallavi

              A 1 Reply Last reply
              0
              • P Pallavi Bhoite

                welcome..:)

                pallavi

                A Offline
                A Offline
                Andre Stroebel
                wrote on last edited by
                #7

                Hi, Soz to bother u again but you never told me what it is the getReportData does. I assume it gets the report using OLE, but how does one do that????

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups