Export Access Reports
-
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é. -
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é.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
-
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
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:
-
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:
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()+"
-
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()+"
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. :)
-
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. :)
welcome..:)
pallavi
-
welcome..:)
pallavi
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????