Error in exporting ssrs 2008 report to excel - reporting-services

I have a report returning around 90000 rows. But when i export it to excel from the asp.net page it gives this error:
An error occurred during rendering of the report
But the same report is getting successfully exported to excel from the report server.
If i pass some more parameters from the web page to reduce the number of records to 100, then i am able to export it to excel from the web page itself.
Edit-1
Stack Trace:
[Exception: For more information about this error navigate to the report server on the local server machine, or enable remote errors]
[Exception: An error occurred during rendering of the report.]
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +574
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +905
Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +28
Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, String& mimeType, String& fileNameExtension) +88
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +123
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +153
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +585
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +901
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +76

I can suggest you some workaround: in the report you can place a link to Force SSRS Report to create a file rather than render on screen.
the link should contain the following:
http://localhost/ReportServer/Pages/ReportViewer.aspx?
%2fSample+Report&rs:Format=excel

SSRS 2008 can only export to XLS (MS Office 2003). XLS files are limited to 65k rows.
Have you looked at the row count of the export from the Report Manager? Unless you are using a custom or third-party tool to allow export to XLSX, the file should only have ~65k rows.
I think the Report Manager works around the exceeded row length by performing what is essentially something like SELECT TOP 65k from the report. Your asp.net interface probably does not account for this limitation, and is forcing too many rows into the Excel export.
Your options are:
1.) Use SSRS 2012 which allows export to XLSX. XLSX files can handle many more rows.
2.) Change your asp.net code to slice off the top 65k rows before export to XLS.
3.) Consider a third-party or custom solution to work around the SSRS 2008 export limitations (I know of Aspose.)
4.) Export to CSV, then have the end user convert the CSV into Excel.

As dev_etter mentioned, SSRS 2008 doesn't support such large Excel reports out of the box but it can be done with 3rd party tools like SoftArtisans OfficeWriter which allows you to design and export reports in the OOXML (.xlsx/.xlsm) format.
Disclaimer: I work for SoftArtisans

Maybe there is timeout error in ReportViewer control?
Try to play with:
ViewerControl.ServerReport.Timeout
http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.serverreport.timeout(v=vs.80).aspx
Because report server also use ReportViewer control and maybe with different configaration with yours. The default value for timeout is 600000 milliseconds.
BTW: It would be great to see your StackTrace. This will help to give you better answer.

Ram on the server may be an issue. There are a lot of issues here with high volume reports not coming through and ram seems to fix them, from the responses at least.

if the problem is exceeding the 65k limit of excel, you can add a parent group to your tablix and add the following code for the group expression
=CEILING(RowNumber(Nothing)/65500)
Then add a page break between each instance of the group...
this will create multiple tabs in the excel file for the tablix that is > 65500 rows...

My fix turned out to be removing the seal(image) on our report. I'm not sure if this is limited to png's or not but after it was removed the reports exported to excel without issue.

I had this problem when exporting an Oracle SSRS report with an hierarchical connect by type query, in SSRS 2014. The report was displaying, but faster than I expected. I was wondering if it was timing out in the background, but still displaying some of the rows. I changed the report to never timeout and that fixed it. Took longer to run after that, but it would export to excel after it finished.

Related

SSRS report external image source

I am trying to create a solution to show dynamic images in SSRS reports. I have .NET process that generates Base64 strings that after decoding returned to the client. Here is C# code:
byte[] imageBytes = Convert.FromBase64String(image);
MemoryStream exportStream = new MemoryStream(imageBytes, 0, imageBytes.Length);
exportStream.Position = 0;
return Ok(exportStream);
where image is the Base64 string.
It works fine when a client is a Browser. But in the report it shows Red X when I am running it in the report builder. Published report shows nothing at all. Seems like the report doesn't fully understand the return format or something else. Please share any idea.
Thanks
Image properties:

SSRS -External image not rendering on HTML report

