How to generate Report in MS Word
-
Hi, I am using asp.net 2.0 and working with creating reports. I have shown the Output (Report) in the web page using several GridView, Details view, etc. by binding with the database Sql Server. I wish to SAVE the entire (report) page, how I am seeing the page actually in the page, as MS WORD (.doc) format. Because I wish to send this file as a attachment to the client. Anyone can give me the clue for this? Thanks.
Regards, Jay
-
Hi, I am using asp.net 2.0 and working with creating reports. I have shown the Output (Report) in the web page using several GridView, Details view, etc. by binding with the database Sql Server. I wish to SAVE the entire (report) page, how I am seeing the page actually in the page, as MS WORD (.doc) format. Because I wish to send this file as a attachment to the client. Anyone can give me the clue for this? Thanks.
Regards, Jay
hi use the code given below this will be usefull protected void word_Click(object sender, EventArgs e) { //string attachment = "attachment; filename=f.xls"; SqlDataAdapter da = new SqlDataAdapter("select * from empdata", cn); DataSet dsExport = new DataSet(); da.Fill(dsExport); System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dsExport; // //Report Header hw.WriteLine("" + "Report for the Employee Information: " + ""); //hw.WriteLine("
"); //// Response.AddHeader("emp info", attachment); // // Get the HTML for the control. dgGrid.HeaderStyle.Font.Bold = true; dgGrid.DataBind(); dgGrid.RenderControl(hw); // // Write the HTML back to the browser. Response.ContentType = "application/msword"; this.EnableViewState = false; Response.Write(tw.ToString()); Response.End(); } -
Hi, I am using asp.net 2.0 and working with creating reports. I have shown the Output (Report) in the web page using several GridView, Details view, etc. by binding with the database Sql Server. I wish to SAVE the entire (report) page, how I am seeing the page actually in the page, as MS WORD (.doc) format. Because I wish to send this file as a attachment to the client. Anyone can give me the clue for this? Thanks.
Regards, Jay
let me know the given really helps u or not? don't forget to reply
-
let me know the given really helps u or not? don't forget to reply
-
Hi, I hope, what you have given is correct. Can you please explain me or refer a article for this to understand. Because I am very new to this. Please help me. Thanks
Regards, Jay
hi jay first u show me the coding u have done
-
hi jay first u show me the coding u have done
Hi, I dont know, where to start with. Because, 1. I neeed to create aroud 10 Table format information, which may be created in 6 web pages (aspx) NOT A SINGLE Web page. If I combine everything in one page, the page length is too long. 2. I wish to combine the all the page's output and WRITE in a single WORD file. 3. The WORD file has contains some output fron WebPage and also some Sataic contents like NOTE,Company address, etc. 4. what is word_Click in your code?? Whether after clicking the button, then only the web page is displayed and word file is wrote?
Regards, Jay :)
-
Hi, I dont know, where to start with. Because, 1. I neeed to create aroud 10 Table format information, which may be created in 6 web pages (aspx) NOT A SINGLE Web page. If I combine everything in one page, the page length is too long. 2. I wish to combine the all the page's output and WRITE in a single WORD file. 3. The WORD file has contains some output fron WebPage and also some Sataic contents like NOTE,Company address, etc. 4. what is word_Click in your code?? Whether after clicking the button, then only the web page is displayed and word file is wrote?
Regards, Jay :)
word_click is just list button_click.......ok here button text&id is word
-
word_click is just list button_click.......ok here button text&id is word
-
Hi, I have got the below error in the following line GridView1.RenderControl(hw); Http Exception: Control 'ctl00_ContentPlaceHolder1_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
Regards, Jay :)
as an example take a sample grid and populate with data from database and then press button here text and id of button is word protected void word_Click(object sender, EventArgs e) { //string attachment = "attachment; filename=f.xls"; SqlDataAdapter da = new SqlDataAdapter("select * from empdata", cn); DataSet dsExport = new DataSet(); da.Fill(dsExport); System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); //DataGrid dgGrid = new DataGrid(); //dgGrid.DataSource = dsExport; DataGrid1.DataSource = dsExport; // //Report Header hw.WriteLine("" + "Report for the Employee Information: " + ""); //hw.WriteLine("
"); //// Response.AddHeader("emp info", attachment); // // Get the HTML for the control. //dgGrid.HeaderStyle.Font.Bold = true; //dgGrid.DataBind(); //dgGrid.RenderControl(hw); DataGrid1.HeaderStyle.Font.Bold = true; DataGrid1.DataBind(); DataGrid1.RenderControl(hw); // // Write the HTML back to the browser. Response.ContentType = "application/msword"; this.EnableViewState = false; Response.Write(tw.ToString()); Response.End(); } -
as an example take a sample grid and populate with data from database and then press button here text and id of button is word protected void word_Click(object sender, EventArgs e) { //string attachment = "attachment; filename=f.xls"; SqlDataAdapter da = new SqlDataAdapter("select * from empdata", cn); DataSet dsExport = new DataSet(); da.Fill(dsExport); System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); //DataGrid dgGrid = new DataGrid(); //dgGrid.DataSource = dsExport; DataGrid1.DataSource = dsExport; // //Report Header hw.WriteLine("" + "Report for the Employee Information: " + ""); //hw.WriteLine("
"); //// Response.AddHeader("emp info", attachment); // // Get the HTML for the control. //dgGrid.HeaderStyle.Font.Bold = true; //dgGrid.DataBind(); //dgGrid.RenderControl(hw); DataGrid1.HeaderStyle.Font.Bold = true; DataGrid1.DataBind(); DataGrid1.RenderControl(hw); // // Write the HTML back to the browser. Response.ContentType = "application/msword"; this.EnableViewState = false; Response.Write(tw.ToString()); Response.End(); }it is working fine for me i tested again ok bye best of luck
-
it is working fine for me i tested again ok bye best of luck
-
Hi, I have got the below error in the following line GridView1.RenderControl(hw); Http Exception: Control 'ctl00_ContentPlaceHolder1_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
Regards, Jay :)