My users have a lot of reports that they need to generate and save in PDF
format. Each report is the same, except using different parameters.
What I'd like to do is programatically generate a bunch of PDF report files
to a folder on the network, each one using just a different set of parameters.
I have successfully generated a report using the URL:
http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
This pops up a Save As... dialog box, prompting the user for a path and
file name. I'd like to control and set the path file name programatically to
automatically generate all the report permutations by passing different
parameters.
Is the URL method the right approach? Any advice would be appreciated, or at
least point me in the right direction so I can research the actual mechanics
of doing this.
Thanks!!!I think what you want can be accomplished using the Subscription feature of
Reporting Services. You can specify a subscription with the "Report Server
File Share" delivery method in order to save PDFs to a folder on the network
on a specified schedule. You can also set up a shared schedule so all the
subscriptions run at the same time.
- Byron
"Smit-Dog" wrote:
> My users have a lot of reports that they need to generate and save in PDF
> format. Each report is the same, except using different parameters.
> What I'd like to do is programatically generate a bunch of PDF report files
> to a folder on the network, each one using just a different set of parameters.
> I have successfully generated a report using the URL:
> http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
> This pops up a Save As... dialog box, prompting the user for a path and
> file name. I'd like to control and set the path file name programatically to
> automatically generate all the report permutations by passing different
> parameters.
> Is the URL method the right approach? Any advice would be appreciated, or at
> least point me in the right direction so I can research the actual mechanics
> of doing this.
> Thanks!!!|||Thanks for the reply Bryon.
The only problem with setup up report subscriptions is that there are about
5 different parameters for the report, and basically I need to cycle through
dozens and dozens of possible parameter values for each parameter. And the
values are database driven, so they will change over time.
I'd like to programatically query the database for a list of valid parameter
values, then loop through the parameters list and generate all the PDF
reports with the proper syntax.
I'm guessing that I can do this from VB or .NET by accessing the SRS web
service interface. I just can't seem to find or understand the documentation
for doing this. Any example code would be great.
Thanks...
"Byron" wrote:
> I think what you want can be accomplished using the Subscription feature of
> Reporting Services. You can specify a subscription with the "Report Server
> File Share" delivery method in order to save PDFs to a folder on the network
> on a specified schedule. You can also set up a shared schedule so all the
> subscriptions run at the same time.
> - Byron
> "Smit-Dog" wrote:
> > My users have a lot of reports that they need to generate and save in PDF
> > format. Each report is the same, except using different parameters.
> >
> > What I'd like to do is programatically generate a bunch of PDF report files
> > to a folder on the network, each one using just a different set of parameters.
> >
> > I have successfully generated a report using the URL:
> >
> > http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
> >
> > This pops up a Save As... dialog box, prompting the user for a path and
> > file name. I'd like to control and set the path file name programatically to
> > automatically generate all the report permutations by passing different
> > parameters.
> >
> > Is the URL method the right approach? Any advice would be appreciated, or at
> > least point me in the right direction so I can research the actual mechanics
> > of doing this.
> >
> > Thanks!!!|||programmatically...
you mean something like this? I think this is right.
warnings = rs.CreateReport(asReportName, "/", True,
reportDefinition, Nothing)
If Not (warnings Is Nothing) Then
Dim warning As ReportService.Warning
For Each warning In warnings
lblMsg.Text = warning.Message
Next warning
Else
lblMsg.Text = "Report: {0} created successfully with no
warnings"
End If
result = rs.Render(reportName, "PDF", historyID, devInfo,
parameters, credentials, showHideToggle, encoding, mimeType,
reportHistoryParameters, warnings, streamIDs)
sh.SessionId = rs.SessionHeaderValue.SessionId
lblMsg.Text = "SessionID after call to Render: {0}" &
rs.SessionHeaderValue.SessionId
lblMsg.Text = "Execution date and time: {0}" &
rs.SessionHeaderValue.ExecutionDateTime
lblMsg.Text = "Is new execution: {0}" &
rs.SessionHeaderValue.IsNewExecution
' Write the contents of the report to an pdf file.
Try
' Dim stream As FileStream = File.Create("C:\" &
asReportName & ".pdf", result.Length)
Console.WriteLine("File created.")
stream.Write(result, 0, result.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Catch ex As Exception
lblMsg.Text = ex.Message
GoTo Exit_Sub
End Try
--
Message posted via http://www.sqlmonster.com
No comments:
Post a Comment