Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Creating HTML reports

Tags:

html

c#

reporting

I have in my winform application 4 datasets that gets values from my database. Values like like how many products I have in my product table and information about categories. I was wondering how I can save the dataset informaiton in a html page. I want to create a html template so that I can present the information in nice way. How can I do that? Eny good guide that explains how to do that?

like image 927
Man1 Avatar asked Apr 03 '11 20:04

Man1


2 Answers

This seems like a great job for something like RazorEngine. You can define a template using Razor syntax, and then render out the content using the RazorEngine template service, e.g.:

@helper RenderItem(Item item) {
  <tr>
    <td>item.Name</td>
    <td>item.Price</td>
  </tr>
}

<html>
  <head></head>
  <body>
    <table>
      @foreach (Item item in Model.Items) {
        @RenderItem(item)
      }
    </table>
  </body>
</html>
like image 102
Matthew Abbott Avatar answered Sep 30 '22 00:09

Matthew Abbott


You can save DataSet as XML and then transform it by using XSLT.

You can take a look at this samples:

  • XSLT - Transformation
  • Creating and Populating an HTML Template
  • Using XSLT and .NET to Manipulate XML Files
like image 33
HABJAN Avatar answered Sep 30 '22 01:09

HABJAN