We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

How can I save my document as a CSV and maintain all languages in the exported document

asked 2018-05-28 23:19:24 +0200

Kevin  French gravatar image

updated 2021-05-11 14:35:16 +0200

Alex Kemp gravatar image

Right now, I am forced into choosing a specific language for my CSV file. All characters not in my selected language become question marks.

edit retag flag offensive close merge delete


What you are asking might not be possible. In my limited experience, CSV files are coded in ASCII which allows some accented characters (using Extended-ASCII) but not all foreign characters. But It might be possible to generate a CSV file using UTF-8 character coding which should cover many/most foreign alphabets. I don't know if this is possible in LibreOffice.

ve3oat gravatar imageve3oat ( 2018-05-29 03:26:26 +0200 )edit

Of course it is. And yes, UTF-8 covers all Unicode characters, not just many/most.

erAck gravatar imageerAck ( 2018-05-30 09:30:39 +0200 )edit

@erAck, thanks for the info. I stand corrected (and informed).

ve3oat gravatar imageve3oat ( 2018-05-30 15:16:59 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-05-29 09:11:04 +0200

gabix gravatar image

CSV files are plain-text files, thus, they do not have such an attribute as a language. The only thing that you do in that respect is to control the encoding when you export to CSV, so make sure to tick Edit filter settings in the export dialog. To be on the safe side, choose UTF-8 or UTF-16. For further information refer to the manual.

Here is my macro that exports a spreadsheet to UTF-8, tab-delimited, no text delimiter:

Sub ExportToGlossary

Dim oDoc as Object
Dim glossaryFileProperties(3) as new com.sun.star.beans.PropertyValue
Dim sURL as String
Dim iLen as Integer
Dim isSpreadSheet as Boolean

oDoc = ThisComponent
If oDoc.getLocation() = "" Then Exit Sub

isSpreadSheet = oDoc.supportsService("com.sun.star.sheet.SpreadsheetDocument")

If isSpreadSheet Then
sURL = oDoc.getLocation()
iLen = len(sURL)

If lcase(right(sURL,4))=".ods" Then
    sURL = left(sURL, iLen - 4)
   If lcase(right(sURL,4))=".xls" Then
       sURL = left(sURL, iLen - 4)
       If lcase(right(sURL,5))=".xlsx" Then
           sURL = left(sURL, iLen - 5)
       End If
   End If    
End If

sURL = sURL + ".txt"

glossaryFileProperties(0).Name = "FilterName"  ' setting properties of exported file such as tab as field delimiter, nothing as text delimiter, UTF-8 as encoding
glossaryFileProperties(0).Value = "Text - txt - csv (StarCalc)"
glossaryFileProperties(1).Name = "FilterOptions"
glossaryFileProperties(1).Value = "9,0,76,1,,0,false,true,false"
glossaryFileProperties(2).Name = "Overwrite"
glossaryFileProperties(2).Value = True

oDoc.storeToURL(sURL, glossaryFileProperties())
End If
End Sub
edit flag offensive delete link more
Login/Signup to Answer

Question Tools



Asked: 2018-05-28 23:19:24 +0200

Seen: 1,079 times

Last updated: May 29 '18