https://bugs.documentfoundation.org/show_bug.cgi?id=167117

            Bug ID: 167117
           Summary: Unexpected AutoFilter prompt "The range does not
                    contain column headers"
           Product: LibreOffice
           Version: 24.8.6.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

I am generating a number of LibreOffice Calc spreadsheets automatically
(programmatically) with the --headless option. The spreadsheets are filled with
information from a database.

I want the AutoFilter header in them, so this is the code I came up with:

Sub SetAutoFilter ( doc As Object )

  Dim frame As Object
  frame = doc.CurrentController.Frame

  Dim dispatcher As Object
  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( frame, ".uno:GoToCell", "", 0, args() )

  dispatcher.executeDispatch( frame, ".uno:DataFilterAutoFilter", "", 0,
Array() )

End Sub

That worked fine for a while, but started failing for some spreadsheets. After
some investigation, it turns out the reason is that LibreOffice Calc sometimes
prompts the following:

"The range does not contain column headers. Do you want the first line to be
used as column header?"

That prompt breaks automation in headless mode.

Some people say that this happens when the first row has empty cells, but that
wasn't the case.

After some more research, I found out that the prompt only comes up if there
are less than 4 column headers.

This seems like a bug to me.

As a work-around, I just added extra column headers with the title
"<workaround>", and then the routine above worked fine again. The data
underneath can still have less than 4 columns.

By the way, where can I find documentation about the parameters for
.uno:DataFilterAutoFilter ? I couldn't find any documentation at the usual
locations, and I would like to know what arguments [ "", 0, Array() ] mean.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to