Tema: Re: Kaip CSV failus redaguoti?
Autorius: rimux
Data: 2015-06-09 14:41:38
O siaip tai googlas visagalis, va tau surinkau makro is internetiniu pavyzdziu, kaip irasineti aktyvu exelio sheeta i csv su utf8 koduote:


Sub Save_CSV_UTF8()
  Dim ws As Worksheet
  Set ws = ActiveSheet
  Call SaveWorksheet_As_CSV_UTF8("d:\temp\utf8.csv", ws)
End Sub

Function SaveWorksheet_As_CSV_UTF8(ByVal sUTF8CSVOutputFileName As String, ByVal wksWorksheet As Excel.Worksheet)
  Const sComma As String = ","
  Dim lDataRows As Long, lDataColumns As Long, lRowIndex As Long, lColumnIndex As Long
  lDataRows = wksWorksheet.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
  lDataColumns = wksWorksheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
  
  Dim vararrData() As Variant
  ReDim vararrData(1 To lDataColumns)
  
  Dim adodbStream As Object
  Set adodbStream = CreateObject("ADODB.Stream")
  adodbStream.Type = 2
  adodbStream.Charset = "utf-8"
  adodbStream.Open
    
  For lRowIndex = 1 To lDataRows
      For lColumnIndex = 1 To lDataColumns
          vararrData(lColumnIndex) = wksWorksheet.Cells(lRowIndex, lColumnIndex).Text
      Next
      'adodbStream.WriteText Join(vararrData, sComma), adWriteLine
      T = Join(vararrData, sComma)
      T = T + Chr(13) + Chr(10)
      adodbStream.WriteText T, adWriteLine
  Next
  
  adodbStream.SaveToFile sUTF8CSVOutputFileName, 2

End Function



Bent jau pas mane veikia, kada irasau i celes teksta su lietuviskom raidem, ir po to uzseivinta su situo makrosu  failiuka atidarau su notepad++,
tekstas teisingai rodomas buna. Gali modifikuotis pagal tai ko tau reikia - vietoj kablelio kabliataskius pasidaryti, ir pan.

Jeigu problema su atidarymu failo utf8, analogiska makrosa atidarymui failo galima pasirasyti.




On Tue, 9 Jun 2015 13:36:17 +0300, "Aras" <nera@nera.nera> wrote:

>Excelis iskraipo, jeigu tekste yra rusisku ir lenkisku raidziu. Kitu atveju nebesupranta internetas, jei nedarau UTF-8 koduotes.
>
>"marijonas" <jo@fa.na> wrote in message news:ml6bvg$rbi$1@trimpas.omnitel.net...
>> "Aras" <nera@nera.nera> Wrote in message:
>>> Gal esate i?testav? kokia nemokama programa geriausia CSV failams redaguoti? Excelio nesi?lyti, bo jis nesusitvarko su UTF-8.
>>> 
>> 
>> Siulau exceli
>> -- 
>> 
>> 
>> ----Android NewsGroup Reader----
>> http://usenet.sinaapp.com/
>>