excel sheet

Hi,
I am using vb.net desktop version, need to convert a excel sheet to csv.
Need to calculate the used range of excel and convert it into comma seperated csv.

***Please note speed is an issue here, if you suggest any code with high performance it will be appreciated the most.
Thanks
RIASAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical Specialist IVCommented:
If speed is an issue, you only have one option IMO

I have done various document automation processes and GemBox Spreadsheet is the fastest library I have found.
https://www.gemboxsoftware.com/spreadsheet
0
MishaProgrammerCommented:
GemBox  is good library,
But in some cases GemBox  can be not free. Also you can use NPOI. It is free low-level api to work with excel.
0
RIASAuthor Commented:
Thanks,Any vb.net code please , appreciate it
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

RIASAuthor Commented:
Cannot use any third party
0
MishaProgrammerCommented:
You can read EXcel with Ado net, put data to string with symbol ";" and wtite this data to file. Try this code:
Imports System.Data.Odbc
Imports System.IO
Module Module1
    Sub Main()
        Try
            Dim ConnectionString As String = "Driver={Microsoft Excel Driver (*.xls)};DBQ=D:\Test.xls"
            Dim file As StreamWriter
            file = My.Computer.FileSystem.OpenTextFileWriter("D:\Test.csv", True)
            Dim conn As New OdbcConnection(ConnectionString)
            Dim sql As String = "Select * FROM [Sheet1$]"
            conn.Open()
            Dim da As New OdbcDataAdapter(sql, conn)
            Dim ds As New DataSet()
            da.Fill(ds, "Sheet1")
            conn.Close()
            Dim Result As String = ""
            For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
                For j As Integer = 0 To ds.Tables(0).Columns.Count - 1
                    Result += ds.Tables(0).Rows(i).Item(j) + ";"
                Next
                file.WriteLine(Result.Substring(0, Result.Length - 1))
                Result = ""
            Next
            file.Close()

Open in new window


P.S.
In vain you refuse good libraries. Many actions are already made for you in this lybraries.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Thanks!
0
MishaProgrammerCommented:
Glad to help you!
0
Shaun VermaakTechnical Specialist IVCommented:
In vain you refuse good libraries. Many actions are already made for you in this lybraries.
Not only do libraries make it easier, GemBox does not use Office so you do not need licenses and it is 20 times faster than Office automation
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.