Documentation for scalc: Text - txt - csv (StarOffice Calc)?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ChuckS12065
Posts: 2
Joined: Tue Dec 22, 2020 9:08 pm

Documentation for scalc: Text - txt - csv (StarOffice Calc)?

Post by ChuckS12065 »

I am relatively new to OOo Macros and Basic (but not to programming), so I'll apologize in advance if this is "somewhere obvious"...

I have spent several hours trying to find via web search what options are available when using loadComponentFromURL with the FilterName set to "scalc: Text - txt - csv (StarOffice Calc)" but have come up empty (including the Developer's Guide and BASIC Programming Guide). In example code that I have run across, another property that seems to be used regularly is USE_CONFIG="3". I'd like to know what that does, as well as understand what other possible options are. I am assuming here that USE_CONFIG is an option to the filter. Please correct me if I'm wrong.

Thanks for the help!

Chuck
Fedora 33 - current distro kernel & libreoffice-calc versions, which currently (12/2020) is 5.9.14-200 and 7.0.4.2, respectively.
Jan_J
Posts: 188
Joined: Wed Apr 29, 2009 1:42 pm
Location: Poland

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by Jan_J »

Here you should find complete options for the filter: https://wiki.openoffice.org/wiki/Docume ... CSV_Filter. They specify ordinary details for csv subformat processing.

USE_CONFIG is in no way not a filter option. It is named constant (having value 3) defined in MacroExecutionMode module for the purpose to help controlling execution of document-embedded macros.
More: see Andrew Pitonyak, “OpenOffice Macros Explained”, section 12.4.3 `Enabling macros while loading a document`, https://www.pitonyak.org/OOME_3_0.pdf, page 282.
JJ ∙ https://forum.openoffice.org/pl/
LO (25.2|24.8) ∙ Python (3.12|3.10) ∙ Unicode 16 ∙ LᴬTEX 2ε ∙ XML ∙ Unix tools ∙ Linux (Rocky|CentOS)
User avatar
Sébastien C
Posts: 111
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by Sébastien C »

Hello all !

An example extract from the beginning of this code snippet and this CSV.
The REMs can be useful I think...

Code: Select all

Sub readCSV()
 Dim       myCSVdocument As Object, mySheet As Object
 Dim        myOptions(2) As New com.sun.star.beans.PropertyValue

 myCSVFile = "/here/you/have/to/set/the/path/of/the/file/named/myTempoCSV.csv"

 ' Open the CSV file.
 myOptions(0).Name = "FilterName"    : myOptions(0).value = "Text - txt - csv (StarCalc)"
 myOptions(1).Name = "FilterOptions" : myOptions(1).value = "44,34,76,1,1/2/2/4/3/2"
 '  44 =          Field separator : comma.
 '  34 =     Text field delimiter : quote character ".
 '  76 =                 Encoding : Unicode (UTF-8).
 '   1 = First line to be treated : line 1.
 ' 1/2 =            Column format : column 1 is formating in TEXT (2).
 ' 2/4 =            Column format : column 2 is formating in DATE (4) JJ/MM/AA (french disposition) ; the import of TIME what is spewed by PHP is still...
 ' 3/2 =            Column format : column 3 is formating in TEXT (2).

 myCSVdocument = starDesktop.loadComponentFromURL(convertToURL(myCSVFile), "_blank", 0, myOptions())
       mySheet = myCSVdocument.sheets(0)
End Sub

:D
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 :ouch: .
ChuckS12065
Posts: 2
Joined: Tue Dec 22, 2020 9:08 pm

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by ChuckS12065 »

Jan_J wrote:Here you should find complete options for the filter: https://wiki.openoffice.org/wiki/Docume ... CSV_Filter. They specify ordinary details for csv subformat processing.

USE_CONFIG is in no way not a filter option. It is named constant (having value 3) defined in MacroExecutionMode module for the purpose to help controlling execution of document-embedded macros.
More: see Andrew Pitonyak, “OpenOffice Macros Explained”, section 12.4.3 `Enabling macros while loading a document`, https://www.pitonyak.org/OOME_3_0.pdf, page 282.
Thanks, Jan_J!! I'm not only learning about the task at hand, I'm also learning how to navigate the documentation! :-)

However, the code that I have seen did not use USE_CONFIG as a named constant. Instead, it was thus:

FileProperties(1).Name = "USE_CONFIG"
FileProperties(1).Value ="3"

Is this equivalent to MacroExecutionMode = com.sun.star.document.MacroExecMode.USE_CONFIG?

Thanks again,

Chuck
Fedora 33 - current distro kernel & libreoffice-calc versions, which currently (12/2020) is 5.9.14-200 and 7.0.4.2, respectively.
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by Villeroy »

Open one of your csv files manually with all the required options for delimiters, encoding, language, special numbers = ON, special settings for individual columns etc.
Then run the following routine which reports the current document's filter options in an input box from where you can copy the string.

Code: Select all

Sub showFilterOptions()
Dim args(),i%
   args() = thisComponent.getArgs
   for i = 0 to uBound(Args())
      if args(i).Name = "FilterOptions" then inputbox args(i).Name,"",cStr(args(i).value)
   next
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 3076
Joined: Wed Mar 09, 2016 2:40 pm

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
CarlSopchak
Posts: 4
Joined: Sun Mar 15, 2009 2:49 am

Re: Documentation for scalc: Text - txt - csv (StarOffice Ca

Post by CarlSopchak »

Thanks Villeroy, that could prove useful!
Thanks for trying Sébastien, but I was not looking for a specific example. I was looking for all of the options available (which Jan_J's first link supplied).
Thanks for trying JeJe, but I had already read through those pages. They do not have what I was looking for.
Thanks to all!
Chuck
OOo 2.3.X on Fedora 8 + F10
Post Reply