473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1554

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 tecnhique used is to create a Excel-MIME stream...
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 simple COM DLL in .NET by using the COM class...
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 datagrid .The user then selects to save the file as 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 btnExcelExport_Click ( s As Object, e As...
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 to Excel. The problem is that when I attempt to...
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: Response.Cache.SetCacheability(HttpCacheability.NoCache); it didn't actually work...
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 the internet, and of course it worked without a...
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 name. eg : when I am writing My machine IP...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.