Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reporting using ASP.NET and MS Word

Status
Not open for further replies.

MetaFunk

Programmer
Aug 28, 2003
11
0
0
GB
Hi

I have requirement to develop a report in ASP.NET which needs to be exportable to MS Word.

The report format needs to be

Group A
Some Info ...
Some Info ...
Some Info ...

Group B
Some Info ...
Some Info ...
Some Info ...

Group C
Some Info ...
Some Info ...
Some Info ...

I think you get the picture. Any suggestions on the best way to acheive this ?

Regards
G,
 
I am not sure about MS Word, but would Excel do?

If you databind a datagrid control you can then execute the following code to make it come out as Excel. Just change dgResults to whatever the name of your datagrid is. You might get this to go into Word if you change the vnd.ms-excel part to read vnd.ms-word but I haven't tested it so don't know.

If Me.dgResults.Items.Count > 0 Then
'Set the content type to Excel...
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
dgResults.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
Else
GetDataSet()
End If


HTH

Eva
 
Hi Eva

Thanks for yor reply. I am familiar with the Excel method.

The requirement is for MS Word and the bigger problem is data grouping which I have explained earlier.


G,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top