0

Hi,

I'm new to C#. Can any one help with extracting info from a few .csv files and insert them into DIFFERENT sheet in excel(not necessary .xls format. .csv is fine). I'm not asking for the whole piece of coding. Just need some idea on where to start. :-/

Thanks!

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by raul15791
0

Hi,

I have my own dataset of data. Just wonder what function can I use to write into a excel file. For my current coding, I'm writing the data into several .csv files. Now I'm trying to write all these data into separate sheets in excel (.xls). Here my old piece of coding (store data in csv format):

StreamWriter writer = File.CreateText(strDirectory + FileName); 
            writer.WriteLine();
            writer.WriteLine("Sheet Name");
            writer.WriteLine();
            writer.WriteLine("Column 1,Column 2, Column 3, Column 4");
       
            foreach (DataRow dr in dtable.Rows)
            {   writer.Write(dr[0]);
                writer.Write(",");
                writer.Write(dr[1]);
                writer.Write(",");
                writer.Write(dr[2]);
                writer.Write(",");
                writer.Write(dr[3]);
                writer.WriteLine();
            }
0

Well csv format (which you're writing out, and theres a quicker way to do that, look at the join function) cannot do multiple excel sheets, the only thing that does multiple sheets is excel. For which you would need to use the excel object.

Take a look, theres been some posts in here about working with excel direct.

0

Yeah... I decide to save everything into a single excel file directly.

Thanks anyway...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.