Setting defaults in calc, Freeze First Row, AutoFilter- how does it work?

How does one ‘Freeze First Row’ and ‘AutoFilter’ by default ?

I do not see any help for this in the Calc documentation near the text
Defaults
On the LibreOffice Calc – Defaults page

Have a look at:

Freeze Cells

AutoFilter

Applying AutoFilter

Thanks for the link to the on-line documentation.

When I look at the links above, I only see documentation for how to set these values for each spread sheet. I do this so often that I would like each spread sheet to set up this way as soon as I open the corresponding csv file; i.e., by default. How do I do this ?

See freezeAtPosition method

Sub DoFreeze()
    With ThisComponent.CurrentController
    '   .setActiveSheet(.ActiveSheet)  'not necessary
        .freezeAtPosition(0, 1) 
    End With
    Call DisplayAutoFilter
End Sub

Sub DisplayAutoFilter()
    Dim document As Object
    Dim dispatcher As Object

    document = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    Dim args(0) As New com.sun.star.beans.PropertyValue

    args(0).Name = "ToPoint"
    args(0).Value = "$A$1"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args())
    dispatcher.executeDispatch(document, ".uno:DataFilterAutoFilter", "", 0, Array())
End Sub

NOTE: If you do not change the active cell with the mouse, then A1 will be selected anyway when you open a CSV file.

Updated

This looks like it may solve my problem (at least for freezing the first row) but I am a lost as to how to apply it.

  1. What language is this script written in ?

  2. Where do I store this script so that it is loaded by libreoffice calc and executed directly after I load a new csv file ?

StarBasic
Lib: My Macros & Dialogs
You can call the procedure yourself (Alt+F11) or create a button in the menu to call it:
Tools - Customize - Tab: Menus Toolbars - Category: Macros, Search: DoFreeze - Select DoFreeze - Define scope & Add item to selected target: Standard (select the last item to add after)
Updated
Or set the key to call the macro (I used Alt+M):


Note: In my notebook