Bug 167117 - Unexpected AutoFilter prompt "The range does not contain column headers"
Summary: Unexpected AutoFilter prompt "The range does not contain column headers"
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.6.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: AutoFilter Macro
  Show dependency treegraph
 
Reported: 2025-06-19 17:36 UTC by R. Diez
Modified: 2025-06-20 04:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R. Diez 2025-06-19 17:36:28 UTC
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.
Comment 1 m_a_riosv 2025-06-20 00:37:09 UTC
Please ask your question in https://ask.libreoffice.org/c/english/5/l/latest, there are valuable people to help.