CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    78

    Creating a document using C#

    Hi,

    I am working on a program that tests a unit and in the end creates a "report" about the tests which passed or failed.

    Till now I was using a simple .txt file which functioned perfect, but since I might have to integrate pictures, graphs in next release which is not possible in a .txt file, therefore I wish to generate Report in some other document. The requirement says that every user should be able to open report using a standard SW (for e.g. MS word or a browser).

    Unfortunately I have not found many tutorials that provide a sufficient hint to write to a word or to a html file using C# and also I would like to ask which one of the above options is good or there is some other way of writing such a report.


    My requirements are:
    Write text to report in bold, Italics, different colors.
    Insert images in the report.
    Draw tables in the report.

    Regards
    Ricky

  2. #2
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Re: Creating a document using C#

    Hi,

    These examples are in VB, but it shouldn't be difficult to adapt the code to C#. I've always found it easier to create template files to work with rather than creating a new report file each time.

    http://www.vb-helper.com/index_office.html#word


    Hope this helps

    Curt

  3. #3
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Re: Creating a document using C#

    Hi Ricky, I'm don't know a lot about html, but you could create your own .html file from scratch using C#, and then write to it to add whatever you need. The C# side is as easy as creating a file and writing to it. Check FileStream on MSDN for example. What you write you can learn about in the infinite html tutorials the web has to offer, but it will be just text, as it would be with a .txt file.

    I used to have a template file with all the headers and footers and a few C# functions to add fields like paragraphs, pages, buttons, fonts, etc. You know what the report will be like, so you know what data you will be expecting and how to format it. Just add the fields starting and ending tags; for example <p> </p> and write text inside it.
    Perhaps there is a specific html class in C# to do that even easier? I'm sure there must be a more 'professional' way of doing this.

    As far as format goes, I'd go with browser based languages, as it will be easier to read on any computer.

  4. #4
    Join Date
    Aug 2008
    Posts
    78

    Re: Creating a document using C#

    Thanks Curt and Nickel.
    I opted for creating the report in MS Word. It involves intensive work but is ultimately easier to intend and demands a lot of creation too.

  5. #5
    Join Date
    Aug 2008
    Posts
    78

    Resolved Re: Creating a document using C#

    Marked "Solved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured