ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¨DEXCEL Âà CSV ÀÉ®×(UTF-8®æ¦¡)

[µo°Ý] ¨DEXCEL Âà CSV ÀÉ®×(UTF-8®æ¦¡)

¥»©«³Ì«á¥Ñ PKKO ©ó 2016-9-27 16:40 ½s¿è

¦³®É»Ý­n³oºØ¸ê®Æ,¤â°Ê·|«ÜÂZ¤H
§Ú¿ý»s¤F¥¨¶°
±NEXCELÂରCSVÀÉ®×+UFT-8®æ¦¡
¦ý¹ê»Ú¤W«o¤£¬OUFT-8

¦³¤j¤jÄ@·N¤À¨É¤@¤U¦p¦ó¥i¥H¿ì¨ì¶Ü?
¥H¤U¬O¤p§Ì¿ù»~ªºCODE
  1. With ActiveWorkbook.WebOptions
  2.         .RelyOnCSS = True
  3.         .OrganizeInFolder = True
  4.         .UseLongFileNames = True
  5.         .DownloadComponents = False
  6.         .RelyOnVML = False
  7.         .AllowPNG = True
  8.         .ScreenSize = msoScreenSize1024x768
  9.         .PixelsPerInch = 96
  10.         .Encoding = msoEncodingUTF8
  11.     End With
  12.     With Application.DefaultWebOptions
  13.         .SaveHiddenData = True
  14.         .LoadPictures = True
  15.         .UpdateLinksOnSave = True
  16.         .CheckIfOfficeIsHTMLEditor = True
  17.         .AlwaysSaveInDefaultEncoding = False
  18.         .SaveNewWebPagesAsWebArchives = True
  19.     End With
  20.     ActiveWorkbook.SaveAs Filename:="C:\Users\user\Documents\test2.csv", _
  21.         FileFormat:=xlCSV, CreateBackup:=False
½Æ»s¥N½X
¤]¦³¤Wºô¬d¹L,¤U­±³o­Ó¤]¤£¬OUTF-8ªº¼Ë¤l
  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 "test.csv", 2
  21. oAdoS.Close
  22. Set oAdoS = Nothing
  23. End Sub
½Æ»s¥N½X
PKKO

§ó¥¿,¥H¤U¤è¦¡¥i¥H¦¨¥\ÂରUTF8+CSV
  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
½Æ»s¥N½X
PKKO

TOP

        ÀR«ä¦Û¦b : «Î¼e¤£¦p¤ß¼e¡C
ªð¦^¦Cªí ¤W¤@¥DÃD