views:

907

answers:

2

Hello All,

We have recently upgraded our CRM system from 3.0 to 4.0. Since then we are

having troubles with our reports.

Whenever we export the report to excel format, the file which is created in

CRM 4.0 has name as some "GUID".xls. Not just the name of the file, the sheet

contianing the output also has GUID as the name. This applies to other

formats also (output file name contains GUID).

I can save the rename the file as something else. But we have subscriptions

over most of our reports which sends out excel output of the report to a set

of ppl.

Instead of uploading the RDL from CRM 4.0, if i can upload the report to

some other SSRS folder and give a link, it will work. But we dont want to do

it.

Can anyone help me with this?

Thanks

A: 

Not sure, but it's possible to try create custom render extention for Excel. Change the Render method from article as it was proposed by this comment with the only difference - use excel format:

public bool Render(Report report, 
  NameValueCollection reportServerParameters, 
  NameValueCollection deviceInfo, NameValueCollection clientCapabilities, 
  EvaluateHeaderFooterExpressions evaluateHeaderFooterExpressions, 
  CreateAndRegisterStream createAndRegisterStream)
{
    string strUri = string.Empty;
    strUri += 
      "http://localhost/Reports/Reserved.ReportViewerWebControl.axd";
    strUri += "?ReportSession=" + reportServerParameters["SessionID"];
    // Here you can check the name of report provided to viewer for export. 
    // If it's incorrect, you may extend method to set the right name.
    strUri += "&FileName=" + report.Name;  
    strUri += "&ControlId=" + Guid.Empty;
    strUri += "&Culture=" + 
      CultureInfo.CurrentCulture.LCID.ToString(
        CultureInfo.InvariantCulture);
    strUri += "&UICulture=" + 
      CultureInfo.CurrentUICulture.LCID.ToString(
        CultureInfo.InvariantCulture);
    strUri += "&ReportStack=1";
    strUri += "&OpType=Export";
    strUri += "&ContentDisposition=OnlyHtmlInline";
    strUri += "&Format=MHTML";
    Stream outputStream = null;
    StreamWriter streamWriter = null;
    try
    {
        //Output to Excel
        outputStream = createAndRegisterStream(report.Name, "xls",
          System.Text.Encoding.UTF8,
        "application/vnd.ms-excel", true, StreamOper.CreateAndRegister);
        streamWriter = new StreamWriter(outputStream);
        //Input
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUri);
        //Credentials
        request.Credentials = System.Net.CredentialCache.DefaultCredentials;
        //Output
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        //Input
        Stream inputStream = response.GetResponseStream();
        StreamReader streamReader = 
          new StreamReader(response.GetResponseStream());
        //Read/Write
        streamWriter.Write(streamReader.ReadToEnd());
    }
    finally
    {
        if (streamWriter != null)
        {
            streamWriter.Flush();
        }
    }
    return false;
}

You may add this renderer as a new custom extention (you will have to change subscription format then) or replace existing excel extention - see Specifying Rendering Extension Parameters in Configuration Files

Max Gontar
A: 

Hi Coldice, thanks very much. The info was useful, I'm trying to implement the same. I have been able to create the custom renderer, but it is giving an error while exporting (HTTP:500 Internal error on Getresponse line). I will try to debug it.

Thanks anyway for your quick reply.