472,337 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

VB.NET: Problem with charset setting when export to Excel

VietPP
17
Hi all,

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
  1. Private Sub saveExcelHA()
  2.         ' This's my loading Flashscreen, you can remove it
  3.         Dim frmStatusMessage As New frmStatus()
  4.         frmStatusMessage.Show("Creating...")
  5.         Dim IsConnecting As Boolean = True
  6.         While IsConnecting
  7.         '-------------------------------------------------
  8.             Try
  9.                 Dim filename As String
  10.                 Dim col, row As Integer
  11.                 Dim ComDset As New DataSet
  12.  
  13.                 Dim SelectStr As String = "select * from myTable"
  14.                 Dim adp As New OracleDataAdapter(SelectStr, Oracnn)
  15.                 ComDset.Reset()
  16.                 adp.Fill(ComDset, "TTbl")
  17.                 If ComDset.Tables.Count < 0 Or ComDset.Tables(0).Rows.Count <= 0 Then
  18.                     Exit Sub
  19.                 End If
  20.                 Dim Excel As Object = CreateObject("Excel.Application")
  21.  
  22.                 If Excel Is Nothing Then
  23.                     MsgBox("Excel is not installed on this machine", MsgBoxStyle.Critical)
  24.                     Return
  25.                 End If
  26.  
  27.                 With Excel
  28.                     .SheetsInNewWorkbook = 1
  29.                     .Workbooks.Add()
  30.                     .Worksheets(1).Select()
  31.  
  32.                     Dim i As Integer = 1
  33.                     For col = 0 To ComDset.Tables(0).Columns.Count - 1
  34.                         .cells(1, i).value = ComDset.Tables(0).Columns(col).ColumnName
  35.                         .cells(1, i).EntireRow.Font.Bold = True
  36.                         i += 1
  37.                     Next
  38.                     i = 2
  39.                     Dim k As Integer = 1
  40.                     For col = 0 To ComDset.Tables(0).Columns.Count - 1
  41.                         i = 2
  42.                         For row = 0 To ComDset.Tables(0).Rows.Count - 1
  43.                             .Cells(i, k).Value = ComDset.Tables(0).Rows(row).ItemArray(col)
  44.                             i += 1
  45.                         Next
  46.                         k += 1
  47.                     Next
  48.                     filename = "c:\DataOut\ExpFile - " & Format(Now(), "yyyyMMdd - hhmmss") & ".xls"
  49.                     .ActiveCell.Worksheet.SaveAs(filename)
  50.                 End With
  51.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
  52.                 Excel = Nothing
  53.                 MsgBox("Done", MsgBoxStyle.Information)
  54.  
  55.                 ' Close opened file.
  56.                 Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
  57.                 For Each i As Process In pro
  58.                     i.Kill()
  59.                 Next
  60.             ' This's my loading Flashscreen, you can remove it
  61.                 IsConnecting = False
  62.             '-------------------------------------------------
  63.             Catch ex As Exception
  64.                 MsgBox(ex.Message, MsgBoxStyle.Critical, "Messages Error")
  65.                 Throw ex
  66.             End Try
  67.         'This's my loading Flashscreen, you can remove it
  68.         End While
  69.         frmStatusMessage.Close()
  70.         '-------------------------------------------------
  71.     End Sub
Dec 28 '07 #1
0 1495

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Funbeat | last post by:
Hi everybody, I'm facing with the following problem (bug ?) : A page is calling another one (export.aspx) for exporting data to excel. The...
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a...
4
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a...
3
by: mattdaddym | last post by:
Hi all, I have been using the following code to export my datagrids to excel for quite some time. Very simple and very effective. <code> Sub ...
3
by: Russ | last post by:
I have a usercontrol that is loaded by a webform. The usercontrol populates a datagrid which users need the capability to export data from the grid...
5
by: Tim_Mac | last post by:
hi, i read that by adding the following code to by aspx pages, it would not store temporary internet files:...
1
by: Anonieko | last post by:
Here are some of the approaches. 1. Transform DataGrid http://www.dotnetjohn.com/articles.aspx?articleid=36 3. Use the Export approach ...
1
by: JawzX01 | last post by:
Hello All, First, thank you for any help you can provide. I'm trying to do a simple export to excel. I've used the classic code that is all over...
0
by: mustaqueahmad | last post by:
Hi All, I am getting export to excel problem when I am giving IPAddress in URL, but it is working correct when am giving localhost and page...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.