I am working on SSRS Report. I have a report with an external image embedded in it
This renders fine inside the report viewer.
but when I render report in HTML 4.0 format in my application via web url (without using report viewer).The report that comes back from all the data except the image is not in the html
see the image tag looks like the following:-
<img onerror="this.errored=true;" class="r1" src="http://ges-server-pc/ReportServer_SQLEXPRESS?%2FGES-MVC%2FGES_FWCR&rs%3ASessionID=vdpuofii3xtph545xelnym45&rs%3AFormat=HTML4.0&rs%3AImageID=1403af250c474da8a5f851b63a8a377b">
how can I render extrenal image on Report which is in format= HTML 4.0
Can Anybody have solution for the same It will be appreciable
Thanks in advance
Here is one way to ensure that your application can reliably display images dynamic rendered in a report by SSRS.
When you are using the report viewer control, a lot is done behind the scenes to keep an active session and allow access to all artifacts generated by reports requested by the user. When you are using the ReportExecution api directly there are some advanced reporting features that are just not supported. Interactive sorting, sizing, drilldown and this issue just to name a few.
Always ensuring dynamic images from reports are available to your client is pretty easy. I had to cross this hurdle a way back and I'll share the way I solved it.
In a nutshell, you are going to have to intercept the render, iterate the streams, and save each resource to a temp folder and tell ssrs to look for the image in your temp folder that is behind the web app that your end user has authenticated with.
DeviceInfo
The device info structure, mostly overlooked, is going to come in handy. In this structure you will find a StreamRoot property. You can find documents on this. It basically allows you to override the location from which SSRS will stream resources as needed. This is how you tell SSRS to look for your external images in a new location.
For each report rendered I create a temp folder using a guid prior to rendering. Also, prior to rendering you need to set the StreamRoot to this temp folder.
string physicalTempFolder = MakeNewTempFolderInTempOffOfWebRoot();
string virtualTempFolder = Path.Combine(yourWebRoot,"Temp",Path.GetDirectoryName(physicalTempFolder));
Now you have a physical and virtual pointer to your repo where the images will be saved for your report. Now update the StreamRoot in SSRS. This tells SSRS that we want to override the default location for dynamic images and whatnot.
StringBuilder devInfo = new StringBuilder();
if (YourRenderFormat=="HTML")
{
devInfo.Append("<DeviceInfo>");
devInfo.Append("<StreamRoot>" + virtualTempFolder+ "</StreamRoot>");
devInfo.Append("</DeviceInfo>");
}
With the needed device info structure build we can pass it into the render method.
string extension;
string mimeType;
string reportEncoding;
string[] streamIDs = null;
ReportExecution2005.Warning[] warnings = null;
ReportExecution2005.ExecutionHeader execHeader = new ReportExecution2005.ExecutionHeader();
ReportExecution2005.ExecutionInfo rpt = _execService.LoadReport(YourReportPath, null);
if(YourParamas!=null)
_execService.SetExecutionParameters(YourParams, "en-us");
_execService.ExecutionHeaderValue = execHeader;
_execService.ExecutionHeaderValue.ExecutionID = rpt.ExecutionID;
result = _execService.Render(format, devInfo.ToString(), out extension, out mimeType, out reportEncoding, out warnings, out streamIDs);
The render method returns the streamIDs out parameter and it is key here. Next after we call render, simply iterate all the streams that are images and call ssrs's RenderStream() method to get the images and save to your physical temp folder.
if (YourRenderFormat=="HTML"))
{
string imageEncoding = "";
// For each image stream returned by the call to render,
// render the stream and save it to the application root
string FilePath = physicalTempFolder;
byte[] image;
// For each image stream returned by the call to render,
// render the stream and save it to the application root
foreach (string streamID in streamIDs)
{
image = _execService.RenderStream("HTML4.0", streamID, null, out imageEncoding, out mimeType);
//All files are unique
File.WriteAllBytes(Path.Combine(physicalTempFolder,streamID),image);
}
}
return result;

