Import data from .csv and save in separate sheet in .xls

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 89
Reputation: raul15791 is an unknown quantity at this point 
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Import data from .csv and save in separate sheet in .xls

 
0
  #1
Sep 29th, 2008
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!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Import data from .csv and save in separate sheet in .xls

 
0
  #2
Sep 29th, 2008
What code do you have?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 89
Reputation: raul15791 is an unknown quantity at this point 
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Re: Import data from .csv and save in separate sheet in .xls

 
0
  #3
Sep 30th, 2008
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):

  1. StreamWriter writer = File.CreateText(strDirectory + FileName);
  2. writer.WriteLine();
  3. writer.WriteLine("Sheet Name");
  4. writer.WriteLine();
  5. writer.WriteLine("Column 1,Column 2, Column 3, Column 4");
  6.  
  7. foreach (DataRow dr in dtable.Rows)
  8. { writer.Write(dr[0]);
  9. writer.Write(",");
  10. writer.Write(dr[1]);
  11. writer.Write(",");
  12. writer.Write(dr[2]);
  13. writer.Write(",");
  14. writer.Write(dr[3]);
  15. writer.WriteLine();
  16. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Import data from .csv and save in separate sheet in .xls

 
0
  #4
Sep 30th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 89
Reputation: raul15791 is an unknown quantity at this point 
Solved Threads: 7
raul15791 raul15791 is offline Offline
Junior Poster in Training

Re: Import data from .csv and save in separate sheet in .xls

 
0
  #5
Oct 6th, 2008
Yeah... I decide to save everything into a single excel file directly.

Thanks anyway...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC