Click here to Skip to main content
13,191,877 members (30,599 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,

I'm trying to save a converted xls file in csv.

--> after convert process
Dim _Out() As String = csvData.Split("\n")
 
   Dim _OutPut As String = targetFile 'path and filename to save in local
   Dim _csv As StreamWriter = New StreamWriter(_OutPut, False)
   _csv.Write(csvData)
   _csv.Close(

)


Gives me this ressult below:
ABCReferenceNo,ChequeDate,ChequeNo,DocRate,HouseBankCode,BankAcct,Project,ProjectName,Customer_OR_VendorCode,Customer_OR_VendorName,DocumentCurrency,Balance,\nABCRef1,20120131,1234,1,ABC01 USD,4808507000-22,A01102,Lente-Serenity Tower,V-J1036,CORJUVIT TRADING & CONSTRUCTION,USD,#VALUE!\nABCRef2,20120131,1235,1,ABC01 USD,4808507000-22,A01102,Lente-Serenity Tower,V-U1001,USAUK INC.,USD,#VALUE!\nABCRef3,20120131,1236,1,ABC01 USD,4808507000-22,A03101,ASIA oOne Corall Way,V-S1058,STARGATE MANUFACTURING CORP.,USD,#VALUE!\nABCRef4,20120131,1237,1,ABC01 USD,4808507000-22,A03101,ASIA oOne Corall Way,V-N1010,"NUEVA JAPAN HUMAN RESOURCES BUILDERS GROUP,INC.",USD,#VALUE!\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n,,,,,,,,,,,,\n


The result that should be is like this below:
ABCReferenceNo,ChequeDate,ChequeNo,DocRate,HouseBankCode,BankAcct,Project,ProjectName,Customer_OR_VendorCode,Customer_OR_VendorName,DocumentCurrency,Balance
ABCRef1,20120131,1234,1,ABC01 USD,4808507000-22,A01102,Lente-Serenity Tower,V-J1036,CORJUVIT TRADING & CONSTRUCTION,USD,#VALUE!
ABCRef2,20120131,1235,1,ABC01 USD,4808507000-22,A01102,Lente-Serenity Tower,V-U1001,USAUK INC.,USD,#VALUE!
ABCRef3,20120131,1236,1,ABC01 USD,4808507000-22,A03101,ASIA oOne Corall Way,V-S1058,STARGATE MANUFACTURING CORP.,USD,#VALUE!
ABCRef4,20120131,1237,1,ABC01 USD,4808507000-22,A03101,ASIA oOne Corall Way,V-N1010,"NUEVA JAPAN HUMAN RESOURCES BUILDERS GROUP,INC.",USD,#VALUE!



I'm using VB2005. Please Help me
Posted 11-Dec-12 14:29pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

I've got the solution.

in the While process, after reading the whole line, i then save it per line using streamwriter writeline like this;

While row_no < rCount ''(_Result.Tables(0).Rows.Count - 1)
 
            For i As Integer = 0 To cCount
 
                csvData += _Result.Tables(0).Rows(row_no)(i).ToString() + ","
 

            Next
 
            Dim _OutPut As String = targetFile
 
            Dim swE As New System.IO.StreamWriter(_OutPut, True)
 
            swE.WriteLine(csvData)
 
            row_no = row_no + 1
 
            csvData = ""
 
            swE.Flush()
            swE.Close()
 
End While
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171017.2 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100