彰化一整天的論壇

 找回密碼
 立即註冊
查看: 547|回復: 0

EXCEL 轉 CSV 檔案(UTF-8格式)

[複製鏈接]
發表於 2016-9-28 10:04:36 | 顯示全部樓層 |閱讀模式
  1. Sub saveUnicodeCSV()
  2. Set oAdoS = CreateObject("ADODB.Stream")

  3.     oAdoS.Charset = "UTF-8"
  4.     oAdoS.Mode = 3
  5.     oAdoS.Type = 2
  6.     oAdoS.Open

  7. lRow = 1
  8. lCol = 1
  9. Do Until Sheets(1).Cells(lRow, lCol).Value = ""
  10.   oAdoS.WriteText (Sheets(1).Cells(lRow, lCol).Text)
  11.   lCol = lCol + 1
  12.   Do Until Sheets(1).Cells(lRow, lCol).Value = ""
  13.    oAdoS.WriteText ("," & Sheets(1).Cells(lRow, lCol).Text)
  14.    lCol = lCol + 1
  15.   Loop
  16.   oAdoS.WriteText (vbCrLf)
  17.   lCol = 1
  18.   lRow = lRow + 1
  19. Loop

  20. oAdoS.SaveToFile "c:\test.csv", 2
  21. oAdoS.Close
  22. Set oAdoS = Nothing
  23. End Sub
複製代碼
http://forum.twbts.com/viewthread.php?tid=18437&highlight=
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2019-10-18 01:46 , Processed in 0.131601 second(s), 19 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表