How to combine multiple csv files into an existing excel sheet

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive programmed a vb.net application. This is a matching applcation generates 3 lisboxes. I have written these to a csv files.
<div style="color:black; background-color:white
<pre><span style="color:blue Private <span style="color:blue Sub Button3_MouseClick(<span style="color:blue ByVal sender <span style="color:blue As System.Object, <span style="color:blue ByVal e <span style="color:blue As System.Windows.Forms.MouseEventArgs) <span style="color:blue Handles Button3.MouseClick, Button4.MouseClick, Button5.MouseClick
ListBox3.Items.Add(TimeString) <span style="color:green (ElapsedTime.Milliseconds).ToString)
<span style="color:blue If sender <span style="color:blue Is Button3 <span style="color:blue Then ListBox2.Items.Add(<span style="color:#a31515 "1")
<span style="color:blue If sender <span style="color:blue Is Button4 <span style="color:blue Then ListBox2.Items.Add(<span style="color:#a31515 "2")
<span style="color:blue If sender <span style="color:blue Is Button5 <span style="color:blue Then ListBox2.Items.Add(<span style="color:#a31515 "3")
chooseImg()
<span style="color:blue End <span style="color:blue Sub


<span style="color:blue Private <span style="color:blue Sub SaveButton_Click(<span style="color:blue ByVal sender <span style="color:blue As System.Object, <span style="color:blue ByVal e <span style="color:blue As System.EventArgs) <span style="color:blue Handles SaveButton.Click
<span style="color:blue Using sw <span style="color:blue As StreamWriter = <span style="color:blue New StreamWriter(<span style="color:#a31515 "C:Documents and SettingsDesktopPooPoofile.csv")
<span style="color:blue For i <span style="color:blue As <span style="color:blue Integer = 0 <span style="color:blue To ListBox1.Items.<span style="color:blue Count - 1
sw.WriteLine(ListBox1.Items(i) & <span style="color:#a31515 "," & ListBox2.Items(i) & <span style="color:#a31515 "," & ListBox3.Items(i))
<span style="color:blue Next
sw.Close()
<span style="color:blue End <span style="color:blue Using
SaveButton.Enabled = <span style="color:blue False
<span style="color:blue End <span style="color:blue Sub
[/code]

This produces my csv files and I have the contents of each listbox nicely written to individual columns...no commas yeahyyy!!!
My application stores login information to excel. How do I pull in all the csv files into the existing excel file? I dont have any column names in the csv file just three lists of numbers. Is it better to send each file into separate worksheets and perhaps
call the the worksheet the same name as the csv file? Or is there a way of combining all the data into one excel sheet ...perjaps pull the csv file into the same sheet?
<br/>
<br/>

View the full article
 
Back
Top