CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    11

    C# DataSet to RichText File

    Hi

    I'm a beginner and if I'm asking strange things sorry about it.

    I read some informations from sql database and display it in my project.

    I used sqldataadapter dataset and datagridview.

    In my project, in datagridview, I see a table with several columns and rows. And table is full with values.

    Until here everything is ok.

    Now my problem is I want to move this table to a richtext and save informations. I mean, I want to creat richtext file. There will be a table in richtextfile.

    Is it possible to move all table with one code or with one way?

    I searched some informations about this stuff.

    One way is reading datagrid and creating csv file in excel. It's not good because users don't have excel.
    Another way is, reading all informations one by one and converting them to string and make table in text file. This is very long way.

    Read colum1row1 and colum1row2 ......................... too much. Also it's not very easy to make tables in txt file.

    So I think you understand what I meant.

    Can you show me a way to do that ?
    Is there a similar project?

    Thank you for comments

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# DataSet to RichText File

    Quote Originally Posted by pokajy View Post
    One way is reading datagrid and creating csv file in excel. It's not good because users don't have excel.
    Excel reader is free and csv sounds like the best way to store this data. Many applications know how to read and format csv files, not so with rtf.

    Another way is, reading all informations one by one and converting them to string and make table in text file. This is very long way.

    Read colum1row1 and colum1row2 ......................... too much. Also it's not very easy to make tables in txt file.
    Not sure what you mean. That is trivial using a nested loop:

    Code:
    foreach( string row in Rows )
    {
        foreach( string column in row.Columns )
        {
            // print to text file
        }
    }
    So I think you understand what I meant.
    Not really. RTF sounds like an awful way to store table organized data.

  3. #3
    Join Date
    Oct 2010
    Posts
    11

    Re: C# DataSet to RichText File

    I find excel very cumbersome.
    Same table in Txt or rtf 10kb, in excel maybe 100kb.
    If it was creating 2-3 files. it's ok. 90kb is nothing, but It'll be kinda reporting and it'll report many times in a day.
    I have to install excel to every user who wants to open this files.

    I'm not trying to show RTF is good. I'm just trying to explain why I thought about RTF.

    Txt does not support tables, I thought it might be possible to send this infos to RTF as table.
    If u're saying it's very bad idea. ok then

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# DataSet to RichText File

    Quote Originally Posted by pokajy View Post
    I find excel very cumbersome.
    Same table in Txt or rtf 10kb, in excel maybe 100kb.
    I can't imagine how that could possibly be true. A csv file *is* a text file, so it would be smaller than the RTF version. However, you have your reasons, and if you say csv doesn't work for you that's your call.

    Have you looked into any of the free/open source reporting tools out there for C#?

  5. #5
    Join Date
    Oct 2010
    Posts
    11

    Re: C# DataSet to RichText File

    yes I saw several reporting examples. Generally people are using csv. It's only me who is abnormal.

    Well at the beginning I said that I was a beginner. So don't be angry with strange questions.

    Thanks for your help. I'll try creating csv.

  6. #6
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# DataSet to RichText File

    I guess my suggestion would be; go with csv

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: C# DataSet to RichText File

    XML is also TEXT
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# DataSet to RichText File

    Yup

    The advantage of csv (or tsv, or whatever-sv) is that many, many programs know how to display them nicely and the lend themselves to tabular data.

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