I need to do recurring import of text files with the same format into Calc, but every time I got to specify their fields format; is there a way to get them saved and reusable?
I don’t think that it is possible without a macro.
@MSpina: Doesn’t your import dialog remember the previous settings?
Beyond that, I’m afraid, there is no way to set defaults, not to speak of a kind of dropdown with selectable named items.
@gabix: Do you know an interface or a service of the API for the purpose (and also for ‘Text to Columns…’) and a way to use it from a “macro”. Or did you mean a complete re-implementation by the macro?
Shouldn’t the application itself come with that kind of features on board? Do you know a feature request like ‘Implement import styles and Tect-to-Columns styles’?
Tank you. That’s precisely what I meant. (Five years old and not upvoted once, Should actually nobody need that?)
I think because many times we import the same file, and if it is linked, options are preserved. Or with new files, last options are preserved except those for fields, but if the appropiatted language is selected, no intervention it’s needed, except to retain as text for some field with numbers.
I have to post it as an answer because of a limitation on the comment size. However, this is not a real answer, rather a comment to Lupp’s comment to my initial comment.
I have a couple of macros to load specific CSV files with specific preset options, here is one example:
Sub loadES
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl = "file:///e.csv"
sUrl2 = "file:///i.csv"
Dim mFileProperties(2) as new com.sun.star.beans.PropertyValue
mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)"
mFileProperties(1).Name = "FilterFlags"
mFileProperties(1).Value = "FIX,,30,1,0/2/13/2/50/2/53/10/65/10"
oDocument = oDesktop.loadComponentFromURL(sUrl, "_blank", 0, mFileProperties())
oDocument2 = oDesktop.loadComponentFromURL(sUrl2, "_blank", 0, mFileProperties())
End Sub
The macro is very crude but worked for me for many years in OpenOffice.org. However, it does not work in LibreOffice. Blame the developers for yet another broken thing. Thus, either use Apache OpenOffice (my firm general recommendation when it is about spreadsheets), or find a way to circumvent, or, well, pressure on the developers to repair the API.
(I won’t spend much more time with this thread since I never imported csv via “macros”.)
@gabix: You may throw a glance at LibreOffice: MediaDescriptor Service Reference and probably to LibreOffice: FilterFactory Service Reference
Well, you’re right. That’s not what we would call a clear and sufficiently complete documentation.
@gabix: AOO Calc also has lots of bugs of which rarely one is fixed. A relevant number, however, of the common heritage were resolved for LibO. LibO cared for healthy new blood, of course. I would judge there was a net improvement nonetheless. A few new incompatibilities may have been unavoidable.
(You surely learned to avoid mined terrain in AOO for a long time.)