Free Support Forum - aspose.com

Saving reports instead of rendering

is there anyway to automate the saving of a report to a network directory instead of having the ie prompt asking if you want to save/open? we want to take the power away from the employees because our word docs need to be saved in one centralised location.<br>

Hi,

Thank you for your request. If you meant to use Aspose.Words for Reporting Services, then I think you could use the Reporting Services web service. Perhaps I can provide you a sample code, but please give me more details of your task to make sure I'm on right way.

i wrote this code myself to do an http request and save the results onto my local drive, but is there a webservice call that can do the same? basically i will be running this report from vb6 and the only solution i have come up with is to pull an aspx page up that pulls the report in and saves it.
thisUrl &= “http://reports/Reportserver?%2FImport_In_Progress%2FAIM+(Unitrin)+Approval+Letter&rs%3ACommand=Render&rs:Format=awdoc&treatmentID=24705&rc:Parameters=false
SaveFile(thisUrl, “c:\apps\report.doc”)
Protected Sub SaveFile(ByVal url As String, ByVal localpath As String)
Dim loRequest As HttpWebRequest
Dim loResponse As HttpWebResponse
Dim loResponseStream As Stream
Dim loFileStream As FileStream
Dim laBytes(256) As Byte
Dim liCount As Integer = 1

Try

loRequest = CType(WebRequest.Create(url), HttpWebRequest)
loRequest.Credentials = New NetworkCredential(“Chris.Brickhouse”, “brickhouse1”, “PROD”)
loRequest.Timeout = 1000 * 60 * 15 'timeout 15 minutes
loRequest.Method = “GET”
loResponse = CType(loRequest.GetResponse, System.Net.HttpWebResponse)
loResponseStream = loResponse.GetResponseStream

loFileStream = New FileStream(localpath, FileMode.Create, FileAccess.Write)
Do While liCount > 0
liCount = loResponseStream.Read(laBytes, 0, 256)
loFileStream.Write(laBytes, 0, liCount)
Loop
loFileStream.Flush()
loFileStream.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

I've never tried to call a web service from a VB6 application but here is a couple of useful links describing the Reporting Services web service:

http://msdn2.microsoft.com/en-us/library/aa274396(SQL.80).aspx

http://msdn2.microsoft.com/en-us/library/aa237438(SQL.80).aspx

In C# the method calling the service and returning the binary result might look like the following:

private byte[] RenderReport(string reportName, ParameterValue[] parameters)
{
string extension;
string mimeType;
string encoding;
Warning[] warnings;
string[] streamIds;

string fullReportName = GetRemoteReportName(reportName);

ExecutionHeader header = new ExecutionHeader();
ExecutionInfo info = gExecutionService.LoadReport(fullReportName, null);
header.ExecutionID = info.ExecutionID;

if (parameters != null)
gExecutionService.SetExecutionParameters(parameters, null);

gExecutionService.ExecutionHeaderValue = header;

byte[] reportBytes = gExecutionService.Render(
"AWRTF",
GetDeviceInfoString(),
out extension,
out mimeType,
out encoding,
out warnings,
out streamIds);

return reportBytes;
}

Hope this helps.