Is there a way to extract the culture of an excel using OleDbDataAdapter on VB.Net?

80 Views Asked by At

What I've been trying to do is get either a string or a type of information about the cells of the excel and regarding their format dates.

For example if there are different formats in a cell I would like to be able to find the format so I can get the corrent date. 10/11/2000 can be different depending on whether the month is first or not. Since it would be the same for each row getting the culture of the whole sheet can be a solution too.

Unfortunately I don't seem to find anything that responds to that.

What i've tried so far is this

Dim ds As New DataSet()
Dim cn As OleDbConnection

Dim fileHasHeader As String = "NO"
Dim connectionString As String = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR={1};IMEX=1""", _filePath, fileHasHeader)

        cn = New System.Data.OleDb.OleDbConnection(connectionString)

                If _file Is Nothing Then
                    Try
                        Me.ExportXLSFile()
                        cn.Open()
                        Dim tablename = cn.GetSchema("Tables").Rows(0)("TABLE_NAME")
                        Dim genious = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, {})
                        Dim geinous2 = genious.Locale.DateTimeFormat.LongDatePattern

The thinking was that maybe by taking the LongDatePattern there would be some differences if the locale was different but the LongDatePattern seems to fetch the same result ( "dddd, dd MMMM yyyy" ).

0

There are 0 best solutions below