SSRS 2016 can't set credentials when using an expression based connection string

I am trying to deploy a SSRS report to a 2016 server which uses a an API as it's data source. The URL for the API is generated dynamically via an expression which builds the query string based on a couple of report parameters.
In the past, using report manager I could set which account the API is called under.
Note that in the above screenshot the Connection string is still expression based.
However if I attempt the same thing in 2016 the connection string is wiped out.
Surely the connection string and the credentials should be independent, why has this changed in 2016 or is it a bug?
I had a similar issue in ReportServer 2017; however if you click the button 'Revert to Default' (visible in the above screenshot) the Expression based connection string will magically reappear!
Nice feature - if you find it ;-)

Report rsExecutionNotFound when exporting to other formats

I am using CRM 4.0 SSRS. I can display reports which take a long time. When a report displays I can export to Excel, XML or another file type within in 10 minutes. But after exactly 10 minutes, I cannot export reports to Excel or other formats.
Report message is :
The report execution ifjzab55k5icxl4510oyfsmt has expired or cannot be found. (rsExecutionNotFound)
Report Server Log Text:
ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerStorageException: , An error occurred within the report server database. This may be due to a connection failure, timeout or low disk condition within the database.;
session!ReportServer_0-10!17c8!05/09/2013-16:03:14:: e ERROR: Error in getting session data: Expired Session: qkmiqv455sdu5wyc2sa23az1
session!ReportServer_0-10!17c8!05/09/2013-16:03:14:: i INFO: LoadSnapshot: Item with session: qkmiqv455sdu5wyc2sa23az1, reportPath: , userName: VRVENDING\crm.service not found in the database
library!ReportServer_0-10!17c8!05/09/2013-16:03:14:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ExecutionNotFoundException: , Microsoft.ReportingServices.Diagnostics.Utilities.ExecutionNotFoundException: The report execution qkmiqv455sdu5wyc2sa23az1 has expired or cannot be found"
This is happening because the session that SSRS was using to store your reports data has expired, releasing the cached data; so when you attempt to export there's nothing there to export. Simply clicking "View Report" again should rebuild that cache, and allow you to export, however I can understand that not being the ideal user experience.
2 things I'd suggest trying:
Increase the session timeout for SSRS.
In the web.config, find the "httpRuntime" element, and add a "RequestLength" property to it, set that value to something absurdly high, like 100000, and see if that helps. (do this in both the reportserver and reportmanager web.configs)
Given the error message, I doubt that the 2nd one is your issue, but still may be worth checking out, as I've seen similar behavior that was fixed with that (albeit with a much different error message).
You could also try tinkering with the reports snapshot settings, however the amount of overhead that introduce on your server may outweigh the benefits of letting people export their report...

Why do I sometimes get an error in Reporting Services when I export a report containing .jpg images to MS Word

When you create a report using SQL Server Reporting Services 2008 (SP1), that uses .jpg images sometimes you get the following error when you export the report to word.
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Index was outside the bounds of the array.
Having discussed this with Microsoft support (a helpful chap called Mikael Ljunghorn) it would appear to be related to whether the .jpg image you are using in your report is encoded using 'progressive' encoding.
To prevent this from occuring, try to avoid using progressive encoded .jpg images in your report.
Mikael also suggested that the following workaround to convert a jpg image to a png sidestepping the conversion problem in word:
1)
Add this custom code block through the Report > Report Properties > Code window.
Function ConvertToPNG(ByVal bytes As Byte()) As Byte()
Dim inStream As New System.IO.MemoryStream(bytes)
Dim bmp As New System.Drawing.Bitmap(inStream)
Dim outStream As New System.IO.MemoryStream()
bmp.Save(outStream, System.Drawing.Imaging.ImageFormat.PNG)
Return outStream.GetBuffer()
End Function
2)
Wrap the database image Value expression in this call: =Code.ConvertToPNG(Fields!ImageBlobField.Value)