Bug 167442 - [Documentation] Detection of first row as header when sorting in Calc
Summary: [Documentation] Detection of first row as header when sorting in Calc
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Olivier Hallot
URL:
Whiteboard: target:26.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-09 19:09 UTC by LeroyG
Modified: 2025-08-15 13:26 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample file to test. (14.20 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-07-09 19:09 UTC, LeroyG
Details

Note You need to log in before you can comment on or make changes to this bug.
Description LeroyG 2025-07-09 19:09:55 UTC
Created attachment 201720 [details]
Sample file to test.

Under sorting it is written:
"However, it also recognizes the first row as a header row and excludes it from the sort."

Source:
Calc Guide 25.2, Chapter 15 - Calc as a Database
https://books.libreoffice.org/en/CG252/CG25215-CalcAsADatabase.html#toc24

To be true, there must be at least one column header that is text and the column content must be numbers.
If the content of all cells are just text, or the content mix text and numbers, the first row is sorted too.

Header recognition…
…works with:
a	b
1	2
2	1

…works with:
a	b
aaa	2
bbb	1

…don't works with:
1	2
a	b
b	a

…don't works with:
a	0
aaa	2
bbb	1

…don't works with:
a	b
aaa	bb
bbb	aa

Version: 24.8.5.2 (X86_64) / LibreOffice Community
Build ID: 480(Build:2)
CPU threads: 4; OS: Linux 6.4; UI render: default; VCL: gtk3
Locale: es-MX (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Regina Henschel 2025-07-10 11:10:27 UTC
Do you mean something like the following?

In case the column has a text in the first row and only numbers in the following rows, Sort recognizes the first row as a header row and excludes it from the sort.

That the Sort dialog has to be used in other cases, follows in the next but one paragraph.
Comment 2 LeroyG 2025-07-10 11:21:44 UTC
(In reply to Regina Henschel from comment #1)
> Do you mean something like the following?
> 
> In case the column has a text in the first row and only numbers in the
> following rows, Sort recognizes the first row as a header row and excludes
> it from the sort.
Maybe:
However, if there is at least one column with text in the first row and numbers in the following rows, Sort recognizes the first row as a header row and excludes it from the sort.
Comment 3 Olivier Hallot 2025-08-01 13:49:46 UTC
This text is going to the Help first and later to the book.

-------8<------
Sorting a block of cells in LibreOffice Calc

A block of cells is a rectangular range of cells surrounded by empty cells.

LibreOffice Calc automatically identifies a block of cells for sorting. Place the cursor within the block, and the sorting will take place accordingly.

If all the cells in the first row of a block are text cells, this row is assumed to be the header. The sorting will then be performed from the second row to the last row of the block, except if all the block cells are text cells.

However, if any cell in the first row contains a numerical value, or all the block cells are text cells, the first row will not be considered a header, and sorting will be applied to the entire block.

The sorting is applied to the selected column or the first column of the block.

If the selected column is inside the block, LibreOffice Calc prompts to extend the sorting to the adjacent columns.
-------8<------
Comment 4 Commit Notification 2025-08-04 11:38:15 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/632d38b60f5169e1ab2651d52667f7415c7d3800

tdf#167442 Precision on sorting blocks of cells.