Read Chinese characters from Excel worksheet? (Always returns “????”)

陌路散爱 提交于 2019-12-23 17:11:53

问题


How do I read Chinese characters from Excel cells and write them to a file? When I take values by

Worksheets(ActiveCell.Worksheet.Name).Cells(3, columnNumbers(0)).value

it always returns "????????"


回答1:


Dim fileStream, FilePath As String    

'Full properties file path
propFilePath = "C:\file.properties"

'Create Stream object
Set fileStream = CreateObject("ADODB.Stream")

'Specify stream type – we want To save text/string data.
fileStream.Type = 2

'Specify charset For the source text data.
fileStream.Charset = "utf-8"

'Open the stream And write binary data To the object
fileStream.Open
fileStream.writetext "write something here"

'Save binary data To disk
fileStream.SaveToFile FilePath, 2
fileStream.Close



回答2:


  1. this may be csv file
  2. open with text editor, save in the UTF8 or UNICODE format


来源:https://stackoverflow.com/questions/9632830/read-chinese-characters-from-excel-worksheet-always-returns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!