I've asked too much question in this day, hehe.
I'm trying to export my table data in OracleDB to excel. The problem is my charset in database is US7ACSII (using Vietnamese font), when I exprort to excel it's changed to Unicode UTF-8 so all of the characters had lost, text cannot be display correctly.
Is it possible to add a charset setting to code.
Thank you!
I'm using:
Expand|Select|Wrap|Line Numbers
- Private Sub saveExcelHA()
- ' This's my loading Flashscreen, you can remove it
- Dim frmStatusMessage As New frmStatus()
- frmStatusMessage.Show("Creating...")
- Dim IsConnecting As Boolean = True
- While IsConnecting
- '-------------------------------------------------
- Try
- Dim filename As String
- Dim col, row As Integer
- Dim ComDset As New DataSet
- Dim SelectStr As String = "select * from myTable"
- Dim adp As New OracleDataAdapter(SelectStr, Oracnn)
- ComDset.Reset()
- adp.Fill(ComDset, "TTbl")
- If ComDset.Tables.Count < 0 Or ComDset.Tables(0).Rows.Count <= 0 Then
- Exit Sub
- End If
- Dim Excel As Object = CreateObject("Excel.Application")
- If Excel Is Nothing Then
- MsgBox("Excel is not installed on this machine", MsgBoxStyle.Critical)
- Return
- End If
- With Excel
- .SheetsInNewWorkbook = 1
- .Workbooks.Add()
- .Worksheets(1).Select()
- Dim i As Integer = 1
- For col = 0 To ComDset.Tables(0).Columns.Count - 1
- .cells(1, i).value = ComDset.Tables(0).Columns(col).ColumnName
- .cells(1, i).EntireRow.Font.Bold = True
- i += 1
- Next
- i = 2
- Dim k As Integer = 1
- For col = 0 To ComDset.Tables(0).Columns.Count - 1
- i = 2
- For row = 0 To ComDset.Tables(0).Rows.Count - 1
- .Cells(i, k).Value = ComDset.Tables(0).Rows(row).ItemArray(col)
- i += 1
- Next
- k += 1
- Next
- filename = "c:\DataOut\ExpFile - " & Format(Now(), "yyyyMMdd - hhmmss") & ".xls"
- .ActiveCell.Worksheet.SaveAs(filename)
- End With
- System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
- Excel = Nothing
- MsgBox("Done", MsgBoxStyle.Information)
- ' Close opened file.
- Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
- For Each i As Process In pro
- i.Kill()
- Next
- ' This's my loading Flashscreen, you can remove it
- IsConnecting = False
- '-------------------------------------------------
- Catch ex As Exception
- MsgBox(ex.Message, MsgBoxStyle.Critical, "Messages Error")
- Throw ex
- End Try
- 'This's my loading Flashscreen, you can remove it
- End While
- frmStatusMessage.Close()
- '-------------------------------------------------
- End Sub