view datagrid report in .xls or .pdf

  • Thread starter Thread starter scarred wind
  • Start date Start date
S

scarred wind

Hello all!

I'm currently working on a report using webform in VB.Net for the
company i'm working with.

The layout is something like this:

Header(.inc)

Calendar start ---- Calender end (user choose the date they want to
view the report)

create report button (user click this button after specifying the date
and report is then generate)

Footer(.inc)

------------------------
Output:

The report is generated in datagrid according to the date selected.

Header(.inc)

Calendar start ---- Calendar end

Datagrid (with the data provided from stored procedure, which the user
wanted to see)

Footer(.inc)

------------------------
What i want:

after the report is generated, what i want is to enable the user to view
it in .pdf and/or .xls format, by the click of button.
I know i should/can use CrystalReport for this kind of thing, but i'm
not familiar with CrystalReport, i don't know how it works... If
possible i'd like to do this coding without having to use CrystalReport.


I hope, I've been clear to my problem...

Thank you in advance!
Yours,
syidah
 
found a solution for this one. i've found a good code for letting the
user view the datagrid in excel format.
i hope this will be a good share for all ^^

'below are the conversion codes from datagrid to excel
If Request.QueryString("bExcel") = "1" Then

'Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel"

'Remove the charset from the Content-Type header.
Response.Charset = ""

'Turn off the view state.
Me.EnableViewState = False

Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

'Get the HTML for the control
DataGrid1.RenderControl(hw)

'Write the HTML back to the browser
Response.Write(tw.ToString())

'End the response.
Response.End()

Notes: there are supposed to be two pages for this one.
 
what i mean is two webforms, one to do the conversion process from the
server, one to return the resulting conversion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top