.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Export Multiple Gridviews To Word

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
Hi, I am trying to export multiple gridviews to Word.  I am able to do this but what i want to do is add some headings and text in between each grivdiew.  Please see my code below i am using to export the gridviews.         Response.Buffer = True        Response.ContentType = "Application/vnd.ms-word"        Response.ContentEncoding = System.Text.Encoding.Default        Response.AddHeader("content-disposition", "attachment;filename=evaluation_report.doc")        EnableViewState = False        Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter        Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)         dv_course_information.RenderControl(oHtmlTextWriter)        gv_gp_practices.RenderControl(oHtmlTextWriter)        gv_attendance_summary.RenderControl(oHtmlTextWriter)        gv_useful_activities.RenderControl(oHtmlTextWriter)         Response.Write(oSt

View Complete Post

More Related Resource Links

Word Automation - Multiple DCOM Errors/Behavior

Before I get started, I already know that Microsoft does not support and highly discourages server-based MS Office automation.  I've read a multitude of posts and smarmy "*wink*, here's a link" replies, so I'm looking for actual help here, not condescending reprimands.

That notwithstanding, here is my problem.  I have developed a simple method that will open a local Word document, modify some header information, and then save the document as a new file.  As expected, it works great as a console/windows app, but as soon as I went to ASP.NET, DCOM jacked my world up when accessing the app remotely from a different domain account (that has access to the ASP.NET app.  For reference, my method is shown below:


1    public static string ModifyAndSaveBuildDocument(string localFilePath, BuildDocumentType docType, string buildNumber, DateTime buildDate, string projectName)
2            {
3                try
4                {
5                    ProjectConfiguration config = (ProjectConfiguration)ConfigurationManager.GetSection("ProjectConfiguration");

Autocomplete with multiple word suggestions, How can we do in Asp.Net with Ajax?


Hi All,

Could you please let me know the process to get multiple word suggesions for a text box in asp.net using Ajax.  

Actually I got a solution for that,


But it used Atlas. When I am running with this code in my application, it is conflicting with Script Manager that is already there in Masterpage.

How can I overcome that problem. Is there any built-in solution in latest versions of Ajax?


Thanks in Advance,

Sateesh Nagalla,



Export to Word and include an image

Hi, I am able to export a gridview and other tables into Word, but i want to include an image in this.  How is this possible.  If i do as below the image is not displayed. Please see my code below:         Response.Buffer = True        Response.ContentType = "Application/vnd.ms-word"        Response.ContentEncoding = System.Text.Encoding.Default        Response.AddHeader("content-disposition", "attachment;filename=participant_attendance.doc")        EnableViewState = False        Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter        Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)         Dim style As String = "<style> .textmode { mso-number-format:\@; } </style>"        Dim table_text As String = String.Empty        Dim contact_text As String = String.Empty         ' Top table which contains the course information.    &nb

Exporting multiple gridviews in multiple excel tabs

Hi All, I am able to export multiple gridviews in a single excel worksheet My question is can I separate these gridviews in multiple tabs under the same excel file ? This is my current method under the link buttonprotected void lnkExport_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition","attachement;filename=TrendAnalysisRpt"+StoreNum); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); HtmlForm frm = new HtmlForm(); this.grd_Inj.Parent.Controls.Add(frm); this.grdBody_1.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Add(this.grd_Inj); frm.Controls.Add(this.grdBody_1); frm.Controls.Add(this.grdBody_2); frm.Controls.Add(this.grdBody_3); frm.Controls.Add(this.grdBody_4); frm.Controls.Add(this.grdMonth); frm.Controls.Add(this.grdDay); frm.Controls.Add(this.grdHours); frm.Controls.Add(this.grdLengthOS); frm.RenderControl(hw); Response.Write(sw.ToString()); Response.End(); } Thanks again!    

ssrs 2008 export to word 2010



I am having an issue with the header on an rdl file (ssrs 2008) when I export to word 2010.  The header gets cut off at the top of the page (about .5 inch).  But when I export to a PDF file it is fine.  If all our users exported only to pdf this would not be an issue, but unfortunately our users use both word and pdf to print out the reports.



SSRS Word Export Issue- Last Column Data getting Trim


We are exporting a SSRS report in Word. The last colum is getting displayed without its right side vertical bar. Data is also getting trim. Please let us know the solution on this.


Issue with Excel and Word Export - SSRS 2008


Hi there,

          I have created fairy simple report having a table in body section and Header, Footer. I have set the Report Properties

Orientation - Landscape

Paper Size - Custom

Width - 11in & Height - 8 in

Margins - Left 0.25 in , Right 0.25 in, Top 0.5 in, Botton 0.5 in

Issue NO 1: When i export the report to Excel, it takes margin as Left 0.75 in , Right 0.75 in, Top 1 in, Botton 1 in, because of this some part of my Report is cut. what should i do to keep margins of Excel as per margins set in RDL.

Issue No 2: In Footer excel shows Page 1 of 1 for all the pages

Expression used :



"Page" & Globals!PageNumber & " of " & Globals!TotalPages;

Issue No 3: when i export the Report to word, it does not consider landscape and show only middle part of report, cut rest of the report data.

Word Export error when orientation is Landscape in SSRS 2008


Hi there,

        I have created a report in SSRS 2008, In the report properties I have selected Orientation as Landscape but when i Export the report to Word it prints the report on middle of the page and cuts the rest of the report.

Urgent help is needed!!!

SSRS Export to Excel Multiple Sheets empty First Row


I have a report with four tables. There are page breaks in between each table (the Insert Page Break After this table option is selected on the first three tables). When I export this report to Excel, there are four sheets with the four tables of data on them. The 2nd, 3rd and 4th sheets all have the first row empty and its height is set to 0 so it looks like rwo 2 is the first one but row 1 is actually hidden. I need this row and would like the data to be populated in the first row and not the second. Has anyone come across this before?



Parsing Words from Multiple Recordsets - Returning With Word Counts


I've had too many sleepless nights trying to work this out - I hope I can get some help here.

I have three distinct ADO recordsets that I need to parse words from and return to the client with sorted full word counts (less a predefined dictionary of innocuous words e.g. a, an, the, of.) across all three, references to the original record and references to the original source. The user needs to be able to drill in and out of this result set.

I'm going to simplify the layout for clarification purposes.

Let's say each data source has three identical fields 'updatedTime' (DateTime), 'text'(VARCHAR(255)) and 'ID'.

User goes to the site and searches for the word 'frog'.
User is returned with a word count of every record that has the word 'frog' in the 'text' field sorted by the top count down.
'green' 18 times in table A, 12 times in table B, 22 times in table C
'hop' 16 times in table A, 13 times in table B, 6 times in table C.
'roadkill' 12, 11, 4
'red' 10, 12, 3
And so on.

User clicks on the word 'green'.
Now only words with both 'frog' AND 'green' in the original record show up (again, with the counts and sorted by count).
A breadcrumb is built, so the user can click on 'frog' again to kill that filter.
User decides he doesn't want the default timeframe (6 months) and adjusts a filter

Using ReportViewer.LocalReport.Render() method to export single report multiple times


I'm using the ReportViewer control on my .aspx page which displays a single report based on various user parameter selections.  Dropdown2 is dependent on the DropDown1 selection (i.e. the user selects Unit A from DropDown1 and that results in 10 selections under Dropdown2, or the user selects Unit B from DropDown1 and that results in 15 selections under DropDown2, and so on).  The user makes the selections, clicks the "Run Report" button, and the report displays as expected.  The user then can export to Excel or PDF

I've received a request to allow users to run the report for all possible selections and export to their desired format rather than having to run the report for each separate DropDown1 and DropDown2 selection.  So in other words, they don't even want to see the report on the screen, they just want to be able to click a button that runs the report for all possible parameter selections and export it to a single Excel or PDF document.

Does anyone have thoughts on how to best approach this?  Or is it even possible?  I know how to render a single report with parameters directly to PDF or Excel using the ReportViewer.LocalReport.Render() method, but I don't know how to render the same report multiple times to a single destination.

External Data Fields in a Word Template saved as a content type in a document library with multiple


I have created a Word Template for a Document Library that has an External Data Column in it of Client Name which also adds Client Address1, Client Address2, Client City, Client State, & Client Zip.  Now this works fine for a Document library with that template as the Template.dotx file. 

I want to be able to make a bunch of Templates and have them all as Content Types in one Library.  When I do this I cannot get the External Data Quick Parts to work.

Anyone have any ideas?

Lookup fileds with allow multiple values option enabled are separated by ;# in export spreadsheet


The lookup fields with allow multiple options enabled displays parent listitem id separated by ";#" when exporting to spreadsheet. I need to remove the #and the parent list item id from the spreadsheet. how to achieve that?

Any suggestions?

SSRS 08 SP2 - Export to Word places the Footer 0.5" from the bottom


I am using SSRS 08 SP2.  I have a report that has top and bottom margins of 0.25".  This report also has a page header and footer.  When I export the report to Word, the page margin settings from the report export correctly to Word, BUT the footer is displayed 0.5" from the bottom and the header is displayed 0.5" from the top, so the document appears to have a .75" margin.  This can be edited in the Word document by clicking "Edit Footer" and then going to the design tab and changing the "Header from Top" and "Footer from Bottom" settings manually.  However, is there any way to change the report so it exports to Word with the correct margins automatically?  My users don't want to edit the report manually each time it is generated.

Also, this is not an issue when exported to PDF.  The margins are also not an issue if the page footer and header are removed and the report is exported to Word.  It only occurs with a report with page headers/footers that is exported to Word.  However, in my current project, it is not an option to use PDF and I cannot remove the page header/footer.

How to delete multiple rows in DD GridViews?


Hi All,

I have started working on a DD project and would like to know how to delete multiple rows in DD GridViews?

I have added checkboxes to a GridView in ItemTemplate, but now sure how to associate "Delete" command to a custom button?

Reportviewer 2010 redistributable export to Ms Word pagenumber problem


Hi, in my asp.net app I use the Reportviewer 2010 tot show reports (RDLC). This is working fine, but when I export to Word the pagenumbers is always 1 from 1 even when the document contains 2 or more page, while when I export to PDF it is showing the right page number.

Anyone has the same problem?

Can you have InfoPath export a list into a Word Doc and have that mailed?


Have a very particular question here. We have a client that have items located in a list within SharePoint 2007. Their requirement is as follows...

After a new item is created

Take the items in the list and generate a new word document

Attach that word document with any other attachments to the item and email that to the client.

I was told this can be done in InfoPath but I don't see where InfoPath could automatically generate a Word Document from a list and email it somewhere. If this is possible can someone point me to an example please?

Any help is appreciated, thank you in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend