Showing posts with label render. Show all posts
Showing posts with label render. Show all posts

Monday, March 26, 2012

How to use the Render method to save a report directly to disk ?

Hi there,

Is there a way to programmatically save a RS results into Excel format using the render method ?

I had read about that capability but I can't seem to find any sample code on how to do it. Is this a parameter that you have to set in the render method ?

Any suggestion or tips are much appreciated !

Thanks !

Here's one way...

http://sqljunkies.com/WebLog/roman/archive/category/370.aspx

rs -i "C:\RS Script\MyScript.rss" -s http://myserver/reportserver

Here is the code from MyScript.rss. It renders the Product Line Sales report, it's one of the sample reports that comes with RS:

Public Sub Main()
Dim format as string = "EXCEL"
Dim fileName as String = "C:\RS Script\Product Line Sales.xls"
Dim reportPath as String = "/SampleReports/Product Line Sales"

' Prepare Render arguments
Dim historyID as string = Nothing
Dim deviceInfo as string = Nothing
Dim showHide as string = Nothing
Dim results() as Byte
Dim encoding as string
Dim mimeType as string
Dim warnings() AS Warning = Nothing
Dim reportHistoryParameters() As ParameterValue = Nothing
Dim streamIDs() as string = Nothing

results = rs.Render(reportPath, format, _
Nothing, Nothing, Nothing, _
Nothing, Nothing, encoding, mimeType, _
reportHistoryParameters, warnings, streamIDs)

' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub

cheers,

Andrew

|||

Hi andrew,

Thanks for the quick reply !

Yup, that works ! For now I am using this to save my reports to Excel.

I am not sure whether it is actually possible for the Render method to actually save a report to Excel without having to "see the report" or perhaps changing one of the parameters.

Can anyone verify this ?

Thanks.

|||

Hi there,

Glad to hear. Not sure what you mean about having to see the report? If you take a look at running from a URL and specifying the Excel Export option in the query parameters, you should not have to see the report. You would need to either define default parameters or specify required parameters for this to work.

You should be able to automate everything.

cheers,

Andrew

|||

Hi Andrew,

Well the problem with what I am doing is that I need to use the Render method so as not to expose the reporting server URL to outside sources. In other words through ASMX. I am trying not to "render" the report to the browser in Excel format.

So the regular way of rendering a report in the browser is the following:-

Response.ClearContent()

Response.AppendHeader("content-length", result.Length.ToString())

Response.ContentType = mimeType

Response.BinaryWrite(result)

Response.Flush()

Response.Close()

This will render the report in Excel to the browser. I was wondering whether there was a way to save the file as an excel without having to render it to a browser. I am also curious whether there was just more than setting the Format parameter to "EXCEL" and whether there were other parameters that I need to set ? (just like you mentioned in the post)

Thanks

Monday, March 19, 2012

How to use row values from query

Our database is normalized to the point that I need to build a dataset to
render a report from.
For example "select county name from COUNTYTABLE where COUNTYNUMBER IN
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ". This query return 1 column and 15
rows of county names. I need them to be in 1 row and 15 columns to make up
the data going accross the report. What is the best way to do this?
Thanks,
ShawnI you create a matrix report with County Name across the top of the matrix,
it will automatically generate the appropriate number of columns...
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
(Please respond only to the newsgroup.)
I support the Professional Association for SQL Server ( PASS) and it's
community of SQL Professionals.
"sysdesigner" <sysdesigner@.discussions.microsoft.com> wrote in message
news:55F38FB8-CBD1-4C1C-9611-8247A1A5C60E@.microsoft.com...
> Our database is normalized to the point that I need to build a dataset to
> render a report from.
> For example "select county name from COUNTYTABLE where COUNTYNUMBER IN
> (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ". This query return 1 column and
15
> rows of county names. I need them to be in 1 row and 15 columns to make
up
> the data going accross the report. What is the best way to do this?
> Thanks,
> Shawn
>|||I need to make a report that looks like...
Statistic A Statistic B Statistic C Statistic D
----
99 07 102 91
It would be easy but the values are all in one column in the table, like...
KeyValue | StatisticCode | StatisticValue
001| A| 99
002| B| 07
003| D| 91
004| C| 102
Thanks,
Shawn
"Wayne Snyder" wrote:
> I you create a matrix report with County Name across the top of the matrix,
> it will automatically generate the appropriate number of columns...
> --
> Wayne Snyder MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> (Please respond only to the newsgroup.)
> I support the Professional Association for SQL Server ( PASS) and it's
> community of SQL Professionals.
> "sysdesigner" <sysdesigner@.discussions.microsoft.com> wrote in message
> news:55F38FB8-CBD1-4C1C-9611-8247A1A5C60E@.microsoft.com...
> > Our database is normalized to the point that I need to build a dataset to
> > render a report from.
> >
> > For example "select county name from COUNTYTABLE where COUNTYNUMBER IN
> > (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ". This query return 1 column and
> 15
> > rows of county names. I need them to be in 1 row and 15 columns to make
> up
> > the data going accross the report. What is the best way to do this?
> >
> > Thanks,
> > Shawn
> >
>
>

How to use Render() SOAP API?

Hi
How do i use the Render() method? Where do i begin?
I am try out avoiding the grey pop-up message when exporting reports.
Currently, i have a java servlet web application. There are hyperlinks to the reports in some JSP pages. I am using URL Access now. How do i use SOAP API instead?
Thank youCheck
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_6x0z.asp.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Chiara" <Chiara@.discussions.microsoft.com> wrote in message
news:30F51016-EEA1-4D91-BCAF-A28124806033@.microsoft.com...
> Hi
> How do i use the Render() method? Where do i begin?
> I am try out avoiding the grey pop-up message when exporting reports.
> Currently, i have a java servlet web application. There are hyperlinks to
the reports in some JSP pages. I am using URL Access now. How do i use SOAP
API instead?
> Thank you