Hi,

I need to write a program to send data from a particular excel sheet in a workbook to a notepad. Say,I've an xl sheet with the following columns: "Name,Age,Salary" with values "john,24,1000" respectievely,Now I need a C# program to read the xl sheet and write the values onto the Notepad (in Tab separated format) as follows: John 24 1000.
I need to write all the columns in the xl sheet into the notepad as follows.

Before I ask any help,let me make it clear that I'm a beginner to this stuff,and while I have done some programs dealing with the likes of 'fibonnacci' & 'prime numbers',they were all part of the curriculum and I've learnt all of em by Rote methodology..... Please help me regarding the above program.I have tried to do it myself and here's what I have till now...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel;
using System.io;


namespace datt
{
    class Program
    {
        static void Main(string[] args)
        {
            DataSet ds = new DataSet;
            DataTable dt = new DataTable "table1";
            DataColumn dc_col1 = new DataColumn("trigger term")
            DataColumn dc_col2 = new DataColumn("news1")
            DataColumn dc_col3 = new DataColumn("news1url")
            DataColumn dc_col4 = new DataColumn("news2")
            DataColumn dc_col5 = new DataColumn("news2url")
            dt.Columns.add(dc_col1);
            dt.Columns.add(dc_col2);
            dt.Columns.add(dc_col3);
            dt.Columns.add(dc_col4);
            dt.Columns.add(dc_col5);
            while
            {
                dr.read()
                dr.next();

                DataRow newrow = dt.newrow;
                dt.rows.add(newrow);
            } 
            ds.tables.add(dt);

                FileStream f1 = new FileStream("C:\Harsha\Work\List_Answer_Production\AU_States_V1.xls",FileMode.Create);
                ds.WriteXml(f1);
                f1.close();
                byte b[] = File.ReadAllBytes("C:\Harsha\Work\List_Answer_Production\AU_States_V1.xls");
                FileStream f1 = new FileStream("C:\Harsha\Work\List_Answer_Production\test1.txt",FileMode.Create);
                f2.WriteAllBytes(b);
                f2.close();

                    

            
        }
    }
}

I know the above code doesn't do the trick....So I didn't even bother executing it..... Any help is appreciated.Thank you all.Please do note I'm a Beginner and If u point out a few examples of the sort of program I requested,It'd be mighty helpful.Thank you...Please Help!!~

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.