Monday, February 20, 2012

Rendering true Excel

My users are complaining that the Excel files they are getting back from
the web application's rendering of reports in Excel mode are not true
Excel, but rather still retain HTML. Has anyone else experienced this?
I have included my rendering code snippet below:
--
try
{
data = render.RunReport(ConfigurationSettings.AppSettings[ePledgeConstants.REPORT_SERVER_URL_PROPERTY],
fullReportName, reportParameters, format, out
encoding,
out mimeType, out parametersUsed, out warnings,
out streamIds);
Response.Clear();
Response.ContentType = mimeType;
string fileName = report.Name +
GetFileExtension(mimeType);
if (mimeType != "text/html")
{
Response.AddHeader("Content-Disposition",
"attachment; filename=" + fileName);
}
switch(encoding)
{
case "Unicode (UTF-8)":
Response.ContentEncoding = new UTF8Encoding();
break;
case "Unicode (UTF-7)":
Response.ContentEncoding = new UTF7Encoding();
break;
default:
Response.ContentEncoding = new UTF8Encoding();
break;
}
Response.BinaryWrite(data);
}
catch (Exception exception)
{
Console.Out.Write(exception.ToString());
}
---
The run report method in turn is like this:
---
public byte[] RunReport(string ServerUrl, string ReportName,
ParameterValue[] parameters, string Format, out string encoding, out
string mimeType, out ParameterValue[] parametersUsed, out Warning[]
warnings, out string[] streamIds)
{
ReportingService rs = new ReportingService();
rs.Timeout = -1;
rs.Url = ServerUrl;
rs.Credentials = new NetworkCredential(UserName, Password);
return rs.Render(ReportName, Format, null, null, parameters, null,
null, out encoding, out mimeType, out parametersUsed, out warnings,
out streamIds);
}Have you deployed Reporting Services SP1. In SP1, we output native XLS.
-Lukasz
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bryon" <blape@.whittmanhart.com> wrote in message
news:OVl$MrGGFHA.2932@.TK2MSFTNGP15.phx.gbl...
> My users are complaining that the Excel files they are getting back from
> the web application's rendering of reports in Excel mode are not true
> Excel, but rather still retain HTML. Has anyone else experienced this? I
> have included my rendering code snippet below:
> --
> try
> {
> data => render.RunReport(ConfigurationSettings.AppSettings[ePledgeConstants.REPORT_SERVER_URL_PROPERTY],
> fullReportName, reportParameters, format, out
> encoding,
> out mimeType, out parametersUsed, out warnings, out
> streamIds);
> Response.Clear();
> Response.ContentType = mimeType;
> string fileName = report.Name +
> GetFileExtension(mimeType);
> if (mimeType != "text/html")
> {
> Response.AddHeader("Content-Disposition",
> "attachment; filename=" + fileName);
> }
> switch(encoding)
> {
> case "Unicode (UTF-8)":
> Response.ContentEncoding = new UTF8Encoding();
> break;
> case "Unicode (UTF-7)":
> Response.ContentEncoding = new UTF7Encoding();
> break;
> default:
> Response.ContentEncoding = new UTF8Encoding();
> break;
> }
> Response.BinaryWrite(data);
> }
> catch (Exception exception)
> {
> Console.Out.Write(exception.ToString());
> }
> ---
> The run report method in turn is like this:
> ---
> public byte[] RunReport(string ServerUrl, string ReportName,
> ParameterValue[] parameters, string Format, out string encoding, out
> string mimeType, out ParameterValue[] parametersUsed, out Warning[]
> warnings, out string[] streamIds)
> {
> ReportingService rs = new ReportingService();
> rs.Timeout = -1;
> rs.Url = ServerUrl;
> rs.Credentials = new NetworkCredential(UserName, Password);
> return rs.Render(ReportName, Format, null, null, parameters, null,
> null, out encoding, out mimeType, out parametersUsed, out warnings, out
> streamIds);
> }|||Lukasz Pawlowski [MSFT] wrote:
> Have you deployed Reporting Services SP1. In SP1, we output native XLS.
> -Lukasz
>
Yes I have.
An interesting side note to this problem is that on a Mac, it only sees
the HTML, never the Excel information. In Windows, the file looks like
Excel, but does not save as Excel.
Also, is there a way to display gridlines? The Excel comes back as
Excel for the web and does not have gridlines by default.|||Grid lines are based on how you designed your report. If you created for
example a table with inner boarders, you should see grid lines.
Are you supplying any device info parameters to your excel rendering?
-Lukasz
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bryon" <blape@.whittmanhart.com> wrote in message
news:%23ynRKTHGFHA.128@.TK2MSFTNGP14.phx.gbl...
> Lukasz Pawlowski [MSFT] wrote:
>> Have you deployed Reporting Services SP1. In SP1, we output native XLS.
>> -Lukasz
>>
> Yes I have.
> An interesting side note to this problem is that on a Mac, it only sees
> the HTML, never the Excel information. In Windows, the file looks like
> Excel, but does not save as Excel.
> Also, is there a way to display gridlines? The Excel comes back as Excel
> for the web and does not have gridlines by default.|||Lukasz Pawlowski [MSFT] wrote:
> Grid lines are based on how you designed your report. If you created for
> example a table with inner boarders, you should see grid lines.
> Are you supplying any device info parameters to your excel rendering?
> -Lukasz
>
I'm not sure what you mean by device parameters.

No comments:

Post a Comment