3

How is it possible for reporting services to return report data (there are already some complete reports in my report server) that my ASP.Net web application can recevie, format and display using asp.net html and CSS?

Is it possible for RS to retrun the reports as json, xml etc that i easly can use in my code-behind to show them? I want to for instance make the headtitles blue and values dark blue and put a backgroud image for the my reprort and put some icons for some values in the report programmaticlly , etc.

I dont want to use the reportviewer control. My reports do not use any input paramaters.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
  • 1
    If you don't want a report then you shouldn't use a report. Just use a database query. – lc. Oct 05 '12 at 07:51
  • @lc they may want to use the existing reports queries and/or the online report designer as a easy to use query generator – TFD Oct 05 '12 at 20:51

1 Answers1

3

There is a way i have tried it ones.

First you need to output the report in XML format by default. http://msdn.microsoft.com/en-us/library/ms154040.aspx http://msdn.microsoft.com/en-us/library/ms152835.aspx

Next you need to applying Transformations to XML Output using XSLT http://msdn.microsoft.com/en-us/library/aa178953(v=sql.80).aspx

I think it is the only way to take a report and transform it styles to look more as HTML

Another sollution Based on TFD suggestion i have created a simple console application which read a csv file generated by reporting services and print the results.

I have used LinqToExcel so it will be quicker to read the data, but you don't have to use it

the code:

System.Net.WebClient client = new WebClient();
        client.Credentials = new NetworkCredential("username", "password");
        client.DownloadFile("reporingservisesURL/ReportServer?
        rs:Command=Render&rs:Format=CSV", "file.csv");
        FileInfo file = new FileInfo("file.csv");

        var excel = new ExcelQueryFactory(file.FullName);
        var worksheetNames = excel.GetWorksheetNames();
        var results = from c in excel.Worksheet("UsersTry")
                      select c;

        foreach (var item in results)
        {
            Console.WriteLine(String.Format("UserID: {0} , UserName:{1} ,
            LoginName: {2}",item[0].Value,item[1].Value,item[2].Value));
        }

        Console.WriteLine("The End :)");
        Console.ReadLine();

I hope it help you

Community
  • 1
  • 1
Silagy
  • 3,053
  • 2
  • 27
  • 39
  • 1
    CSV is available too, that may be easier given the data will most likely be de-normalised since it was a report – TFD Oct 05 '12 at 20:51
  • I think you right, but you should take in consideration that the name of your columns will changed in every report – Silagy Oct 05 '12 at 20:57
  • Thanks for all answers. CSV format does not include the column names which i need as well. Nor does xml format. But i see that there is another wcf method rs.getREportDefinition() that returns xml which includes the column names. So if i choose XML so i have to make 2 WCF calls (for every reports); one for the values and one for the column names in order to render a ful table in html for instanse. Correct me if i am wrong, – user1705714 Oct 08 '12 at 08:26
  • i am able to get the xml data with first wcf call and xml with field names with another wcf call in order to render a full html table with field names and values from the report in reportserver. So yes it works. – user1705714 Oct 08 '12 at 08:57