0% found this document useful (0 votes)
7 views

CG248-CalcGuide

This document is the copyright notice and contributor list for the LibreOffice Calc Guide, published in January 2025. It outlines the distribution rights under the GNU General Public License and Creative Commons Attribution License, and provides information on where to seek help and feedback. The guide is intended for users ranging from beginners to advanced, covering various features and functionalities of LibreOffice Calc.

Uploaded by

Tania Popa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CG248-CalcGuide

This document is the copyright notice and contributor list for the LibreOffice Calc Guide, published in January 2025. It outlines the distribution rights under the GNU General Public License and Creative Commons Attribution License, and provides information on where to seek help and feedback. The guide is intended for users ranging from beginners to advanced, covering various features and functionalities of LibreOffice Calc.

Uploaded by

Tania Popa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 572

Copyright

This document is Copyright © 2025 by the LibreOffice Documentation Team. Contributors are
listed below. You may distribute it and/or modify it under the terms of either the GNU General
Public License (https://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative
Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), version 4.0 or later.
All trademarks within this guide belong to their legitimate owners.
Book 1

Contributors
To this edition
Dione Maddern Lisa Samy Ed Olson
B. Antonio Fernández Claire Wood Olivier Hallot

To previous editions
Skip Masonsmith flywire Kees Kriek
Steve Fanning Jenna Sargent Olivier Hallot
Pulkit Krishna Jean Hollis Weber Dan Lewis
Peter Schofield Jochen Schiffers Robert Großkopf
Jost Lange Martin Fox Hazel Russman
Steve Schwettman Alain Romedenne Andrew Pitonyak
Jean-Pierre Ledure Drew Jensen Randolph Gamo

Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
forum at https://community.documentfoundation.org/c/documentation/loguides/ (registration is
required) or send an email to: [email protected].

Note
Everything you send to a forum, including your email address and any other
personal information that is written in the message, is publicly archived and
cannot be deleted. Emails sent to the forum are moderated.

Publication date and software version


Published January 2025. Based on LibreOffice 24.8 Community.
Other versions of LibreOffice may differ in appearance and functionality.

Documentation for LibreOffice is available at https://documentation.libreoffice.org/en/


Contents
Copyright.....................................................................................................................................2
Preface.............................................................................................................................. 7
Who is this book for?.................................................................................................................. 8
What’s in this book?.................................................................................................................... 8
Where to get more help..............................................................................................................8
What you see may be different................................................................................................. 10
Using LibreOffice on macOS.....................................................................................................11
What are all these things called?..............................................................................................12
Frequently asked questions......................................................................................................13
What's new in this guide........................................................................................................... 14
Chapter 1 Introduction..................................................................................................15
What is Calc?............................................................................................................................ 16
Spreadsheets, sheets, and cells...............................................................................................16
Calc main window..................................................................................................................... 16
Creating, opening, and saving spreadsheets...........................................................................24
Password protection................................................................................................................. 28
Navigating within spreadsheets................................................................................................ 29
Selecting items in a spreadsheet..............................................................................................33
Working with columns and rows............................................................................................... 36
Working with sheets.................................................................................................................. 38
Viewing a spreadsheet..............................................................................................................40
Using the Navigator.................................................................................................................. 43
Using document properties.......................................................................................................44
Chapter 2 Entering and Editing Data............................................................................ 49
Introduction............................................................................................................................... 50
Entering data.............................................................................................................................50
Accelerating data entry............................................................................................................. 55
Merging and splitting cells.........................................................................................................62
Sharing content between sheets...............................................................................................63
Validating cell contents.............................................................................................................64
Modifying data...........................................................................................................................67
Group and outline..................................................................................................................... 72
Filtering..................................................................................................................................... 74
Sorting records..........................................................................................................................79
Find and replace....................................................................................................................... 82
Searching and filtering with regular expressions...................................................................... 85
Chapter 3 Formatting Data............................................................................................ 91
Introduction............................................................................................................................... 92
Formatting data......................................................................................................................... 92
AutoFormat of cells and sheets................................................................................................99
Value highlighting.................................................................................................................... 100
Using conditional formatting....................................................................................................101
Hiding and showing data......................................................................................................... 111
Chapter 4 Using Styles and Templates......................................................................115
What are styles? Why use them?........................................................................................... 116
Calc style types.......................................................................................................................116
Applying cell styles.................................................................................................................. 117
Applying page styles............................................................................................................... 120
Creating new styles.................................................................................................................121
Using themes.......................................................................................................................... 133

Calc Guide 24.8 | 3


Managing styles...................................................................................................................... 135
What is a template? Why use one?........................................................................................ 136
Using a template to create a spreadsheet.............................................................................. 137
Creating a template.................................................................................................................138
Editing a template................................................................................................................... 139
Changing the template assigned to a document....................................................................140
Adding templates obtained from other sources...................................................................... 140
Setting the default template.................................................................................................... 142
Organizing templates.............................................................................................................. 143
Chapter 5 Using Images and Graphics......................................................................147
Introduction............................................................................................................................. 148
Adding graphics (images) to a spreadsheet...........................................................................148
Modifying images.................................................................................................................... 152
Positioning, resizing, and arranging images........................................................................... 154
Using LibreOffice’s drawing tools............................................................................................157
Additional tools........................................................................................................................160
Using Fontwork....................................................................................................................... 160
Generating a QR or Barcode.................................................................................................. 161
Chapter 6 Creating Charts and Graphs...................................................................... 163
Introduction............................................................................................................................. 164
Chart Wizard........................................................................................................................... 164
Using the Sidebar to change chart settings............................................................................ 171
Modifying charts...................................................................................................................... 172
Selecting and moving chart elements.....................................................................................176
Changing chart type................................................................................................................ 177
Titles, subtitles, and axis names............................................................................................. 177
Legends.................................................................................................................................. 179
Formatting chart backgrounds................................................................................................ 181
Data range and series.............................................................................................................182
Axes........................................................................................................................................ 190
Data labels.............................................................................................................................. 197
Chart Data Tables................................................................................................................... 201
Grids....................................................................................................................................... 204
3D charts.................................................................................................................................205
Trend and mean value lines....................................................................................................209
Error bars................................................................................................................................ 214
Adding drawing objects to charts............................................................................................217
Resizing, moving, and positioning charts................................................................................218
Selecting multiple charts.........................................................................................................222
Copying, exporting, and deleting charts..................................................................................224
Chapter 7 Gallery of Chart Types............................................................................... 227
Introduction............................................................................................................................. 228
Column charts......................................................................................................................... 228
Bar charts................................................................................................................................229
Pie charts................................................................................................................................ 229
Area charts..............................................................................................................................232
Line charts.............................................................................................................................. 233
Scatter or XY charts................................................................................................................ 235
Bubble charts.......................................................................................................................... 238
Net charts................................................................................................................................239
Stock charts............................................................................................................................ 240
Column and line charts........................................................................................................... 243
Pivot charts............................................................................................................................. 244

4 | Calc Guide 24.8


Create box plots with whiskers in Calc...................................................................................245
Sparklines............................................................................................................................... 246
Chapter 8 Printing, Exporting, Emailing, and Signing..............................................253
Printing.................................................................................................................................... 254
Using print ranges................................................................................................................... 258
Page breaks............................................................................................................................ 263
Printing options for page styles............................................................................................... 264
Headers and footers............................................................................................................... 265
Exporting to PDF.....................................................................................................................268
Exporting to other formats.......................................................................................................276
Emailing spreadsheets............................................................................................................276
Digital signing of documents...................................................................................................276
Removing personal data......................................................................................................... 279
Chapter 9 Using Formulas and Functions................................................................. 281
Introduction............................................................................................................................. 282
Setting up a spreadsheet........................................................................................................282
Creating formulas....................................................................................................................283
Understanding functions......................................................................................................... 298
Strategies for creating formulas and functions.......................................................................306
Investigating and Resolving Formula Errors...........................................................................308
Examples of functions.............................................................................................................311
Volatile / non-volatile functions................................................................................................314
Using wildcards and regular expressions in functions............................................................314
Advanced functions.................................................................................................................317
Chapter 10 Using Pivot Tables.................................................................................... 319
Introduction............................................................................................................................. 320
The Pivot Table Layout dialog................................................................................................. 323
Working with the results of the pivot table.............................................................................. 335
Using pivot table results elsewhere........................................................................................347
Pivot charts............................................................................................................................. 350
Chapter 11 Data Analysis............................................................................................ 355
Introduction............................................................................................................................. 356
Consolidating data.................................................................................................................. 356
Creating subtotals................................................................................................................... 359
Using scenarios...................................................................................................................... 364
Using the Multiple Operations tool..........................................................................................368
Using Goal Seek..................................................................................................................... 374
Using the Solver......................................................................................................................376
Using Statistics tools............................................................................................................... 381
Chapter 12 Linking Data.............................................................................................. 401
Using multiple sheets.............................................................................................................. 402
Referencing other documents................................................................................................. 409
Using hyperlinks and URLs.....................................................................................................410
Linking to external data........................................................................................................... 416
Linking to registered data sources..........................................................................................423
Embedding spreadsheets....................................................................................................... 429
XML Source............................................................................................................................ 435
Chapter 13 Sharing and Reviewing Spreadsheets...................................................439
Introduction............................................................................................................................. 440
Sharing spreadsheets............................................................................................................. 440
Reviewing documents............................................................................................................. 442
Merging documents................................................................................................................ 449

Calc Guide 24.8 | 5


Comparing documents............................................................................................................ 449
Saving versions.......................................................................................................................449
Chapter 14 Macros....................................................................................................... 453
Introduction............................................................................................................................. 454
On Visual Basic for Applications (VBA) compatibility..............................................................454
Using the macro recorder.......................................................................................................454
Write your own functions.........................................................................................................458
Accessing cells directly...........................................................................................................467
Sorting.....................................................................................................................................468
Overview of BeanShell, JavaScript, and Python macros........................................................469
ScriptForge library...................................................................................................................474
Built-in object inspector........................................................................................................... 474
Working with VBA macros.......................................................................................................475
Conclusion.............................................................................................................................. 477
Chapter 15 Calc as a Database................................................................................... 479
Introduction............................................................................................................................. 480
Associating a range with a name............................................................................................481
Referencing in a Calc Database Table....................................................................................486
Sorting.....................................................................................................................................489
Filtering................................................................................................................................... 491
Useful database-like functions................................................................................................494
Chapter 16 Setting up and Customizing....................................................................503
Introduction............................................................................................................................. 504
LibreOffice options..................................................................................................................504
Options for loading and saving documents.............................................................................509
Calc-specific options...............................................................................................................512
Default colors for charts..........................................................................................................525
Customizing the user interface...............................................................................................525
Assigning macros to events....................................................................................................533
Adding functionality with extensions....................................................................................... 533
Adding custom colors..............................................................................................................535
Setting up document themes.................................................................................................. 536
Chapter 17 User Interface Variants............................................................................. 539
Introduction............................................................................................................................. 540
Selecting the user interface....................................................................................................541
Standard interfaces................................................................................................................. 541
Contextual Single.................................................................................................................... 542
Tabbed interface..................................................................................................................... 542
Tabbed Compact interface......................................................................................................556
Groupedbar Compact interface...............................................................................................556
Appendix A Keyboard Shortcuts................................................................................559
Introduction............................................................................................................................. 560
Windows / Linux keyboard shortcuts......................................................................................560
macOS keyboard shortcuts.....................................................................................................568
Appendix B Error Codes............................................................................................. 577
Introduction to Calc error codes.............................................................................................. 578
Error codes displayed within cells...........................................................................................579
General error codes................................................................................................................ 580
Calc Error Functions............................................................................................................... 582

6 | Calc Guide 24.8


Calc Guide 24.8

Preface
Who is this book for?
This book is for beginner to advanced users of Calc, the spreadsheet component of LibreOffice.
You may be new to spreadsheet software, or you may be familiar with another program. If you
have never used LibreOffice before, or you want an introduction to all of its components, you
might like to read the Getting Started Guide first. If you have never used spreadsheets before,
you might also like to read a book or find some tutorials about the use of spreadsheets.

What’s in this book?


This book introduces the features and functions of LibreOffice Calc. It is not a tutorial on using
spreadsheets. Some chapters assume familiarity with basic spreadsheet usage when describing
how to use Calc.
You can enter data (usually numerical) in a spreadsheet and then manipulate this data to
produce certain results. Alternatively, you can enter data and then use Calc in a ‘What if...’
manner by changing some of the data and observing the results without having to retype all of
the data. Functions can be used to create formulas to perform complex calculations on data.
Some of the other features provided by Calc include:
• Database functions, to arrange, store, and filter data.
• Data statistics tools, to perform complex data analysis.
• Dynamic charts: a wide range of 2D, 3D charts, and sparklines
• Ability to open, edit, and save Microsoft Excel and other spreadsheets.
• Import and export of spreadsheets from multiple formats, including HTML, CSV, and
Data Interchange Format.

Where to get more help


This book, the other LibreOffice user guides, the built-in Help system, and user support systems
assume that you are familiar with your computer and basic functions such as starting a program,
opening and saving files.

Help system
LibreOffice comes with an extensive online Help system. This is the first line of support for using
LibreOffice. Windows and Linux users can choose to download and install the offline Help for
use when not connected to the Internet; the offline Help is installed with the program on macOS.
To display the Help system, press F1 or select Help > LibreOffice Help from the Menu bar
(Figure 1). If you do not have the offline help installed on your computer and you are connected
to the Internet, your default browser will open the online Help pages on the LibreOffice website.
The Help menu includes links to other LibreOffice information and support facilities.

Note
The following options indicated by a ‡ symbol are only accessible if your computer is
connected to the Internet.

8 |Calc Guide 24.8


Figure 1: The Help menu
• What’s This? – For quick tips when a toolbar is visible, place the mouse pointer over
any of the icons to see a small box (“tooltip”) with a brief explanation of the icon’s
function. For a more detailed explanation, select Help > What’s This? and hold the
pointer over the icon. In addition, you can choose whether to activate extended tips using
Tools > Options > LibreOffice > General > Extended tips.
• User Guides‡ – Opens your default browser at the English Documentation page of the
LibreOffice website https://documentation.libreoffice.org/en/english-documentation/.
There you will find copies of user guides and other useful information.
• Show Tip of the Day – Opens a dialog showing a useful piece of information to help
expand your knowledge of LibreOffice.
• Search Commands – Opens a dialog where you can search for commands that are
present in the main menu and then run a selected command. More information about this
facility can be found in Chapter 1, Introduction.
• Get Help Online‡ – Opens your default browser at the Ask LibreOffice forum of
questions and answers from the LibreOffice community
https://ask.libreoffice.org/c/english/5.
• Send Feedback‡ – Opens your default browser at the Feedback page of the LibreOffice
website https://www.libreoffice.org/get-help/feedback/. From there you can report bugs,
suggest new features, and communicate with others in the LibreOffice community.
• Restart in Safe Mode – Opens a dialog where you can restart LibreOffice and reset the
software to its default settings.
• Get Involved‡ – Opens your default browser at the Get Involved page of the LibreOffice
website https://www.libreoffice.org/community/get-involved/. There you can choose a
topic of interest to help improve the program.
• Donate to LibreOffice‡ – Opens your default browser at the Support LibreOffice page of
the LibreOffice website https://donate.libreoffice.org/.
• License Information – Outlines the licenses under which LibreOffice is made available.

Preface | 9
• Check for Updates‡ – Opens a dialog and checks the LibreOffice website for updates to
your version of the software.
• About LibreOffice – Opens a dialog, which displays information about the version of
LibreOffice and the operating system you are using. This information will often be
requested if you ask the community for help or assistance with the software. A button is
provided to enable you to copy this information to the clipboard so that you can
subsequently paste it into a forum post, an email, or a bug report.

Other free online support


The LibreOffice community not only develops software, but provides free, volunteer-based
support. In addition to the Help menu links above, there are other online community support
options available, see Table 1.
Table 1: Free LibreOffice support
Resource Support
Answers to frequently asked questions
FAQs
https://wiki.documentfoundation.org/Faq
Free community support is provided by a network of experienced
Mailing lists users
https://www.libreoffice.org/get-help/mailing-lists/
As in the mailing lists above, but through forum
Forum
https://community.documentfoundation.org/
Free community assistance is provided in a question and answer
Questions & Answers formatted web service. Search similar topics or open a new one in
and https://ask.libreoffice.org/c/english/5
Knowledge Base The service is available in several other languages; click on the
language button to open a dialog for language selection.
The LibreOffice website in various languages
https://www.libreoffice.org/community/nlc/
Native language Mailing lists for native languages
support https://wiki.documentfoundation.org/Local_Mailing_Lists
Information about social networking
https://wiki.documentfoundation.org/Website/Web_Sites_services
Information about available accessibility options
Accessibility options
https://www.libreoffice.org/get-help/accessibility/

Paid support and training


You can also pay for support through service contracts from a vendor or consulting firm
specializing in LibreOffice. For information about certified professional support, see The
Document Foundation’s website: https://www.documentfoundation.org/gethelp/support/.

What you see may be different


Illustrations
LibreOffice runs on Windows, Linux, and macOS operating systems, each of which has several
versions and can be customized by users (fonts, colors, themes, window managers). The
illustrations in this guide were taken from a variety of computers and operating systems.
Therefore, some illustrations will not look exactly like what you see on your computer display.

10 |Calc Guide 24.8


Also, some of the dialogs may be different because of the settings selected in LibreOffice. You
can either use dialogs from your computer’s operating system or from LibreOffice. The
differences affect mainly Open, Save, and Print dialogs. To change which dialogs are used, go to
Tools > Options > LibreOffice > General and select or deselect the option Use LibreOffice
dialogs.

Icons
The LibreOffice community has created icons for several icon sets: Breeze, Colibre, Elementary,
Karasa Jaga, Sifr, and Sukapura; some of these are also available in dark, SVG (Scalable
Vector Graphics), and SVG+dark versions. Each user can select a preferred set. The icons in
this guide have been taken from a variety of LibreOffice installations that use different sets of
icons. The icons for some of the many tools available in LibreOffice may then differ from the
ones used in this guide.
To change the icon set used, go to Tools > Options > LibreOffice > View. Choose from the
drop-down list under Icon Theme.

Note
The Galaxy, Oxygen, and Tango icon sets are no longer included as part of the
standard installation package. They can be added back by downloading and
installing the following extensions:
https://extensions.libreoffice.org/extensions/galaxy-icon-theme
https://extensions.libreoffice.org/extensions/oxygen-icon-theme
https://extensions.libreoffice.org/en/extensions/show/tango-icon-theme-for-libreoffice
Some of the previously included gallery backgrounds are now only available as an
extension from:
https://extensions.libreoffice.org/extensions/legacy-gallery-backgrounds

Using LibreOffice on macOS


Some keystrokes and menu items are different on macOS from those used in Windows and
Linux. Table 2 gives some common substitutions for the instructions in this document. For a
more detailed list, see the application Help and Appendix A, Keyboard Shortcuts, to this guide.
Table 2: Example keystrokes for different environments
Windows or Linux macOS equivalent Effect
Tools > Options on
LibreOffice > Preferences Access to setup options
Menu bar
Ctrl+click and/or right-click
Right-click Opens a context menu
depending on computer setup
⌘ and/or Cmd or Command,
Ctrl or Control Used with other keys
depending on keyboard
⌥ and/or Alt or Option
Alt Used with other keys
depending on keyboard

F11 ⌘+T Open the Styles deck in the


Sidebar

Preface | 11
What are all these things called?
The terms used in LibreOffice for most parts of the user interface (the parts of the program you
see and use, in contrast to the behind-the-scenes code that actually makes it work) are the
same as for most other programs.
A dialog is a special type of window. Its purpose is to inform you of something, or request input
from you, or both. It provides controls to use to specify how to carry out an action. The technical
names for common controls are shown in Figure 2. In most cases the technical terms are not
used in this book, but it is useful to know them because the Help and other sources of
information often use them.
In most cases, you can interact only with the dialog (not the document itself) as long as the
dialog remains open. When you close the dialog after use (usually, clicking OK or another button
saves your changes and closes the dialog), then you can again work with your document.
Some dialogs can be left open as you work, so you can switch back and forth between the
dialog and your document. An example of this type is the Find and Replace dialog.

Figure 2: Dialog showing common controls


1) Tabbed page (not strictly speaking a control).
2) Radio buttons (only one can be selected at a time).
3) Checkbox (more than one can be selected at a time).
4) Spin box (click the up and down arrows to change the number shown in the text box next
to it, or type in the text box).
5) Thumbnail or preview.
6) Drop-down list from which to select an item.
7) Push buttons.

12 |Calc Guide 24.8


Frequently asked questions
How is LibreOffice Licensed?
LibreOffice is distributed under the Open Source Initiative (OSI) approved Mozilla Public
License (MPL). See https://www.libreoffice.org/about-us/licenses/.
It is based on code from Apache OpenOffice made available under the Apache License
2.0 but also includes software that differs from version to version under a variety of other
Open Source licenses. New code is available under GNU Lesser General Public License
(LGPL) 3.0 and MPL 2.0.
May I distribute LibreOffice to anyone? May I sell it? May I use it in my business?
Yes.
How many computers may I install it on?
As many as you like.
Is LibreOffice available in my language?
LibreOffice has been translated (localized) into over 100 languages, so your language is
probably supported. Additionally, there are over 100 spelling, hyphenation, and thesaurus
dictionaries available for languages, and dialects that do not have a localized program
interface. The dictionaries are available by selecting the Dictionary tag filter from the
LibreOffice Extension Center https://extensions.libreoffice.org/ .
How can you make it for free?
LibreOffice is developed and maintained by volunteers and has the backing of several
organizations.
Why do I need Java to run LibreOffice? Is it written in Java?
LibreOffice is not written in Java; it is mostly written in the C++ language. Java is one of
several languages that can be used to extend the software. The Java JRE (Java
Runtime Environment) is only required for some features. The most notable one is the
HSQLDB relational database engine used by the Base component of LibreOffice. For
Calc, Java is needed to run some of the solver engines described in Chapter 10, Data
Analysis.
Java is available at no cost. More information and download links to the appropriate
edition for your operating system can be found at: https://openjdk.org/ .

Note
If you want to use LibreOffice features that require Java it is important that the
correct 32 bit or 64 bit edition matches the installed version of LibreOffice.
How can I contribute to LibreOffice?
You can help with the development and user support of LibreOffice in many ways, and
you do not need to be a programmer. To start, check out this webpage:
https://whatcanidoforlibreoffice.org.
May I distribute the PDF of this book, or print and sell copies?
Yes, as long as you meet the requirements of one of the licenses in the copyright
statement at the beginning of this book. You do not have to request special permission.
We request that you share with the project some of the profits you make from sales of
books, in consideration of all the work we have put into producing them.
Donate to LibreOffice: https://www.libreoffice.org/donate/.

Preface | 13
What's new in this guide
Information about the LibreOffice 24.8 Community release can be found in this announcement:
https://wiki.documentfoundation.org/ReleaseNotes/24.8
This book has been updated from Calc Guide 24.2. It covers changes that are visible in the Calc
user interface.

Changes in chapters
• Chapter 3: has been moved to Chapter 6 “Creating Charts and Graphs“ and the section
on chart type became Chapter 7 “Gallery of Charts Types”.
– Added new chart types: “Bar of Pie” and “Pie of Pie”.
• Chapter 4: is now “Styles and Templates”.
• Chapter 5: is now “Using Graphics”.
• Chapters 8 to 19 were renumbered accordingly.
– Several parts rewritten for clarity.
• Chapter 15 “Calc as a Database”: added a section on “Referencing in a Calc Database
Table”.
• Chapter 19 “Macros”:
– Removed section on JavaScript debugger, not available anymore.
– Changes in macro listings formatting.
• Appendix B: Added section on Calc error handling functions.

14 |Calc Guide 24.8


Calc Guide 24.8

Chapter 1
Introduction
Using spreadsheets in LibreOffice
What is Calc?
Calc is the spreadsheet component of LibreOffice. You can enter data (usually numerical) in a
spreadsheet and then manipulate this data to produce certain results.
Alternatively, you can enter data and then use Calc in a ‘What if...’ manner by changing some of
the data and observing the results without having to retype the entire spreadsheet or sheet.
Other features provided by Calc include:
• Functions, which can be used to create formulas to perform complex calculations on
data.
• Database functions to arrange, store, and filter data.
• Data statistics tools, to perform complex data analysis.
• Dynamic charts, including a wide range of 2D and 3D charts.
• Macros for recording and executing repetitive tasks; scripting languages supported
include LibreOffice Basic, Python, BeanShell, and JavaScript.
• Ability to open, edit, and save Microsoft Excel spreadsheets.
• Import and export of spreadsheets in multiple formats, including HTML, CSV, PDF, and
Data Interchange Format.

Note
If you want to use macros written in Microsoft Excel using the VBA macro code in
LibreOffice, you must first edit the code in the LibreOffice Basic IDE editor. For more
information, see Chapter 12, Macros, in this guide or "Getting Started with Macros",
in the Getting Started Guide.

Spreadsheets, sheets, and cells


Calc works with documents called spreadsheets. Spreadsheets consist of a number of individual
sheets, each sheet containing cells arranged in rows and columns. A particular cell is identified
by its row number and column letter.
Cells hold the individual elements – text, numbers, formulas, and so on – that make up the data
to display and manipulate.
Each spreadsheet can have up to 10,000 sheets and each sheet can have a maximum of
1,048,576 rows and 16,384 columns.

Calc main window


When Calc is started, the main window opens (Figure 3). The various parts of this display are
explained below.

Note
By default, Calc’s commands are grouped in menus and toolbars, as described in
this section. In addition, Calc provides other user interface variations, displaying
contextual groups of commands and contents. For more information, see
Chapter 17, User Interface Variants.

16 |Calc Guide 24.8


Note
If any part of the Calc window in Figure 3 is not shown, you can display it using the
View menu. For example, View > Status Bar on the Menu bar will toggle (show or
hide) the Status Bar. It is not always necessary to display all of the parts shown; you
can show or hide any of them as desired.

Figure 3: Calc main window

Title bar
The Title bar, located at the top, shows the name of the current spreadsheet. When the
spreadsheet is newly created, its name is Untitled X, where X is a number. When you save a
spreadsheet for the first time, you are prompted to enter a name of your choice.

Menu bar
Under the Title bar is the Menu bar. When you choose one of the menus, a list of options
appears. You can also modify the Menu bar, as explained in Chapter 16, Setting up and
Customizing.
• File – contains commands that apply to the entire document, such as Open, Save,
Wizards, Export as PDF, Print, Digital Signatures, Templates.
• Edit – contains commands for editing the document, such as Undo, Copy, Find and
Replace, Track Changes.
• View – contains commands for modifying how the Calc user interface looks, such as
Toolbars, View Headers, Full Screen, Zoom.
• Insert – contains commands for inserting elements into a spreadsheet, such as Image,
Chart, Text Box, Headers and Footers.
• Format – contains commands for modifying the layout of a spreadsheet, such as Cells,
Page Style, AutoFormat Styles, Align Text.

Chapter 1 Introduction | 17
• Styles – contains options for applying and managing styles, such as Heading 1,
Footnote, Manage Styles.
• Sheet – contains commands for inserting and deleting elements and modifying the entire
sheet, such as Delete Rows, Insert Sheet, Rename Sheet, Navigate.
• Data – contains commands for manipulating data in your spreadsheet, such as Define
Range, Sort, AutoFilter, Consolidate, Statistics.
• Tools – contains functions to help check and customize a spreadsheet, for example
Spelling, Share Spreadsheet, Macros, Options.
• Window – contains two commands; New Window and Close Window. Also shows all
open windows in other LibreOffice applications.
• Help – contains links to LibreOffice Help (included with the software), User Guides,
and other miscellaneous functions; for example Restart in Safe Mode, License
Information, Check for Updates, About LibreOffice.
The scope of the Menu bar can be daunting for some people and even experienced users can
forget where to look for rarely used functions. To quickly locate and run a command in the Menu
bar, select Help > Search Commands or press Shift+Esc. Calc displays the dialog shown in
Figure 4.

Figure 4: Search Commands dialog


In the above example the pop-up is used to search for the available recalculate options, which
appear in the lower area as soon as the letters “Reca” are typed in the upper area. The required
option is run by clicking on it, or by using the arrow buttons on the keyboard to move through the
options and then pressing the Enter key.

Toolbars
The default setting when Calc opens is for the Standard and Formatting toolbars to be docked at
the top of the workspace (Figure 3).
Calc toolbars can be either docked (fixed in place), or floating, allowing you to move a toolbar to
a more convenient location on your workspace. Docked toolbars can be undocked and moved to
a different docked location or become floating toolbars. Likewise, floating toolbars can be
docked.
The initial default is for all displayed toolbars to be locked in their docked positions. An individual
toolbar can be unlocked, when a vertical handle is displayed at its left edge, and this handle can
be used to drag the toolbar to a new screen position. To lock / unlock all toolbars at once, select
View > Toolbars > Lock Toolbars (LibreOffice must be restarted to apply this change).
You can choose the single-toolbar alternative to the default double toolbar arrangement. It
contains the most-used commands. To activate it, enable View > User Interface > Single
Toolbar. Other variations are also available through View > User Interface.
For additional information on toolbars, see the Getting Started Guide.
The default set of icons (sometimes called buttons) on toolbars provides a wide range of
common commands and functions. You can also remove or add icons to toolbars. See
Chapter 16, Setting up and Customizing, for more information.

18 |Calc Guide 24.8


Placing the mouse pointer over an icon, text box, or menu command, displays a small box called
a tooltip that shows the name of the item’s function. To close a tooltip, move away from the
underlying component or press the Esc key.
To see a more detailed explanation of an icon, text box, or menu command, turn extended tips
on or off. To do this go to Tools > Options > LibreOffice > General on the Menu bar and toggle
the Extended tips checkbox.

Formula Bar
The Formula Bar is located at the top of the Calc workspace. It is permanently docked in this
position and cannot be used as a floating toolbar. However, it can be hidden or made visible by
going to View > Formula Bar on the Menu bar.

Figure 5: Formula Bar


From left to right in Figure 5, the Formula Bar consists of the following:
• Name Box – gives the current active cell reference using a combination of a letter and
number, for example A1. The letter indicates the column and the number indicates the
row of the selected cell. If you have selected a range of cells that is also a named range,
the name of the range is shown in this box. You can also type a cell reference in the
Name Box to jump to the referenced cell. If you type the name of a named range and
press the Enter key, the named range is selected and displayed.
• Function Wizard – opens a dialog from which you can search through lists of available
functions and formulas. This can be very useful because it also shows how the functions
are formatted.
• Select Function – performs a calculation on the numbers in the cells above the selected
cell and then places the result in it. If there are no numbers above the selected cell, then
the calculation operates on the cells to the left. The calculation to be performed is
selected from a drop-down menu containing options for Sum, Average, Min, Max,
Count, CountA, Product, Stdev, StdevP, Var, and VarP.

Tip
The Alt+= keyboard shortcut is equivalent to clicking the Select Function icon and
selecting the Sum option.
• Formula – inserts an equals (=) sign in the selected cell and the Input line, allowing a
formula to be entered.
• Input line – displays the contents of the selected cell (data, formula, or function) and
allows you to edit the cell contents. To turn the Input line into a multi-line input area for
very long formulas, click the Expand Formula Bar icon on the right or Click and drag
between the Formula Bar and top of the Column Headers (when mouse pointer turns into
a double arrow) to extend downwards. To edit inside the Input line area, click in the area,
then type your changes. The height of the formula bar will be saved in your document.
You can also directly edit inside the cell by double-clicking on the cell. When you enter new data
into a cell, the Select Function and Formula icons change to Cancel and Accept icons.

Note
In a spreadsheet, the term “function” covers much more than just mathematical
functions. See Chapter 9, Using Formulas and Functions, for more information.

Chapter 1 Introduction | 19
Status Bar
The Status Bar at the bottom of the workspace (Figure 6) provides information about the
spreadsheet and convenient ways to quickly change some of its features. Most of the fields are
similar to those in other components of LibreOffice. See the Getting Started Guide for more
information.

Figure 6: Status Bar


1) Unsaved changes 6) Selection mode
2) Sheet number 7) Digital signature
3) Cell selection information 8) Cell or object information
4) Page style 9) Zoom slider
5) Language 10) Zoom percentage
The fields on the Status Bar, from left to right, are as follows.
Unsaved changes
The appearance of this icon indicates whether the spreadsheet contains unsaved
changes. When there are unsaved changes, click this icon, use File > Save, click the
Save icon on the Standard toolbar, or press Ctrl+S to save the spreadsheet.
Sheet number
Shows the sequence number of the current sheet and the total number of sheets in the
spreadsheet. The sequence number may not be the same as the name on the sheet tab
if sheets have been moved. Double-click on this zone to open the Navigator dialog.
Cell selection information
Shows how many rows and how many columns are selected. Blank if the selected cells
do not form a rectangular block.
Page style
Shows the page style of the current sheet. To edit the page style, double-click on this
field and the Page Style dialog opens.
Language
Shows current default language as selected at Tools > Options > Languages and
Locales > General.
Insert / overwrite mode
When you are interacting with a cell in edit mode, this field distinguishes between the
insert and overwrite modes. If the cell being edited is in overwrite mode, the field shows
the text Overwrite. In other cases, the field is blank. You can press the Insert key on
the keyboard, or click on this field, to switch between insert and overwrite modes.
Selection mode
Click to open a context menu and select Standard selection, Extending selection, or
Adding selection. The icon changes when different selection modes are selected. See
the Getting Started Guide for more information.

20 |Calc Guide 24.8


Digital signature
If the document has been digitally signed, an icon shows here. You can click the icon to
view the certificate. See Chapter 8, Printing, Exporting, E-mailing, and Signing for more
information about digital signatures.
Cell or object information
Displays information related to the position of the cursor or the selected element of the
spreadsheet. When a group of cells is selected, the average and sum of the contents is
displayed by default. Right-click in this field to select other functions, such as the
maximum value, minimum value, or count (number of items selected).
Zoom slider
Drag the zoom slider, click on the slider’s rail, or click the + and – symbols to change the
view magnification.
Zoom percentage
Indicates the magnification level of the document. Right-click on the percentage to open
a list of magnification values from which to choose. Click on the percentage to open the
Zoom & View Layout dialog.

Sidebar
The Sidebar (Figure 7) is a mixture of toolbar and dialog. When opened (View > Sidebar or
Ctrl+F5), it appears on the right side of the window. When entering or editing data in cells, the
Sidebar consists of five decks: Properties, Styles, Gallery, Navigator, and Functions. Each deck
has a corresponding icon on the Tab panel to the right of the Sidebar, allowing you to switch
between them. These decks are described below. However, the Sidebar is context-sensitive and
the number of decks and the content of each may change when you select objects such as
images or charts.
Properties
The Properties deck includes five content panels. Each panel has a More Options
button that provides additional options. If a dialog opens, it locks the document for editing
until it is closed.
Style: Options for applying, updating, or creating cell and page styles.
Character: Options for formatting the text, such as font name, size, and color. Some
controls, such as superscript, only become active when the text cursor is active in the
Input line of the Formula Bar or the cell. A font is temporarily applied on selected cells
when hovering or navigating in the Font Name drop-down list.
Number Format: Options for formatting numbers, including decimals, currency, dates, or
numeric text.
Alignment: Options for arranging the text in various ways, including horizontal and
vertical alignment, wrapping, indenting, merging, text orientation, and vertical stacking.
Cell Appearance: Options include background color and border formats, including line
color and style.

Chapter 1 Introduction | 21
Figure 7: Sidebar
Styles
The Styles deck enables you to apply existing styles, modify existing styles, or create
new styles. This deck can also be opened by selecting Styles > Manage Styles on the
Menu bar, selecting View > Styles on the Menu bar, or pressing F11.
Gallery
The Gallery deck enables you to add images, diagrams, or other objects that are
available in the Gallery themes. This deck can also be opened by selecting View >
Gallery on the Menu bar.
Navigator
The Navigator deck can also be opened by selecting View > Navigator from the Menu
bar or pressing F5. See “Using the Navigator” on page 43.
Functions
The Functions deck contains a list of Calc’s many functions organized by category. It is a
simpler version of the Function Wizard, which is opened by selecting Insert > Function
on the Menu bar, clicking the Function Wizard icon on the Formula Bar, or pressing
Ctrl+F2.

22 |Calc Guide 24.8


To the right side of the title bar of each open deck is a Close Sidebar Deck button, which closes
the deck to leave only the Tab bar of the Sidebar open. Click any button in the Tab bar to toggle
on / off the display of the associated deck.
To hide the Sidebar, or reveal it if already hidden, click on the left edge Hide/Show button. To
adjust the deck width, drag on the left edge of the Sidebar.

Spreadsheet layout
Individual cells
The main section of the screen displays the cells in the form of a grid, with each cell located at
the intersection of a column and a row.
At the top of the columns and the left end of the rows are a series of header boxes containing
letters and numbers. The column headers use alphabetic characters that start with A and
increase to the right. The row headers use numerical characters that start at 1 and increase
down.
These column and row headers form the cell references that appear in the Name Box on the
Formula Bar (Figure 5). If the headers are not visible on the spreadsheet, go to View > View
Headers on the Menu bar.
When the mouse pointer lies over the grid of cells, the system default pointer is normally shown
(typically an arrow pointer). However, a configuration option is available to switch to using the
pointer shape defined in the icon theme (typically a fat cross). See Chapter 16, Setting up and
Customizing for more information.
The active cell is always indicated by highlighting its corresponding column and row header
cells. An option is available to highlight the entire row and column of the active cell using a
transparent color (Figure 8). This is enabled/disabled using the Tools > Options > LibreOffice
Calc > View > Column/Row highlighting and View Column/Row Highlighting options.

Figure 8: Column and row highlighting

Sheet tabs
A spreadsheet file can contain many individual sheets. At the bottom of the grid of cells in a
spreadsheet are sheet tabs (Figure 3). Each tab represents a sheet in a spreadsheet. You can
create a new sheet by clicking on the plus sign to the left of the sheet tabs or by clicking in the
blank space to the right of the sheet tabs.
Clicking on a tab makes an individual sheet active. When a sheet is active, the tab is highlighted.
To select multiple sheets, hold down the Ctrl key while clicking on the sheet tabs.

Chapter 1 Introduction | 23
To change the default name for a sheet (Sheet1, Sheet2, and so on):
1) Right-click on the sheet tab and select Rename Sheet in the context menu. In the dialog
that opens, type in a new name for the sheet.
2) Click OK when finished to close the dialog.
To change the color of a sheet tab:
1) Right-click on the sheet tab and select Tab Color in the context menu to open the Tab
Color dialog (Figure 9).

Figure 9: Tab Color dialog


2) Select a color and click OK when finished to apply the color and close the dialog.
To add new colors to this color palette, see “Adding custom colors” in Chapter 16, Setting up and
Customizing.

Creating, opening, and saving spreadsheets


Creating and opening
Creating and opening spreadsheets is identical to creating and opening documents in the other
LibreOffice modules. For more information on creating and opening spreadsheets, see Getting
Started Guide.

Using templates
Calc documents can also be created from templates. For information on how to create and use
templates, see Chapter 4, Using Styles and Templates, in this guide.

Opening a CSV file


Comma-separated values (CSV) files are spreadsheet files in a text format where cell contents
are separated by a character such as a comma or semi-colon. Each line in a CSV text file
represents a row in a spreadsheet. Text is entered between quotation marks; numbers are
entered without quotation marks.
To open a CSV file in Calc:
1) Choose File > Open on the Menu bar, click the Open icon on the Standard toolbar, or
press Ctrl+O and locate the CSV file that you want to open.

24 |Calc Guide 24.8


2) Select the file and click Open. By default, a CSV file has the extension .csv. However,
some CSV files may have a .txt extension.
3) The Text Import dialog (Figure 10) opens. Here you can select options for importing a
CSV file into a Calc spreadsheet.
4) Click OK to open and import the file.

Figure 10: Text Import dialog


The options for importing CSV files into a Calc spreadsheet are as follows:
Import
• Character set – specifies the character set to be used in the imported file.
• Language – determines how the number strings are imported. If Language is set to
Default, Calc will use the language associated with the locale selected at Tools >
Options > Languages and Locales > General > Formats. If another language is
selected, that language will determine how numbers are treated.
• From row – specifies which row the import starts with. The initial rows are visible in the
preview window at the bottom of the dialog.
Separator Options
• Fixed width – separates data into columns by a set number of characters. Click on the
ruler that appears in the preview window to set the width.

Chapter 1 Introduction | 25
• Separated by – separates data into columns based on the separator defined here. Select
Other to specify another character used to separate data into columns. This custom
separator must also be contained in the data.
• Merge delimiters – combines consecutive delimiters and removes blank data fields.
• Trim spaces – removes starting and trailing spaces from within fields.
• String delimiter – select a character to delimit text data.

Tip
CSV files can identify the separator to use by including a first row of sep=X or
“sep=X” where X is the separator character. Set From row to 2 to import correctly.
Other options
• Format quoted field as text – when this option is enabled, fields or cells whose values
are entirely within quotes are imported as text.
• Detect special numbers – when this option is enabled, Calc will automatically detect all
number formats, including special number formats such as dates and times. Scientific
notation will also be detected as the adjacent Detect scientific notation option must be
enabled at the same time. The selected language influences how such special numbers
are detected, since different languages and regions many have different conventions for
such special numbers.

When this option is disabled, Calc will detect and convert only numbers in decimal
notation. Detection of numbers in scientific notation will depend on the adjacent Detect
scientific notation option. The rest will be imported as text. A decimal number string can
have digits 0-9, thousands separators, and a decimal separator. Thousands separators
and decimal separators may vary with the selected language and region.
• Evaluate formulas – when this option is enabled, fields that begin with an equals sign (=)
will be imported and evaluated as a formula instead of as data.
• Detect scientific notation – when this option is enabled, Calc will automatically detect
numbers with scientific notation, such as “5E2” for 500. The selected language
influences how scientific notation is detected, since different languages and regions
many have different decimal separator.

This option can be disabled only if the Detect special numbers option is disabled. When
this option is disabled, Calc will detect and convert only numbers in decimal notation and
the remainder will be imported as text. A decimal number string can have digits 0-9,
thousands separators, and a decimal separator. Thousands separators and decimal
separators may vary with the selected language and region.
Fields – shows how your data will look when it is separated into columns.
Column type – select a column in the preview window and select the data type to be
applied to the imported data.
– Standard – Calc determines the type of data.
– Text – imported data are treated as text.
– Date – imported data are treated as dates in the selected format – “DMY”, “MDY”, or
“YMD”.
– US English – numbers formatted in US English are searched for and included
regardless of the system language. A number format is not applied. If there are no US
English entries, the Standard format is applied.

26 |Calc Guide 24.8


– Hide – the data in the column are not imported.

Saving spreadsheets
For information on how to save files manually or automatically, see the Getting Started Guide.
Calc can save spreadsheets in a range of formats and also export spreadsheets to PDF and
XHTML file formats; see Chapter 8, Printing, Exporting, Emailing, and Signing, for more
information.

Saving in other formats


If you need to send files to users who are unable to receive spreadsheet files in Open Document
Format (ODF) (*.ods), which Calc uses as its default format, you can save a spreadsheet in
another format.
1) Select File > Save As on the Menu bar, click the down arrow at the right of the Save icon
on the Standard toolbar and select Save As from the drop-down menu, or press
Ctrl+Shift+S to open the Save As dialog (Figure 11).
2) In File name, if you wish, enter a new file name for the spreadsheet and select the folder
where you want to save the file.
3) In the Save as type field, select from the drop-down menu the type of spreadsheet format
you want to use. If Automatic file name extension is selected, the correct file extension
for the spreadsheet format you have selected will be added to the file name.
4) Click Save.

Figure 11: The Save As dialog


Each time a file is saved in a format other than ODF format, the Confirm File Format dialog
opens (Figure 12). Click Use [xxx] Format to continue saving in the selected spreadsheet
format or click Use ODF Format to save the spreadsheet in Calc’s default format. If you disable
Warn when not saving in ODF or default format on Tools > Options > Load/Save > General
on the Menu bar, the Confirm File Format dialog will no longer appear. You can also clear the
checkbox Ask when not saving in ODF or default format on the dialog to stop the dialog
appearing.

Chapter 1 Introduction | 27
Figure 12: Confirm File Format dialog
If you select Text CSV format (*.csv), the Export Text File dialog (Figure 13) opens. Here you can
select the character set, field delimiter, string delimiter, and so on to be used for the CSV file.

Note
Once you have saved a spreadsheet in another format, all changes you make to the
spreadsheet will now occur only in the format you are using because you have
changed the name and file type of your document. If you want to go back to working
with an *.ods version, you must save the file as an *.ods file.

Figure 13: Export Text File dialog

Tip
To have Calc save documents by default in a file format other than the default ODF
format, go to Tools > Options > Load/Save > General. In the section named
Default File Format and ODF Settings, next to Document type, select Spreadsheet,
then next to Always save as, select your preferred file format, for example one of the
available Microsoft Excel options.

Password protection
To protect a spreadsheet and restrict who can open, read, and make changes to it, you have to
use password protection. Password protection is common to all LibreOffice modules; for more
information, see the Getting Started Guide.

28 |Calc Guide 24.8


Navigating within spreadsheets
Calc provides many ways to navigate within a spreadsheet from cell to cell and sheet to sheet.
You can generally use the method you prefer.

Cell navigation
When a cell is selected or in focus, the cell borders are emphasized. When a group of cells is
selected, the cell area is colored. The color of the cell border emphasis and the color of a group
of selected cells depends on the operating system being used and uses your system’s highlight
color.
• Using the mouse – place the mouse pointer over the cell and click the left mouse button.
To move the focus to another cell using the mouse, move the mouse pointer to the cell
and click the left mouse button.
• Using a cell reference – select or delete the existing cell reference in the Name Box on
the Formula Bar (Figure 5 on page 19). Type the reference of the cell you want to move
to and press the Enter key. Cell references are case insensitive. Thus, typing a3 or A3
will move the focus to cell A3.
• Using the Navigator – to open the Navigator (Figure 24), go to View > Navigator on the
Menu bar, or press F5, or click the Navigator button on the Sidebar. Type the cell
references into the Column and Row fields and press the Enter key.
• Using the Enter key – pressing Enter moves the cell focus down one cell (by default).
You can change the direction of this focus movement as described in the “Customizing
the Enter key” section on page 32.
• Pressing Shift+Enter moves the focus one cell in the opposite direction to that
associated with the Enter key.
• Using the Tab key – pressing Tab moves the cell focus one cell to the right. Pressing
Shift+Tab moves the focus one cell to the left.
• Using the arrow keys – pressing the arrow keys on the keyboard moves the cell focus in
the direction of the arrow pressed.
• Using Home, End, Page Up, and Page Down
– Home moves the cell focus to the start of a row. Ctrl+Home moves the cell focus to the
first cell in the sheet, A1.
– The result of pressing End or Ctrl+End depends on the data contained in the sheet.
To explain these key presses, it is helpful to define Rmax as the highest numbered row
in the sheet that contains any data and Cmax as the rightmost column in the sheet that
contains any data. Press End to move the cell focus along the current row to the cell in
column Cmax. Press Ctrl+End to move the cell focus to the cell at the intersection of
row Rmax and column Cmax. Note that in either case, the newly focused cell may not
contain any data.
– Page Down moves the cell focus down one complete screen display.
– Page Up moves the cell focus up one complete screen display.

Chapter 1 Introduction | 29
Sheet navigation
Each sheet in a spreadsheet is independent of the other sheets, though references can be
linked from one sheet to another. There are four ways to navigate between different sheets in a
spreadsheet.
• Using the Navigator – when the Navigator is open (Figure 24), double-clicking on any of
the listed sheets selects the sheet.
• Using the keyboard – using key combinations Ctrl+Page Down moves one sheet to the
right and Ctrl+Page Up moves one sheet to the left. Ctrl+Tab is equivalent to
Ctrl+Page Down, while Ctrl+Shift+Tab is equivalent to Ctrl+Page Up. These
interactions operate in a cyclic manner. For example, if currently on the first sheet tab,
then Ctrl+Page Up moves to the last sheet tab.
• Using the mouse – clicking on one of the sheet tabs at the bottom of the spreadsheet
selects that sheet.
• Using the menu – go to Sheet > Navigate > To Previous Sheet / To Next Sheet to
navigate to previous or next sheet. These interaction operate in the same cyclic manner
as described above for their equivalent keyboard shortcuts. Sheet > Navigate > Go to
Sheet brings up a dialog box that allows you to select a sheet or to search for a sheet by
name.
If there are many sheets in the spreadsheet, some of the sheet tabs may be hidden. If this is the
case, use the four buttons to the left of the sheet tabs to move the tabs into view (Figure 14).

Note
The sheet tab arrows that appear on the left in Figure 14 are only active if there are
more sheet tabs than can be displayed.

Figure 14: Navigating sheet tabs

Note
When you insert a new sheet into a spreadsheet, Calc automatically uses the next
number in the numeric sequence as a name. Depending on which sheet is open
when you insert a new sheet, your new sheet may not be in numerical order. It is
recommended to rename sheets in a spreadsheet to make them more recognizable.

30 |Calc Guide 24.8


Tip
You can customize the prefix word “Sheet” for new sheets in your document by
entering a new word in Tools > Options > LibreOffice Calc > Defaults > Prefix
name for new worksheets.

Keyboard navigation
You can navigate a spreadsheet using the keyboard, by pressing a key or a combination of keys
at the same time. For example, Ctrl+Home moves the focus to cell A1. Table 3 lists the keys and
key combinations you can use for spreadsheet navigation in Calc.
Table 3. Keyboard cell navigation
Keyboard shortcut Cell navigation
→ or← Moves cell focus right or left one cell.
↑or↓ Moves cell focus up or down one cell.
Ctrl+→ or Ctrl+← If focus is on a blank cell, Ctrl+→ moves focus along the current
row to the first cell on the right that contains data. If there is no cell
on the right containing data, it moves focus along the current row to
the last cell at the right of the sheet.
If focus is on a blank cell, Ctrl+← moves focus along the current
row to the first cell on the left that contains data. If there is no cell
on the left containing data, it moves focus along the current row to
the cell in column A of the sheet.
If focus is on a cell containing data, Ctrl+→ normally moves focus
along the current row to the cell at the right edge of the same data
region. However, if there is a blank cell to the right of the original
cell, focus is moved to the cell at the left edge of the next data
region to the right. In this case, if there is no data region to the right,
focus is moved along the current row to the last cell at the right of
the sheet.
If focus is on a cell containing data, Ctrl+← normally moves focus
along the current row to the cell at the left edge of the same data
region. However, if there is a blank cell to the left of the original cell,
focus is moved to the cell at the right edge of the next data region to
the left. In this case, if there is no data region to the left, focus is
moved along the current row to the cell in column A of the sheet.

Chapter 1 Introduction | 31
Keyboard shortcut Cell navigation
Ctrl+↑ or Ctrl+↓ If focus is on a blank cell, Ctrl+↑ moves focus up the current
column to the first cell that contains data. If there is no cell above
containing data, it moves focus up the current column to the cell in
row 1 of the sheet.
If focus is on a blank cell, Ctrl+↓ moves focus down the current
column to the first cell that contains data. If there is no cell below
containing data, it moves focus down the current column to the last
cell at the bottom of the sheet.
If focus is on a cell containing data, Ctrl+↑ normally moves focus
up the current column to the cell at the top edge of the same data
region. However, if there is a blank cell above the original cell, focus
is moved to the cell at the bottom edge of the next data region
above. In this case, if there is no data region above, focus is moved
up the current column to the cell in row 1 of the sheet.
If focus is on a cell containing data, Ctrl+↓ normally moves focus
down the current column to the cell at the bottom edge of the same
data region. However, if there is a blank cell below the original cell,
focus is moved to the cell at the top edge of the next data region
below. In this case, if there is no data region below, focus is moved
down the current column to the bottom of the sheet.
Ctrl+Home or Moves focus to the top left cell of the sheet (usually cell A1) or
Ctrl+End moves focus to the last used cell in sheet (usually in the bottom
right of the sheet).
Alt+Page Down or
Alt+Page Up Moves focus one screen to the right or left (if possible).

Ctrl+Page Down or Moves focus to the next sheet to the right or left in sheet tabs.
Ctrl+Tab or These interactions operate in a cyclic manner. For example, if
Ctrl+Page Up or currently on the first sheet tab, then Ctrl+Page Up moves to the
Ctrl+Shift+Tab last sheet tab.
Tab or Shift+Tab Moves focus to the next cell on the right or left.
Enter or Moves focus down/up one cell (unless you have changed this
Shift+Enter action, as described in the following subsection).

Customizing the Enter key


You can choose the direction in which the Enter key moves the cell focus by going to Tools >
Options > LibreOffice Calc > General. Use the first three options under Input Settings (Figure
15) to change the Enter key settings. Select the direction cell focus moves from the drop-down
list. Depending on the file being used or the type of data being entered, setting a different
direction can be useful. The Enter key can also be used to switch into and out of editing mode.
In Calc, when the content of a cell is copied to the clipboard, you can paste the information in
another cell by pressing the Enter key; here you can disable this feature.

32 |Calc Guide 24.8


Figure 15: Customizing the Enter key

Selecting items in a spreadsheet


Selecting cells
Single cell
Click in the cell. You can verify the selection by looking in the Name Box on the Formula Bar
(Figure 5).

Range of contiguous cells


A range of cells can be selected using the keyboard or the mouse.
To select a range of cells by dragging the mouse pointer:
1) Click in a cell.
2) Press and hold down the left mouse button.
3) Move the mouse to highlight the desired block of cells, then release the left mouse
button.
To select a range of cells without dragging the mouse:
1) Click in the cell which is to be one corner of the range of cells.
2) Move the mouse to the opposite corner of the range of cells.
3) Hold down the Shift key and click.
To select a range of cells using Extending selection mode:
1) Click in the cell which is to be one corner of the range of cells.
2) Click in the Selection mode field on the Status Bar (Figure 6 on page 20) and select
Extending selection.
3) Click in the cell in the opposite corner of the range of cells.

Chapter 1 Introduction | 33
Tip
Make sure to change back to Standard selection mode or you may find yourself
extending a cell selection unintentionally.
To select a range of cells without using the mouse:
1) Select the cell that will be one of the corners in the range of cells.
2) While holding down the Shift key, use the cursor arrows to select the rest of the range.
To select a range of cells using the Name Box:
1) Click in the Name Box on the Formula Bar (Figure 5 on page 19).
2) Enter the cell reference for the upper left-hand cell, followed by a colon (:), and then the
lower right-hand cell reference, then press the Enter key. For example, to select the
range that would go from A3 to C6, enter A3:C6.

Range of non-contiguous cells


To select a range of non-contiguous cells using the mouse:
1) Select the first cell or range of cells using one of the methods above.
2) Move the mouse pointer to the start of the next range or single cell.
3) Hold down the Ctrl key and click or click-and-drag to select another range of cells to
add to the first range.
4) Repeat as necessary.
To select a range of cells using Adding selection mode:
1) Click in the Selection mode field on the Status Bar (Figure 6 on page 20) and select
Adding selection.
2) Click or click-and-drag to select ranges of cells to add to the selection.

Selecting columns and rows


Single column or row
To select a single column, click on the column header (Figure 3 on page 17). To select a single
row, click on the row header.

Multiple columns or rows


To select multiple columns or rows that are contiguous:
1) Click on the first column or row in the group.
2) Hold down the Shift key.
3) Click the last column or row in the group.
To select multiple columns or rows that are not contiguous:
1) Click on the first column or row in the group.
2) Hold down the Ctrl key.
3) Click on all of the subsequent columns or rows while holding down the Ctrl key.

34 |Calc Guide 24.8


Tip
You can also select rows and columns using options in the Edit > Select menu
(Select Row, Select Column, Select Visible Rows Only, and Select Visible
Columns Only).

Entire sheet
To select the entire sheet, click on the small box between the column headers and the row
headers (Figure 16), use the key combination Ctrl+A, press Ctrl+Shift+Space, or go to Edit
on the Menu bar and select Select All.

Figure 16: Select All box

Selecting sheets
You can select either one or multiple sheets in Calc. It can be advantageous to select multiple
sheets, especially when you want to make changes to many sheets at once.

Single sheet
Click on the sheet tab for the sheet you want to select. The tab for the selected sheet becomes
highlighted.

Multiple contiguous sheets


To select multiple contiguous sheets:
1) Click on the sheet tab for the first desired sheet.
2) While holding down the Shift key, click on the sheet tab for the last desired sheet.
3) All tabs between these two selections will be highlighted. Any actions that you perform
will now affect all highlighted sheets.

Multiple non-contiguous sheets


To select multiple non-contiguous sheets:
1) Click on the sheet tab for the first desired sheet.
2) While holding down the Ctrl key, click on the sheet tabs for other desired sheets.
3) The selected tabs will be highlighted. Any actions that you perform will now affect all
highlighted sheets.

All sheets
Right-click a sheet tab and choose Select All Sheets in the context menu, or select Edit >
Select > Select All Sheets on the Menu bar.

Tip
You can also select sheets using the Select Sheets dialog, accessed by selecting
Edit > Select > Select Sheets on the Menu bar.

Chapter 1 Introduction | 35
Working with columns and rows
Inserting columns and rows
When you insert columns or rows, the cells take the formatting of the corresponding cells in the
column to the left or the row above.

Single column or row


Using the Sheet menu:
1) Select a cell, column, or row where you want the new column or row inserted.
2) Go to Sheet on the Menu bar. For columns, select Sheet > Insert Columns and then
select Columns Before or Columns After. For rows, select Sheet > Insert Rows and
then select Rows Above or Rows Below.
Using the context menu:
1) Select a column or row where you want the new column or row inserted.
2) Right-click the column or row header.
3) Select Insert Columns Before / After or Insert Rows Above / Below in the context
menu.

Multiple columns or rows


Multiple columns or rows can be inserted at once rather than inserting them one at a time.
1) Highlight the required number of columns or rows by holding down the left mouse button
on the first one and then dragging across the required number of identifiers.
2) Proceed as for inserting a single column or row above. The number of columns or rows
highlighted will be inserted.

Hiding columns and rows


To hide columns or rows from view, select the columns or rows to hide and do one of the
following:
Right-click on the selected column or row headers and select Hide Columns / Rows.
From the Menu bar, select Format > Columns / Rows > Hide.

Tip
For a visible indication of hidden rows and columns, enable the option from the Menu
bar, View > Hidden Row/Column Indicator (Figure 17).

36 |Calc Guide 24.8


Figure 17: Hidden columns and rows indicator
To unhide columns or rows, select the entire sheet or the columns or rows around the columns
or rows you wish to unhide and do one of the following:
Right-click on the selected column or row headers and select Show Columns / Rows.
From the Menu bar, select Format > Columns / Rows > Show.

Deleting columns and rows


Single column or row
To delete a single column or row, do one of the following:
• Select a cell in the column or row you want to delete, right-click and select Delete in the
context menu, select Sheet > Delete Cells on the Menu bar, or press Ctrl+- to open
the Delete Cells dialog (Figure 18). Select Delete entire column(s) or Delete entire
row(s) and click OK.
• Select a cell in the column or row you want to delete and select Sheet > Delete
Columns or Sheet > Delete Rows.
• Right-click the header of the column or row that you want to delete and select Delete
Columns or Delete Rows in the context menu.

Figure 18: Delete Cells dialog

Multiple columns or rows


To delete multiple columns or rows, do one of the following:
• Select a range of cells across the columns or rows you want to delete, right-click and
select Delete in the context menu, select Sheet > Delete Cells on the Menu bar, or
press Ctrl+- to open the Delete Cells dialog. Select Delete entire column(s) or Delete
entire row(s) and click OK.
• Select a range of cells across the columns or rows you want to delete and select Sheet
> Delete Columns or Sheet > Delete Rows.

Chapter 1 Introduction | 37
• Highlight the required columns or rows by holding down the left mouse button on the
header of the first one and then dragging across the required number of headers. Then
right-click on one of the selected column or row headers and select Delete Columns or
Delete Rows in the context menu.

Deleting cells
1) Select the cell or cells you want to delete.
2) Select Sheet > Delete Cells, press Ctrl+-, or right-click on one of the selected cells
and select Delete in the context menu.
3) Select the option you require from the Delete Cells dialog and click OK.

Working with sheets


Inserting new sheets
Click on the + symbol next to the sheet tabs to insert a new sheet after the last sheet in the
spreadsheet without opening the Insert Sheet dialog. The following methods open the Insert
Sheet dialog (Figure 19) where you can position the new sheet, create more than one sheet,
name the new sheet, or select a sheet from a file.
• Select the sheet where you want to insert a new sheet, then select Sheet > Insert Sheet
on the Menu bar.
• Right-click on the sheet tab where you want to insert a new sheet and select Insert
Sheet in the context menu.
• Click in the empty space at the end of the sheet tabs.
• Right-click in the empty space at the end of the sheet tabs and select Insert Sheet from
the context menu.

Figure 19: Insert Sheet dialog

Moving and copying sheets


You can move or copy sheets within the same spreadsheet by dragging and dropping or using
the Move/Copy Sheet dialog (Figure 20). To move or copy a sheet into a different spreadsheet,
use the Move/Copy Sheet dialog.

38 |Calc Guide 24.8


Dragging and dropping
To move a sheet to a different position within the same spreadsheet, click on the sheet tab and
drag it to its new position before releasing the mouse button.
To copy a sheet within the same spreadsheet, hold down the Ctrl key then click on the sheet
tab and drag it to its new position before releasing the mouse button. The mouse pointer may
change to include a plus sign depending on the setup of your operating system.

Using Move/Copy Sheet dialog


The Move/Copy Sheet dialog allows you to specify exactly whether you want the sheet in the
same or a different spreadsheet, its position within the spreadsheet, and the sheet name when it
is moved or copied.
1) In the current document, right-click on the sheet tab you wish to move or copy and select
Move or Copy Sheet in the context menu, or go to Sheet > Move or Copy Sheet on the
Menu bar.
2) Select Move to move the sheet or Copy to copy the sheet.
3) Select the spreadsheet where you want the sheet to be placed from the To document
drop-down list. This can be the same spreadsheet, another spreadsheet that is already
opened, or you can create a new spreadsheet.
4) Select the position in Insert before where you want to place the sheet.
5) Type a name in the New name text box if you want to rename the sheet when it is moved
or copied. When copying, Calc suggests a default name (Sheet1_2, Sheet2_2, and so
on).
6) Click Move or Copy to confirm the move or copy and close the dialog.

Figure 20: Move/Copy Sheet dialog

Caution
When you move or copy to another spreadsheet or to a new one, a conflict may
occur if formulas are linked to sheets in the previous location.

Chapter 1 Introduction | 39
Deleting sheets
To delete a single sheet, right-click on the sheet tab you want to delete and select Delete Sheet
in the context menu, or go to Sheet > Delete Sheet on the Menu bar. If the sheet is not empty,
then Calc displays a confirmation dialog – click Yes to confirm the deletion.
To delete multiple sheets, select the sheets (see “Selecting sheets” on page 35), then right-click
one of the sheet tabs and select Delete Sheet in the context menu, or go to Sheet > Delete
Sheet on the Menu bar. If any of the selected sheets is not empty, then Calc displays a
confirmation dialog stating the number of sheets to be deleted – click Yes to confirm the deletion.

Hiding and showing sheets


Sometimes you may want to hide the contents of a sheet to preserve data from accidental
editing or because its contents are not important to display.
To hide a sheet or many sheets, select the sheet or sheets as above, right-click to open the
context menu, and select Hide Sheet.
To show hidden sheets, right-click any sheet tab and select Show Sheet in the context menu. A
dialog will open with all hidden sheets listed. Select the desired sheets and then click OK.

Note
LibreOffice Calc does not let you hide the last visible sheet.

Renaming sheets
By default, the name for each new sheet added is SheetX, where X is the number of the next
sheet to be added. While this works for a spreadsheet with only a few sheets, it can become
difficult to identify sheets when a spreadsheet contains many sheets.
You can rename a sheet using one of the following methods:
• Enter the name in the Name text box when you create the sheet using the Insert Sheet
dialog (Figure 19 on page 38).
• Right-click on a sheet tab and select Rename Sheet in the context menu to open the
Rename Sheet dialog
• Select Sheet > Rename Sheet on the Menu bar to access the Rename Sheet dialog.
• Double-click on a sheet tab to open the Rename Sheet dialog.

Note
Sheet names can contain almost any character. Some naming restrictions apply, the
following characters are not allowed in sheet names: colon (:), back slash (\), forward
slash (/), question mark (?), asterisk (*), left square bracket ([), or right square
bracket (]). In addition a single quote (‘) cannot be used as the first or last character
of the name.

Viewing a spreadsheet
Changing document view
Use the zoom function to show more or fewer cells in the window when you are working on a
spreadsheet. For more about zoom, see the Getting Started Guide.

40 |Calc Guide 24.8


Freezing rows and columns
Freezing is used to lock rows across the top of a spreadsheet or to lock columns on the left of a
spreadsheet. Then, when moving around within a sheet, the cells in frozen rows and columns
always remain in view.
Figure 10 shows some frozen rows and columns. The heavier horizontal line between rows 3
and 23 and the heavier vertical line between columns F and Q indicate that rows 1 to 3 and
columns A to F are frozen. The rows between 3 and 23 and the columns between F and Q have
been scrolled off the page. To freeze rows or columns:
1) Click on the row header below the rows you want the freeze or click on the column
header to the right of the columns where you want the freeze. To freeze both rows and
columns, select the cell (not a row or column) that is below the row and to the right of the
column that you want to freeze. Go to View on the Menu bar and select Freeze Rows
and Columns. A heavier line appears between the rows or columns indicating where the
freeze has been placed.

Figure 21: Frozen rows and columns

Unfreezing
To unfreeze rows or columns, go to View on the Menu bar and click Freeze Rows and
Columns to toggle it off. The heavier lines indicating freezing will disappear.

Splitting the screen


Another way to change the view is by splitting the screen displayed (also known as splitting the
window). The screen can be split horizontally, vertically, or both, displaying up to four portions of
the spreadsheet at the same time. An example of splitting the screen is shown in Figure 22
where a split is indicated by a gray line.
This could be useful for example, when a large spreadsheet has one cell with a number that is
used by three formulas in other cells. Using the split-screen technique, the cell containing the
number can be positioned in one section of the view and the cells with formulas can be seen in
the other sections. This makes it easy to see how changing the number in one cell affects each
of the formulas.

Figure 22: Split screen example

Chapter 1 Introduction | 41
Splitting horizontally or vertically
There are two ways to split a screen horizontally or vertically:
Method One:
1) Click on the row header below the rows where you want to split the screen horizontally or
click on the column header to the right of the columns where you want to split the screen
vertically.
2) Go to View on the Menu bar and select Split Window or right-click and choose Split
Window in the context menu. A thick line appears between the rows or columns
indicating where the split has been placed. An example of a split line is shown below
Row 2 in Figure 22.
Method Two:
For a horizontal split, click on the thick black line at the top of the vertical scroll bar (Figure 23)
and drag the split line below the row where you want the horizontal split positioned.
Similarly, for a vertical split, click on the thick black line at the right of the horizontal scroll bar
(Figure 23) and drag the split line to the right of the column where you want the vertical split
positioned.

Figure 23: Split screen bars

Splitting both horizontally and vertically


Method One:
Position both the black horizontal and the black vertical lines as described above and as shown
in Figure 23.
Method Two:
1) Click the cell that is immediately below the rows where you want to split the screen
horizontally and immediately to the right of the columns where you want to split the
screen vertically.
2) Go to View on the Menu bar and select Split Window. Thick lines appear between the
rows and columns indicating where the splits have been placed.

Removing split views


To remove a split view, do any of the following:
• Double-click on each split line in turn.
• Click on and drag the split lines back to their places at the ends of the scroll bars.
• Go to View on the Menu bar and click Split Window to toggle it off.
• Right-click on a column or row heading and click Split Window in the context menu to
toggle it off.

42 |Calc Guide 24.8


Using the Navigator
The Navigator (Figure 24) is available in all LibreOffice modules. It provides tools and methods
to move quickly through a spreadsheet and find specific items.
The Navigator categorizes and groups spreadsheet objects which you can click on to move
quickly to that object. If an indicator (plus sign or triangle, dependent on computer setup)
appears next to a category, at least one object in this category exists. To open a category and
see the list of items, click on the indicator. When a category is showing the list of objects in it,
double-click on an object to jump directly to that object’s location in the spreadsheet.
To open the Navigator, do one of the following:
• Press the F5 key.
• Select View > Navigator on the Menu bar.
• Click the Navigator icon on the Tab panel of the Sidebar.

Figure 24: Navigator dialog in Calc


The controls and tools available in the Navigator are as follows:
• Column – type a column letter and press the Enter key to reposition the cell cursor to
the specified column in the same row.
• Row – type a row number and press the Enter key to reposition the cell cursor to the
specified row in the same column.
• Data Range – highlights the data range containing the cell in which the cursor currently
lies. Calc checks the content of adjacent cells and determines the data range
automatically. The data range can comprise one cell if there is no data in adjacent cells.
• Start – moves the cursor to the cell at the beginning of the current data range, which you
can highlight using the Data Range icon.
• End – moves the cursor to the cell at the end of the current data range, which you can
highlight using the Data Range icon.
• Contents – toggles on / off the display of the contents view in the lower part of the
Navigator dialog, to temporarily reduce its size. There is no equivalent control needed on
the Navigator deck of the Sidebar.

Chapter 1 Introduction | 43
• Toggle – toggles the contents view. Only the selected category and its objects are
displayed. Click the icon again to restore all elements for viewing.
• Scenarios – displays all available scenarios. See Chapter 11, Data Analysis, for more
information about scenarios. Double-click a name to apply that scenario and the result is
shown in the sheet. If the Navigator displays scenarios, you can access the following
commands when you right-click a scenario entry:
– Delete – deletes the selected scenario.
– Properties – opens the Edit Scenario dialog, where you can edit the scenario
properties.
• Drag Mode – opens a submenu for selecting which action is performed when dragging
and dropping an object from the Navigator into a document. Depending on the mode you
select, the icon indicates whether a hyperlink, a link, or a copy is created.
– Insert as Hyperlink – hyperlinks the entire item.
– Insert as Link – links the copied item to the original item so that when the original item
is changed, that change will be reflected in the current document.
– Insert as Copy – inserts a copy of the selected item.

Tip
Ranges, scenarios, pictures, and other objects are much easier to find if you have
given them informative names when creating them, instead of keeping the default
Calc names, for example Scenario 1, Image 1, Image 2, Object 1, and so on. These
default names may not correspond to the position of the object in the document.

Using document properties


To open the Properties dialog for a document, go to File > Properties on the Menu bar. The
Properties dialog provides information about the spreadsheet and allows you to set some of its
properties. The dialog is shown in Figure 25 and its tabs are described below.

Figure 25: Properties dialog, General tab

44 |Calc Guide 24.8


General
Contains basic information about the current file.
• The text at the top of the dialog displays the file name.
• Change Password – opens a dialog to change the password. It is only active if a
password has been set for the file.
• Type – displays the file type of the current document.
• Location – displays the path and the name of the directory where the file is stored. In
the case of a local file, this is a clickable link that opens the file browser to view the
folder. For remote content (shown as, for example, http://...), the link opens a web
browser.
• Size – displays the size of the current document in bytes.
• Created – displays the date, time, and author when the file was first opened.
• Modified – displays the date, time, and author when the file was last saved in a
LibreOffice file format.
• Template – displays the template that was used to create the file, if applicable.
• Digitally signed – displays the date and time when the file was last signed as well as
the name of the author who signed the document.
• Digital Signatures – opens the Digital Signatures dialog where you can manage digital
signatures for the current document.
• Last printed – displays the date, time, and user name when the file was last printed.
• Total editing time – displays the amount of time that the file has been open for editing
since the file was created. The editing time is updated when you save the file.
• Revision number – displays the number of times that the file has been saved.
• Apply user data – saves the full name of the user with the file. You can edit the name by
going to Tools > Options > LibreOffice > User Data on the Menu bar.
• Save preview image with this document – saves a thumbnail.png inside the
document. These images may be used by a file manager under certain conditions.
• Preferred resolution for images: Check this box to select the preferred image
resolution in points per inch, which is used as default when an image is inserted and
resize it according to the value in the list box.
• Reset Properties – resets the editing time to zero, the creation date to the current date
and time, and the version number to 1. The modification and printing dates are also
deleted.

Description
LibreOffice supports the Dublin Core Metadata Element Set, a standardized set of metadata
elements used to describe physical and electronic documents.
• Title – enter a title for the spreadsheet.
• Subject – enter a subject for the spreadsheet. You can use a subject to group
documents with similar content.
• Keywords – enter the words that you want to use to index the content of the
spreadsheet. Keywords must be separated by commas. A keyword can contain white
space characters or semicolons.

Chapter 1 Introduction | 45
• Contributor – enter the name of a person or organization that has contributed to the
spreadsheet.
• Coverage – enter details of the scope of the spreadsheet.
• Identifier – enter a reference that identifies the spreadsheet.
• Publisher – enter the name of a person or organization that makes the spreadsheet
available.
• Relation – enter details of a related resource.
• Rights – enter details of any rights that are held in or over the spreadsheet.
• Source – enter details of any related resource that has been used in deriving the
spreadsheet.
• Type – enter the nature or type of the spreadsheet.
• Comments – enter comments to help identify the spreadsheet.

Custom Properties
Use this page to assign custom information fields to the spreadsheet. In a new spreadsheet, this
page may be blank. If the new spreadsheet is based on a template, this page may contain fields.
You can change the name, type, and contents of each row. The information in the fields will be
exported as metadata to other file formats.
Click Add Property to add a new custom property. Use the red “X” button at the end of an entry
to delete the custom property.

Security
Enables two password-protected security options.
• Open file read-only – select to allow this document to be opened only in read-only
mode. This file sharing option protects the document against accidental changes. It is still
possible to edit a copy of the document and save that copy with the same name as the
original.
• Record changes – select to require that all changes be recorded. To protect the
recording state with a password, click Protect and enter a password. This is similar to
Edit > Track Changes > Record on the Menu bar. However, while other users of this
document can apply their changes, they cannot disable change recording without
knowing the password.
• Protect or Unprotect – protects the change recording state with a password. If change
recording is protected for the current document, the button is named Unprotect. Click
Unprotect to disable the protection.

Font
When Embed fonts in the document is selected, any fonts used in the spreadsheet will be
embedded into the document when it is saved. This may be useful if you are creating a PDF of
the spreadsheet and want to control how it will look on other computer systems.
Only embed fonts that are used in documents – If fonts have been defined for the
spreadsheet (for example, in the template), but have not been used, select this option to not
embed them.
Font scripts to embed – You can choose which types of fonts are embedded: Latin, Asian,
Complex. See the Getting Started Guide for more information.

46 |Calc Guide 24.8


Statistics
Displays statistics for the current file: the number of sheets, cells, pages, and formula groups.

Chapter 1 Introduction | 47
Calc Guide 24.8

Chapter 2
Entering and Editing Data
Introduction
You can enter data into Calc in several ways: using the keyboard, the Fill tool, and selection lists,
as well as dragging and dropping. Calc also provides the ability to enter data into multiple sheets
of the same spreadsheet at the same time.

Entering data
Most data entry in Calc can be done using the keyboard.

Numbers
Click in the cell and type the number using the number keys on either the main keyboard or the
numeric keypad.

Negative numbers
To enter a negative number, either type a minus sign in front of the number or enclose the
number in parentheses, for example (1234). The result for both methods of entry is the same; for
example, –1234.

Leading zeroes
By default, if a number is entered with leading zeroes, for example 01481, Calc will drop the
leading zeroes. To retain both the number format and a minimum number of characters in a cell
when entering numbers, for example 1234 and 0012, use one of these methods to add leading
zeroes.
Method 1
1) With the cell selected, go to Format > Cells on the Menu bar, or right-click on the cell
and select Format Cells in the context menu, or use the keyboard shortcut Ctrl+1, to
open the Format Cells dialog (Figure 26).
2) Make sure the Numbers tab is selected, then select Number in the Category list.
3) In the Leading zeroes field within the Options area, enter the minimum number of
characters required. For example, for four characters, enter 4. Any number less than four
characters will then have leading zeroes added, for example 12 becomes 0012.
4) Click OK. The number entered retains its number format and any formula used in the
spreadsheet will treat the entry as a number in formula functions.
Method 2
1) Select the cell.
2) On the Sidebar, go to the Properties deck.
3) In the Number Format panel (Figure 27), select Number in the drop-down list, and enter
4 in the Leading zeroes field. Formatting is applied immediately.

Numbers as text
Numbers can also be converted into text using one of the following methods.
Method 1
1) With the cell selected, open the Format Cells dialog (Figure 26).
2) Make sure the Numbers tab is selected, then select Text from the Category list.

50 |Calc Guide 24.8


3) Click OK. The number is converted to text and, by default, is left-aligned. You can
change the formatting and alignment of any text numbers just as you would with normal
text.

Figure 26: Format Cells dialog – Numbers tab


Method 2
1) Select the cell.
2) On the Sidebar, go to the Properties deck.
3) In the Number Format panel (Figure 27), select Text in the drop-down list. Formatting is
applied to the cell immediately.

Figure 27: Set leading zeroes in Sidebar

Tip
If numerical characters do not need to be treated as numbers in calculations (for
example when entering zip codes), you can type an apostrophe (') before the
number, for example '01481. When you move the cell focus, the apostrophe is

Chapter 2 Entering and Editing Data | 51


removed, the leading zeroes are retained, and the number is converted to left-
aligned text.

Text
Click in a cell and type the text. The text is left-aligned by default. Cells can contain several lines
of text. If you want to use paragraphs, press Ctrl+Enter to create another paragraph.
On the Formula Bar, you can extend the Input line if you are entering several lines of text. Click
on the Expand / Collapse Formula Bar icon located on the right of the Formula Bar and the
Input line becomes multi-line, as shown in Figure 28. You can drag the bottom of the Input line
up and down to control its exact height. Click the Expand / Collapse Formula Bar icon again to
return the Input line to its default single line height.

Figure 28: Expanded Input line on Formula Bar

Date and time


Select the cell and type the date or time. You can separate the date elements with a slash (/) or
a hyphen (–) or use text, for example 10 Oct 2020. The date format automatically changes to the
selected format used by Calc.

Note
Tools > Options > Languages and Locales > General > Formats > Date
acceptance patterns defines the date patterns that will be recognized by Calc. In
addition, every locale accepts input in an ISO 8601 YYYY-MM-DD pattern (for
example, 2020-07-26).
When you enter a time, separate time elements with colons, for example 10:43:45. The time
format automatically changes to the selected format used by Calc.
To change the date or time format used by Calc:
1) With the cell selected, open the Format Cells dialog (Figure 26).
2) Make sure the Numbers tab is selected, then select Date or Time in the Category list.
3) Select the date or time format you want to use from the Format list.
4) Click OK to save the changes and close the dialog.

Note
The date format will be influenced by the system or document language settings.

52 |Calc Guide 24.8


Special characters
A special character is a character not normally found on a standard keyboard; for example, © ¾
æ ç ñ ö ø ¢. To insert a special character:
1) Select a cell and place the cursor in the cell or in the Input line, at the point where you
want the character to appear.
2) Go to Insert > Special Character on the Menu bar to open the Special Characters
dialog (Figure 29).

Figure 29: Special Characters dialog


3) From the grid of characters, select the required character. The last character selected is
shown on the right of the Special Characters dialog along with its numerical code.
4) Any recently inserted characters are shown below the grid of characters and can be
selected in the same way as any other character in the dialog.
5) At the bottom of the dialog there is provision for building a small collection of Favorite
Characters. To add a new character to the collection, select the required character and
click the Add to Favorites button. To remove an existing character from the collection,
select the character and click the Remove from Favorites button.
6) Double-click a special character to insert it into the cell, without closing the dialog. Click
Insert to insert a selected special character into the cell and close the dialog.
Alternately, Windows users can use Alt+NumPad to input Unicode characters. For example,
holding the Alt key and typing 9, 5, 5 on the numeric keypad produces the Greek Small Letter
Lambda (λ) from its decimal equivalent 955. Similarly, users of other platforms may input
Unicode characters by typing a two-digit hex code and then pressing Alt+X. For example, typing
A9 and then pressing Alt+X inserts a copyright symbol (@). This method also works for
Windows users.

Chapter 2 Entering and Editing Data | 53


Tip
Clicking the More Characters button will open the full Special Characters dialog
(Figure 29).
You can quickly insert one of your recent or favorite special characters by clicking the
Insert Special Characters icon (Ω) on the Standard toolbar and selecting the
required character or character name from the drop-down.

Figure 30: Special Character dialog

Note
Different fonts include different special characters. If you do not find a particular
special character you want, try changing the Font and Subset selections.

AutoCorrect options
By default, Calc automatically applies many changes during data input using AutoCorrect. You
can undo any AutoCorrect changes by selecting Edit > Undo on the Menu bar, pressing the
keyboard shortcut Ctrl+Z, or manually going back to the change and replacing the
autocorrection with what you actually want to see.
To change the AutoCorrect options, go to Tools > AutoCorrect Options on the Menu bar to
open the AutoCorrect dialog (Figure 31).
• Replace – edit the replacement table for automatically correcting or replacing words or
abbreviations.
• Exceptions – specify the abbreviations or letter combinations that you do not want
corrected automatically.
• Options – select the options for automatically correcting errors as you type.
• Localized Options – specify the AutoCorrect options for quotation marks and for options
that are specific to the language of the text.
• Reset – reset modified values back to their previous values.

54 |Calc Guide 24.8


Figure 31: AutoCorrect dialog

Inserting dashes
Calc provides text shortcuts so that you can quickly insert dashes into a cell and these shortcuts
are shown in Table 4.
Table 4: Inserting dashes
Text that you type Result
A - B (A, space, hyphen, space, B) A – B (A, space, en-dash, space, B)
A -- B (A, space, hyphen, hyphen, space, B) A – B (A, space, en-dash, space, B)
A--B (A, hyphen, hyphen, B) A—B (A, em-dash, B)
A-B (A, hyphen, B) A-B (unchanged)
A -B (A, space, hyphen, B) A -B (unchanged)
A --B (A, space, hyphen, hyphen, B) A –B (A, space, en-dash, B)

Accelerating data entry


Calc includes built-in tools that help reduce the time required to enter data into a spreadsheet.
The tools include:
• AutoInput
• Fill Tool
• Selection Lists
• Data Entry Form Tool

Chapter 2 Entering and Editing Data | 55


Each tool is described in the sections that follow.

AutoInput tool
The AutoInput function in Calc automatically completes entries, based on other entries in the
same column.
When text is highlighted in a cell, AutoInput can be used as follows:
• Press Enter to accept the completion and move to the next cell. Press F2 to accept the
completion and move the cursor to the end of the text inside the cell. Clicking outside the
cell will accept the completion and select the clicked cell.
• When multiple matches continue with the same letters they will appear in the cell after
what has already been typed. Press → to accept the partial completion and move the
cursor to the end of the text inside the cell.
• To view more completions that start with the same letters, use the key combinations
Ctrl+Tab to scroll forward, or Ctrl+Shift+Tab to scroll backward.
• To see a list of all available AutoInput text items for the current column, use the keyboard
combination Alt+↓. See “Selection lists” on page 61 for more information.
When typing formulas using characters that match function names, a Help tip will appear listing
the available functions that start with matching characters.
AutoInput ignores the case sensitivity of any data you enter. If, for example, you have written
“Total” in a cell, you cannot then use AutoInput to enter “total” in another cell of the same column
without first deactivating AutoInput or entering “total” manually.
By default, AutoInput is activated in Calc. To turn it off, go to Tools on the Menu bar and deselect
AutoInput.

Fill tool
You can use the Fill tool in Calc to duplicate existing content or create a series in a range of cells
in the spreadsheet as shown by the examples in Figure 32.
1) Select the cell containing the contents you want to copy or start the series from.
2) Drag the mouse pointer in any direction or hold down the Shift key and click in the last
cell you want to fill.
3) Go to Sheet > Fill Cells on the Menu bar and select the direction in which you want to
copy or create data (Down, Right, Up, Left, Sheets, Series, or Random Number). A
menu option will be grayed out if it is not available.

Figure 32: Examples of using the Fill tool

56 |Calc Guide 24.8


Tip
You can use the keyboard shortcut Ctrl+D as an alternative to selecting Sheet > Fill
Cells > Fill Down on the Menu bar.
Alternatively, you can use a shortcut to fill cells:
1) Select the cell containing the contents you want to copy or start the series from.
2) Move the pointer over the small selection handle in the bottom right corner of the
selected cell. The pointer will change shape.
3) Click and drag in the direction you want the cells to be filled, vertical or horizontal. If the
original cell contained text, then the text will automatically be copied. If the original cell
contained a number or text from a defined list (see “Defining a fill series” on page 58), a
series will be created. To duplicate the number or text instead, hold Ctrl while dragging.

Caution
When you are selecting cells so you can use the Fill tool, make sure that none of the
cells contain data, except for the cell data you want to use. When you use the Fill
tool, any data contained in selected cells is overwritten.

Using a fill series


When you select a series fill from Sheet > Fill Cells > Fill Series on the Menu bar, the Fill
Series dialog (Figure 33) opens. Here you can select the type of series you want or create your
own list.
• Direction – determines the direction of series creation.
– Down – creates a downward series in the selected cell range for the column using the
defined increment to the end value.
– Right – creates a series running from left to right within the selected cell range using
the defined increment to the end value.
– Up – creates an upward series in the selected cell range of the column using the
defined increment to the end value.
– Left – creates a series running from right to left within the selected cell range using the
defined increment to the end value.

Figure 33: Fill Series dialog

Chapter 2 Entering and Editing Data | 57


• Series Type – defines the series type. These are:
– Linear – creates a linear number series using the defined increment and end value.
– Growth – creates a growth series using the defined increment and end value.
– Date – creates a date series using the defined increment and end date.
– AutoFill – forms a series directly in the sheet. The AutoFill function takes account of
customized lists. For example, by entering January in the first cell, the series is
completed using the list defined in Tools > Options > LibreOffice Calc > Sort Lists.
AutoFill tries to complete a value series by using a defined pattern. For example, a
numerical series using 1,3,5 is automatically completed with 7,9,11,13; a date and time
series using 01.01.99 and 15.01.99, is completed using an interval of fourteen days.
• Time Unit – in this area you specify the desired unit of time. This area is only active if
the Date option has been selected in Series Type. The options are:
– Day – creates a series using seven days.
– Weekday – creates a series of five day sets.
– Month – creates a series from the names or abbreviations of the months.
– Year – creates a series of years.
• Start value – determines the start value for the series. Use numbers, dates, or times.
• End value – determines the end value for the series. Use numbers, dates, or times.
• Increment – determines the value by which the series of the selected type increases by
each step. Entries can only be made if the linear, growth, or date series types have been
selected.

Defining a fill series


To define your own fill series:
1) Go to Tools > Options > LibreOffice Calc > Sort Lists to open the Sort Lists dialog
(Figure 34). This dialog shows any previously defined series in the Lists box on the left
and the contents of the highlighted list in the Entries box.
2) Click New and the Entries box is cleared.
3) Type the series for the new list in the Entries box, with one entry per line (Figure 35).
4) Click Add and the new list will now appear in the Lists box.
5) Click OK to save the new list and close the dialog.

58 |Calc Guide 24.8


Figure 34: Sort Lists dialog

Figure 35: Creating a new sort list

Fill with random numbers


Populate a cell range with automatically generated pseudo-random numbers using the selected
distribution function and its specified parameters.
When you select a random number fill from Sheet > Fill Cells > Fill Random Number on the
Menu bar, the Random Number Generator dialog (Figure 36) opens. Here you can select the
type of random numbers you want.

Chapter 2 Entering and Editing Data | 59


Figure 36: Random Number Generator dialog
Cell Range
Define the range of cells to fill with random numbers. If you have previously selected a
range, it will be displayed here.
Distribution
Select the distribution function for the random number generator. Available distributions
are Uniform, Uniform Integer, Normal, Cauchy, Bernoulli, Binomial, Chi Squared,
Geometric, Negative Binomial, and Poisson.
Distribution parameters
Fields directly below Distribution enable entry of parameters related to the selected
distribution, as follows:
– Uniform and Uniform Integer. Specify minimum and maximum values.
– Normal. Specify mean and standard deviation.
– Cauchy. Specify median and sigma.
– Bernoulli and Geometric. Specify p-value.
– Binomial and Negative Binomial. Specify p-value and number of trials.
– Chi Squared. Specify degrees of freedom (nu).
– Poisson. Specify mean.
Enable custom seed
Set a value to initiate the random number generator algorithm. It is used to initialize
(seed) the random number generator in order to reproduce the same sequence of
pseudo-random numbers. Specify a positive integer to produce a specific sequence.
Enable rounding
Round the generated numbers to the given number of decimal places.

60 |Calc Guide 24.8


Selection lists
Selection lists are available only for text and are limited to using only text that has already been
entered in the same column.
1) Select a blank cell in a column that contains cells with text entries.
2) Right-click and select Selection List in the context menu, or use the keyboard shortcut
Alt+↓. A drop-down list appears listing any cell in the same column that either has at
least one text character or whose format is defined as text.
3) Click on the text entry you require and it is entered into the selected cell.

Data Entry Form tool


The Data Entry Form tool makes table data entry easier in spreadsheets, accelerating intensive
manual input. Using the tool you can enter, edit, and delete data records (or rows) and avoid
horizontal scrolling when the table has many columns or when some columns are very wide.
To be effective, the data table should have a header row, where the content of each cell is the
title of the column. The content of each header cell becomes the label for each data field in the
form.
To use the Data Entry Form tool:
1) Select a header or data cell within the table of data.
2) Go to Data > Form on the Menu bar.
3) Calc displays the Data Form dialog (Figure 37), showing the data for the first entry in the
data table.
4) Add, edit, or remove entries from the data table as required.
5) Click the Close button to close the dialog.

Figure 37: Using the Data Entry Form tool


The Data Form dialog provides a text entry field for displaying, editing, or entering the value of
each cell within one row of the data table. In addition, the dialog provides the following options:
• New – Fill the record (table row cells) using the content of form fields and jump to the
next record, or add a new record at the bottom of the table. Alternatively press the Enter
key to add new or updated data to the data table.

Chapter 2 Entering and Editing Data | 61


• Delete – Deletes the current record.
• Restore – When a form field is edited, restore the record contents to its initial state.
• Previous Record – Move to the previous record.
• Next Record – Move to the next record.
• Close – Close the form.

Tip
Use the Tab and Shift+Tab keys to jump forward and backward between text boxes
of the Data Form dialog. In addition, you can use the form’s scroll bar to move
between records.

Tip
Move to the last record before entering a new record, otherwise the current record
will be edited.

Merging and splitting cells


Merging
You can select contiguous cells and merge them into one as follows:
1) Select the range of contiguous cells you want to merge.
2) Go to Format > Merge Cells > Merge Cells or Merge and Center Cells on the Menu
bar, or click on the Merge and Center Cells icon on the Formatting toolbar, or right-click
on the selected cells and select Merge Cells in the context menu. Using Merge and
Center Cells will center align any contents in the cells.
3) If the cells contain any data, the Merge Cells dialog (Figure 38) opens, showing choices
for moving or hiding data in the hidden cells.
4) Make your selection and click OK.

Figure 38: Merge choices for non-empty cells

Caution
Merging cells can lead to calculation errors in formulas used in the spreadsheet.

62 |Calc Guide 24.8


Splitting
You can reverse a merge operation by splitting a cell that was previously created by merging
several cells.
1) Select a merged cell.
2) Go to Format > Merge Cells > Split Cells on the Menu bar, or click on the Merge and
Center Cells icon on the Formatting toolbar, or right-click and select Split Cells in the
context menu.
3) Any data in the cell will remain in the first cell. If the hidden cells did have any contents
before the cells were merged, then you may have to manually move the contents to the
correct cell.

Sharing content between sheets


You might want to enter the same information in the same cell on multiple sheets, for example to
set up standard listings for a group of individuals or organizations. Instead of entering
information on each sheet individually, you can enter it in several sheets at the same time.

Figure 39: Select Sheets dialog


4) Go to Edit > Select > Select Sheets on the Menu bar to open the Select Sheets dialog
(Figure 39).
5) Select the individual sheets where you want the information to be repeated.
6) Click OK to select the sheets and the sheet tabs will be highlighted.
7) Enter the information in the cells on the sheet where you want the information to first
appear and the information will be repeated in the selected sheets.
8) Deselect the sheets when you have finished entering the information that you want
repeated in the sheets.

Tip
You can select sheets with the mouse, as described in the “Selecting sheets” section
of Chapter 1, Introduction.

Chapter 2 Entering and Editing Data | 63


Caution
This technique automatically overwrites, without any warning, any information that is
already in the cells on the selected sheets. Make sure you deselect the additional
sheets when you have finished entering the information to be repeated before
continuing to enter data into the spreadsheet.

Validating cell contents


When creating spreadsheets for other people to use, you may want to make sure they enter data
that is valid or appropriate for the cell. You can also use validation in your own work as a guide
to entering data that is either complex or rarely used.
Fill series and selection lists can handle some types of data, but are limited to predefined
information. For example, a cell may require a date or a whole number with no alphabetic
characters or decimal points, or a cell may not be left empty.
Depending on how validation is set up, it can also define the range of contents that can be
entered, and provide help messages explaining the content rules set up for the cell and what
users should do when they enter invalid content. You can also set the cell to refuse invalid
content, accept it with a warning, or start a macro when an error is entered.

Defining validation
To validate any new data entered into a cell:
1) Select a cell and go to Data > Validity on the Menu bar to open the Validity dialog
(Figure 40).

Figure 40: Validity dialog – Criteria tab


2) Define the type of contents that can be entered in that cell using the options given on the
tabbed pages for Criteria, Input Help, and Error Alert. The options are explained below.

Criteria options
Specify the validation rules for the selected cells using the Criteria tab of the Validity dialog as
shown in Figure 40. For example, you can define criteria such as numbers between 1 and 10, or
texts that are no more than 20 characters.

64 |Calc Guide 24.8


The options available on the Criteria tab will depend on what has been selected in the Allow
drop-down list.
• Allow – select a validation option for the selected cells from the drop-down list.
– All values – no limitation.
– Whole Numbers – only whole numbers allowed.
– Decimal – all numbers correspond to decimal format.
– Date – all numbers correspond to date format. The entered values are formatted the
next time the dialog is called up.
– Time – all numbers correspond to time format. The entered values are formatted the
next time the dialog is called up.
– Cell range – allow only values that are given in a cell range. The cell range can be
specified explicitly, or as a named database range, or as a named range. The range
may consist of one column or one row of cells. If you specify a range of columns and
rows, only the first column is used.
– List – allow only values or strings specified in a list. Strings and values can be mixed.
Numbers evaluate to their value, so if you enter the number 1 in the list, the entry
100% is also valid.
– Text length – allow entries whose length matches the condition on the number of
characters that has been set.
– Custom – allow entries that correspond to a formula entered in the Formula box.
• Allow empty cells – in conjunction with Tools > Detective > Mark Invalid Data, this
defines that blank cells are shown as invalid data (disabled) or not shown (enabled).
• Show selection list – shows a list of all valid strings or values to select from. The list
can be opened either by clicking the down arrow at the right of the cell, or by selecting
the cell and pressing Alt+↓.
• Sort entries ascending – sorts the selection list in ascending order and filters duplicates
from the list. If not checked, the order from the data source is taken.
• Source – enter the cell range that contains the valid values or text.
• Entries – enter the entries that will be valid values or text strings.
• Data – select the comparative operator that you want to use from the drop-down list. The
available operators depend on what you have selected in the Data drop-down list. For
example, if you select valid range, the Minimum and Maximum input boxes replace the
Value box.
• Value – enter the value for the data validation option that you selected in the Data drop-
down list.
• Minimum – enter the minimum value for the data validation option that you selected in
the Data drop-down list.
• Maximum – enter the maximum value for the data validation option that you selected in
the Data drop-down list.
• Formula – enter a formula that can be interpreted as true (non-zero) or false (zero) to
provide a custom validation. For example, assuming cell A4 was selected before opening
the dialog, you could enter ISEVEN(A4) to indicate that only even values should be
entered in cell A4.

Chapter 2 Entering and Editing Data | 65


Input Help options
Enter the message to be displayed when the cell or cell range is selected in the spreadsheet
(Figure 41).

Figure 41: Validity dialog – Input Help tab


• Show input help when cell is selected – displays the message that you enter in the
Title and Input help boxes when the cell or cell range is selected in the sheet. If you enter
text in the Title and Input help boxes and then deselect this option, the text will not be
displayed.
• Title – enter the title to be displayed when the cell or cell range is selected.
• Input help – enter the message to be displayed when the cell or cell range is selected.

Error Alert options


Define the error message that is displayed when invalid data is entered in a cell (Figure 42).
• Show error message when invalid values are entered – when selected, displays the
error message that you enter in the Contents area when invalid data is entered in a cell.
• Action – select the action that you want to occur when invalid data is entered in a cell.
– Stop – rejects the invalid entry and displays a dialog that you have to close by clicking
OK.
– Warning and Information – displays a dialog that can be closed by clicking OK or
Cancel. The invalid entry is only rejected when you click Cancel.
– Macro – activates the Browse button to open the Macro Selector dialog where you
can select a macro that is executed when invalid data is entered in a cell. The macro is
executed after the error message is displayed.
• Title – enter the title of the macro or the error message that you want to display when
invalid data is entered in a cell.
• Error message – enter the message that you want to display when invalid data is
entered in a cell.

66 |Calc Guide 24.8


Figure 42: Validity dialog – Error Alert tab

Calc Detective
The Detective is a tool within Calc that you can use to locate any cells in a spreadsheet that
contain invalid data if the cells are set to accept invalid data with a warning.
1) Go to Tools > Detective > Mark Invalid Data on the Menu bar to locate any cells
containing invalid data. The Detective function marks any cells containing invalid data.
2) Correct the data so that it becomes valid.
3) Go to Tools > Detective > Remove All Traces on the Menu bar and any cells that were
previously marked as containing invalid data have the invalid data mark removed.

Note
A validity rule is considered part of the format for a cell. If you select Delete all on the
Delete Contents dialog (Figure 44), then it is removed. If you want to copy a validity
rule with the rest of the cell, use Edit > Paste Special > Paste Special to open the
Paste Special dialog (Figure 45), then select Paste all or Formats and click OK.

Modifying data
Deleting data
Deleting cell data only
Data can be deleted from a cell without deleting any of the cell formatting. Select a cell or a
range of cells and then press the Delete key.

Deleting cells
This option completely deletes selected cells, columns, or rows. The cells below or to the right of
the deleted cells will fill the space.
1) Select a cell or a range of cells.
2) Select Sheet > Delete Cells on the Menu bar, or right-click inside the selected cells and
choose Delete in the context menu, or press the Ctrl+– keys.

Chapter 2 Entering and Editing Data | 67


Figure 43: Delete Cells dialog
3) The Delete Cells dialog (Figure 43) provides four options to specify how sheets are
displayed after deleting cells:
– Shift cells up. Fills the resulting space with data from the cells underneath.
– Shift cells left. Fills the resulting space with data from the cells to the right of the
deleted cells.
– Delete entire row(s). After selecting at least one cell, deletes the entire row from the
sheet.
– Delete entire column(s). After selecting at least one cell, deletes the entire column
from the sheet.
4) To confirm the selection, click OK.

Note
The selected delete option is stored and reloaded when the dialog is next opened,
until LibreOffice is closed. After opening LibreOffice again the delete option contains
the default setting.

Deleting data and formatting


Data and cell formatting can be deleted from a cell at the same time. To do this:
1) Select a cell or a range of cells.
2) Select Sheet > Clear Cells on the Menu bar, or right-click inside the selected cells and
choose Clear Contents from the context menu, or press the Backspace key.
3) In the Delete Contents dialog (Figure 44), choose any of the options or choose Delete
All. Click OK.

Figure 44: Delete Contents dialog

68 |Calc Guide 24.8


Replacing data
To completely replace data in a cell and insert new data, select the cell and type in the new data.
The new data will replace the data already contained in the cell and will retain the original
formatting used in the cell.
Alternatively, click in the Input line on the Formula Bar, then double-click on the data to highlight
it completely and type the new data.

Editing data
Sometimes it is necessary to edit the contents of a cell without removing all of the data from the
cell. For example, changing the phrase “Sales in Qtr. 2” to “Sales rose in Qtr” can be done as
follows.

Using the keyboard


To edit data with the keyboard:
1) Click in the cell to select it.
2) Press the F2 key and the cursor is placed at the end of the cell.
3) Press the Backspace key to delete any data up to the point where you want to enter new
data.
4) Alternatively, use the keyboard arrow keys to reposition the cursor where you want to
start entering the new data in the cell, then press the Delete key or Backspace key to
delete any unwanted data before typing the new data.
5) When you have finished editing, press the Enter key to save the changes.

Tip
Each time you select a cell, the contents are displayed in the Input line on the
Formula Bar. Using the Input line may be easier when editing data.

Using the mouse


1) Double-click on the cell to select it and place the cursor in the cell for editing.
2) Reposition the cursor to where you want to start editing the data in the cell.
3) Alternatively, single-click to select the cell, then move the cursor to the Input line on the
Formula Bar and click at the position where you want to start editing the data in the cell.
4) When you have finished, click away from the cell to deselect it and the editing changes
are saved.

Paste Special function


You can use the Paste Special function to paste into another cell selected parts of the data in the
original cell or cell range, for example its format or the result of its formula.

Paste Special dialog


1) Select a cell or a cell range.
2) Go to Edit > Copy on the Menu bar, or click the Copy icon on the Standard toolbar, or
right-click and select Copy in the context menu, or press Ctrl+C.
3) Select the target cell or cell range.

Chapter 2 Entering and Editing Data | 69


4) Go to Edit > Paste Special > Paste Special on the Menu bar, or right-click and select
Paste Special > Paste Special in the context menu, or use the keyboard shortcut
Ctrl+Shift+V, to open the Paste Special dialog (Figure 45).
5) Select the options for Paste, Operations, Options, and Shift Cells. The Paste Special
options are explained below.
6) Click OK to paste the data into the target cell or range of cells and close the dialog.

Figure 45: Paste Special dialog

Tip
Instead of steps 5) and 6) above, you can choose one of the four preset options at
the left of the dialog – Values Only, Values & Formats, Formats Only, or
Transpose All. With the Run immediately checkbox ticked, clicking one of these
shortcut buttons actions the requested paste operation and closes the dialog.

Paste Special options


• Paste – select a format for the clipboard contents that you want to paste.
– All – pastes all cell contents, comments, formats, and objects into the current
document.
– Numbers – pastes cells containing numbers.
– Text – pastes cells containing text.
– Date & time – pastes cells containing date and time values.
– Formats – pastes cell format attributes.
– Comments – pastes comments that are attached to cells. If you want to add the
comments to the existing cell content, select the Add operation.
– Objects – pastes objects contained within the selected cell range. These can be OLE
objects, chart objects, or drawing objects.
– Formulas – pastes cells containing formulas.

70 |Calc Guide 24.8


• Operations – select the operation to apply when you paste cells into the sheet.
– None – does not apply an operation when you insert the cell range from the clipboard.
The contents of the clipboard will replace existing cell contents.
– Add – adds the values in the clipboard cells to the values in the target cells. Also, if the
clipboard only contains comments, adds the comments to the target cells.
– Subtract – subtracts the values in the clipboard cells from the values in the target cells.
– Multiply – multiplies the values in the clipboard cells with the values in the target cells.
– Divide – divides the values in the target cells by the values in the clipboard cells.
• Options – sets the paste options for the clipboard contents.
– As Link – inserts the cell range as a link, so that changes made to the cells in the
source file are updated in the target file. To ensure that changes made to empty cells
in the source file are updated in the target file, ensure that All is also selected in the
Paste area. You can also link sheets within the same spreadsheet. When you link to
other files, a DDE link is automatically created. A DDE link is inserted as a matrix
formula and can only be modified as a whole.
– Transpose – pastes the rows of the range in the clipboard as columns of the output
range, and the columns of the range in the clipboard as rows.
– Skip empty cells – does not replace target cells with empty cells from the clipboard. If
you use this option in conjunction with the Multiply or the Divide operation, the
operation is not applied to the target cell of an empty cell in the clipboard. If you select
a mathematical operation and deselect Skip empty cells, empty cells in the clipboard
are treated as zeroes. For example, if you apply the Multiply operation, the target cells
are filled with zeroes.
• Shift Cells – set the shift options for the target cells when the clipboard content is
inserted.
– Don't shift – replaces target cells with inserted cells.
– Down – shifts target cells downward when you insert cells from the clipboard.
– Right – shifts target cells to the right when you insert cells from the clipboard.

Paste Only options


If you only want to copy text, numbers, or formulas to the target cell or cell range:
1) Select the source cell or cell range and copy the data.
2) Select the target cell or cell range.
3) Right-click on the target cell or cell range and select Paste Special in the context menu,
then select Text, Number, or Formula.
4) Alternatively, use the Paste Only Text, Paste Only Numbers, or Paste Only Formula
options in the Edit > Paste Special menu on the Menu bar.

Insert cell fields


You can insert a field linked to the date, sheet name, or document name in a cell.
1) Select a cell and double-click to activate edit mode.
2) Right-click and select Insert Field > Date, Time, Sheet Name or Document Title in the
context menu.
3) Alternatively use the similar options in the Insert > Field menu on the Menu bar.

Chapter 2 Entering and Editing Data | 71


Note
The Insert Field > Document Title command inserts the name of the spreadsheet
and not the title defined on the Description tab of the Properties dialog for the file.

Tip
The fields are refreshed when the spreadsheet is saved or recalculated when using
the Ctrl+Shift+F9 shortcut.

Group and outline


Rows or columns may be grouped together so that the cells may be hidden or shown using a
single click.
The plus (+) or minus (-) controls on the group indicator are used to show or hide rows or
columns. However, if there are groups nested within each other, the basic controls have
numbered buttons so you can hide the different levels of nested groups.

Grouping
To group rows or columns:
1) Select the cells you want to group in the spreadsheet.
2) Go to Data > Group and Outline > Group on the Menu bar, or press the F12 key.
3) On the Group dialog that opens, select either Rows or Columns and click OK. A group
indicator appears to the left of any rows grouped or above any columns grouped. Figure
46 shows a group indicator on the left of the first two rows of the spreadsheet showing
that they have been grouped.

Figure 46: Group indicator

Hiding details
To hide the details of any group of rows or columns:
1) Click on the minus (–) sign on the group indicator.
2) Alternatively, select a cell within the group and go to Data > Group and Outline > Hide
Details on the Menu bar.
3) The rows or columns are hidden and the minus (–) sign becomes a plus (+) sign on the
group indicator.

Showing details
To show the details of any hidden groups of rows or columns:
1) Click on the plus (+) sign on the group indicator.
2) Alternatively, select a cell on each side of the hidden group and go to Data > Group and
Outline > Show Details on the Menu bar.

72 |Calc Guide 24.8


3) The hidden rows or columns are displayed and the plus (+) sign becomes a minus (–)
sign on the group indicator.

Ungrouping
To ungroup any groups of rows or columns:
1) Make sure the grouped rows or columns are displayed and click on a cell within the
group.
2) Go to Data > Group and Outline > Ungroup on the Menu bar, or use the keyboard
combination Ctrl+F12.
3) If only rows or only columns are grouped, they are ungrouped. If both rows and columns
are grouped, select either Rows or Columns on the Ungroup dialog and click OK.

Caution
Any hidden groups of rows or columns must be displayed. If they are hidden, then
the grouped rows or columns are deleted from the spreadsheet.

Note
If there are nested groups, only the last group of rows or columns created is
ungrouped.

AutoOutline
If a selected cell range contains formulas or references, Calc can automatically outline the
selection. For example, in Figure 47 the cells for the 1st and 2nd quarters each contain a sum
formula for the three cells to their left. If you apply the AutoOutline command, the columns are
grouped into two quarters.
To apply the AutoOutline function, go to Data > Group and Outline > AutoOutline on the Menu
bar. Calc will then check for cells that contain formulas or references and automatically group the
cells as necessary.

Figure 47: Example of AutoOutline

Removing
To remove any cell groups of rows or columns, go to Data > Group and Outline > Remove
Outline on the Menu bar and any groups are removed.
For any cell group of rows or columns that are hidden, the grouping is removed from the cells
and the cells are displayed in the spreadsheet.

Chapter 2 Entering and Editing Data | 73


Filtering
A filter is a list of conditions that each entry has to meet to be displayed. Calc provides three
types of filters:
• Standard – specifies the logical conditions to filter the data.
• AutoFilter – filters data according to a specific value or string. Automatically filters the
selected cell range and creates one-row list boxes where you can choose the items that
you want to display.
• Advanced – uses filter criteria from specified cells.

Applying a standard filter


A standard filter is more complex than the AutoFilter. You can set as many as eight conditions as
a filter, combining them with the operators AND or OR. Standard filters are mostly useful for
numbers, although a few of the conditional operators can also be used for text.
1) Select a cell range in the spreadsheet.
2) Go to Data > More Filters > Standard Filter on the Menu bar to open the Standard
Filter dialog (Figure 48).
3) Specify the filter criteria and filtering options that you want to use.
4) Click OK to carry out standard filtering and close the dialog. Any records that match the
filter criteria and options that you specified are shown.

Figure 48: Standard Filter dialog


Use the Standard Filter dialog to define the filter conditions to be combined to form the overall
filter criteria. Each filter condition is specified by indicating the type of logical operator, the name
of a field, a logical condition, and a value.
• Operator – for the following arguments, you can choose between the logical operators
AND and OR. No logical operator is specified for the first filter condition in the list.
• Field name – specifies the field names from the current table to set them in the
argument. You will see the column identifiers if no text is available for the field names.

74 |Calc Guide 24.8


• Condition – specifies the comparative operators through which the entries in the Field
name and Value fields can be linked.
• Value – specifies a value to filter the field. The Value list box contains all possible values
for the specified Field name. Select a value to be used in the filter, including Empty and
Not Empty entries.
• Remove – deletes the associated filter criterion from the Filter Criteria area.
• Case sensitive – distinguishes between uppercase and lowercase letters when filtering
the data.
• Range contains column labels – includes the column labels in the first row of a cell
range.
• Copy results to – select the check box and then select the cell range where you want to
display the filter results. You can also select a named range from the list.
• Regular expressions – select to use regular expressions in the filter definition. If
selected, you can use regular expressions in the Value field of the Standard Filter dialog
if the Condition field is set to “=” (equal) or “<>” (not equal). For more information about
regular expressions, see the section entitled “Searching and filtering with regular
expressions” later in this chapter.
• No duplications – excludes duplicate rows from the list of filtered data.
• Keep filter criteria – select Copy results to and then specify the destination range
where you want to display the filtered data. If this box is checked, the destination range
remains linked to the source range. You must have defined the source range under Data
> Define Range as a database range. You can also reapply the defined filter at any time
by clicking into the source range and then going to Data > Refresh Range.

Applying an AutoFilter
An AutoFilter adds a drop-down list to the top row of one or more data columns which lets you
select the rows to be displayed. The list includes every unique entry in the selected cells sorted
into lexical order (see https://www.dictionary.com/browse/lexical-order for an explanation of
lexical order). AutoFilter can be used on multiple sheets without first defining a database range.
1) Click in a cell range on the spreadsheet. If you want to apply multiple AutoFilters to the
same sheet, you must first define database ranges, then apply the AutoFilters to the
database ranges.
2) Go to Data > AutoFilter on the Menu bar, click the AutoFilter icon on the Standard
toolbar, or press Ctrl+Shift+L. An arrow button is added to the head of each column in
the database range and the size of these buttons scales according to the sheet’s zoom
level.
3) Click the arrow or small triangle in the column that contains the value or string that you
want to set as the filter criteria (shown in Figure 49).
4) Select one or more values or enter a string to be used as the filter criteria in the Search
items box. After clicking OK only the records matching the filter criteria will be visible.
Rows affected by the AutoFilter will have their numbers displayed in blue. Columns
where filtering conditions were created will display the arrow button in blue.

Chapter 2 Entering and Editing Data | 75


Figure 49: AutoFilter example

Filtering by color
You can filter data by the background or font colors used in the cells of a column of interest.
• The AutoFilter drop-down provides a Filter by Color menu containing an entry for each
background color used. In the example shown in Figure 50, the menu provides three
entries indicating that some cells have a light green background, others have a yellow
background, and the remainder have no background color set (“No Fill”).
• The Filter by Color menu on the AutoFilter drop-down also contains an entry for each
font color used. In the example shown in Figure 50, the menu provides three entries
indicating that some cells have a black font, others have a blue font, and the remainder
have a red font. In this case there are no cells that utilize the automatically assigned font
(“Automatic”). The colors presented in this menu include those assigned through custom
number format codes.

Note
It is not possible to filter by a combination of different colors.

76 |Calc Guide 24.8


Figure 50: Filtering by font and background colors

Filtering by condition
The AutoFilter drop-down provides a Filter by Condition menu containing five entries:
• Empty. Filter data to show only rows with empty cells in the relevant column.
• Not Empty. Filter data to show only rows with non-empty cells in the relevant column.
• Top 10. Displays the ten rows of the cell range that contain the largest values in the cells
of the current column. If these values are unique then no more than ten rows will be
visible, but if the values are not unique then it is possible for more than ten rows to be
shown.
• Bottom 10. Displays the ten rows of the cell range that contain the smallest values in the
cells of the current column. If these values are unique then no more than ten rows will be
visible, but if the values are not unique then it is possible for more than ten rows to be
shown.
• Standard Filter. Displays the Standard Filter dialog (see Figure 48).

Chapter 2 Entering and Editing Data | 77


Figure 51: Filtering by condition

Applying an advanced filter


An advanced filter has a structure similar to a standard filter. The difference is that the advanced
filter arguments are not entered in a dialog. Instead, filters can be entered in a blank area of a
spreadsheet, then referenced by the filter dialog to apply the filters.
1) Select a cell range in the spreadsheet.
2) Go to Data > More Filters > Advanced Filter on the Menu bar to open the Advanced
Filter dialog (Figure 52).
3) In Read Filter Criteria From, select the named range, or enter the cell range that contains
the filter criteria that you want to use.
4) Click OK to carry out advanced filtering and close the dialog. Any records that match the
filter criteria and options that you specified are shown.

Figure 52: Advanced Filter dialog

78 |Calc Guide 24.8


Note
The options for advanced filtering are the same as those used for standard filtering,
see “Applying a standard filter” on page 74 for more information.
For an example of an advanced filter, see the Help page entitled “Filter: Applying Advanced
Filters”.

Sorting records
Sorting within Calc arranges the cells in a sheet using the sort criteria that you specify. Several
criteria can be used and a sort applies each criteria consecutively. Sorts are useful when you are
searching for a particular item and become even more useful after you have filtered data.
Also, sorting is useful when you add new information to a spreadsheet. When a spreadsheet is
long, it is usually easier to add new information at the bottom of the sheet, rather than adding
rows in their correct place. After you have added information, you can then sort the records to
update the spreadsheet.

Sort dialog
To sort cells in a spreadsheet using the Sort dialog:
1) Select the cells, rows, or columns to be sorted.
2) Go to Data > Sort on the Menu bar, or click the Sort icon on the Standard toolbar, to
open the Sort dialog.
3) On the Options tab (Figure 53), choose options including whether to sort on rows or
columns. See “Sort options” on page 80 for details.
4) On the Sort Criteria tab (Figure 54), select the criteria in the drop-down lists. The
selection lists are populated from the selected cells.
5) Select either Ascending order (A-Z, 0-9) or Descending order (Z-A, 9-0).
6) Headers – omits the first column/row in the selection from the sort.
7) Direction – select Top to bottom (sort rows) to sort rows by the values in the active
columns of the selected range or select Left to right (sort columns) to sort columns by
the values in the active rows of the selected range.
8) Click OK and the sort is carried out on the spreadsheet.

Note
If any of the cells that you select for sorting are protected and the sheet is protected,
then Calc cannot modify those cells and the sort will not be executed. An error
message will be displayed to indicate that protected cells cannot be modified.
However, it is possible to sort a range containing a row of column labels that are
protected, since these are not modified by the sort.

Chapter 2 Entering and Editing Data | 79


Figure 53: Sort dialog – Options tab

Figure 54: Sort dialog – Sort Criteria tab

Sort options
On the Options tab of the Sort dialog (Figure 53), you can set these options:
• Case sensitive – sorts first by uppercase letters and then by lowercase letters. For
Asian languages, special handling applies.

Note
For Asian languages, select Case sensitive to apply multi-level collation. With multi-
level collation, entries are first compared in their primitive forms with their cases and
diacritics ignored. If they evaluate as the same, their diacritics are taken into account
for the second-level comparison. If they still evaluate as the same, their cases,
character widths, and Japanese Kana difference are considered for the third-level
comparison.

80 |Calc Guide 24.8


• Include formats – preserves the current cell formatting.
• Enable natural sort – natural sorting is an algorithm that sorts string-prefixed numbers
based on the value of the numerical element in each sorted number, instead of the
traditional way of sorting them as ordinary strings. For instance, assume you have a
series of values such as, A1, A2, A3, A4, A5, A6, ..., A19, A20, A21. When you put these
values into a range of cells and run the sort, it will become A1, A11, A12, A13, ..., A19,
A2, A20, A21, A3, A4, A5, ..., A9. With natural sorting selected, values such as these are
sorted correctly.
• Include boundary column(s) containing only comments – keeps these cells
associated with the cells being sorted.
• Include boundary column(s) containing only images – keeps these cells associated
with the cells being sorted.
• Copy sort results to – copies the sorted list to the cell range that you specify. Select a
named cell range where you want to display the sorted list, or enter a cell range in the
input box.
• Custom sort order – select this option and then select the custom sort order that you
want to apply. The available selections are defined as “fill series” in Tools > Options >
LibreOffice Calc > Sort Lists. See “Defining a fill series” on page 58.
• Language – select the language for the sorting rules.
• Options – select a sorting option for the language. For many languages this selection is
grayed out but for some languages options are available. For example, for German the
default choice is Alphanumeric, but you can also select the Phone book option to
include the umlaut special character in the sorting.

Quick sort
If the columns in the spreadsheet have a header with a text format, you can use a quick sort.
1) Select a cell or a cell range to be sorted.
2) Select Data > Sort Ascending or Data > Sort Descending on the Menu bar, or click the
Sort Ascending or Sort Descending icon on the Standard toolbar.
If your data table has an AutoFilter applied, then you can quickly sort using the Sort Ascending,
Sort Descending, and the Sort by Color menu options on the AutoFilter drop-down (Figure 55).
Using the Sort by Color menu, you can sort data by the background or font colors used in the
cells of a column of interest. The color selected in this menu appears at the top of the sorted list.
The options provided in the Sort by Color menu are similar to those in the Filter by Color menu
of the AutoFilter drop-down (see Figure 50) and it is not possible to sort by a combination of
different colors.

Chapter 2 Entering and Editing Data | 81


Figure 55: AutoFilter sort by color options

Find and replace


Calc has two ways to find text within a document: the Find toolbar and the Find and Replace
dialog. The toolbar is quick and easy to use, but its functions are more limited than using the
dialog.

Find toolbar

Figure 56: Find toolbar


3) Go to View > Toolbars > Find or Edit > Find on the Menu bar, or use the keyboard
shortcut Ctrl+F, to open the Find toolbar (Figure 56). By default this toolbar is docked in
the lower left of the Calc window. You can undock the toolbar and move it.
4) Type a search term in the Find text box.
5) To refine the search, you can select the Match Case option. For example, if Owner is the
search term, selecting Match Case will find Owner but not owner. You can also select
the Find All or Formatted Display options.
6) Click the Find Next or Find Previous icon. To find other occurrences of the same term,
continue clicking the icon.

Find and Replace dialog


To open the Find and Replace dialog (Figure 57), go to Edit > Find and Replace on the Menu
bar, or click the Find and Replace icon on the Standard toolbar or the Find toolbar, or use the
keyboard shortcut Ctrl+H.

82 |Calc Guide 24.8


Finding
1) In the Find and Replace dialog enter the search criteria in the Find box.
2) Select basic options from those located directly under the Find box.
3) If necessary, click on Other options to increase the number of search filters.
4) Click Find Next to locate the first instance of the search criteria.
5) Click Find Next again to locate the next instance of the search criteria. Repeat as
needed.
6) Or, click Find All to locate all cells containing the search criteria. These cells will be
highlighted in the spreadsheet. A Search Results dialog will pop up, listing the cell
locations.

Replacing
1) In the Find and Replace dialog enter the search criteria in the Find box.
2) Select basic options from those located directly under the Find box.
3) Enter the replacement contents in the Replace box.
4) If necessary, click on Other options to increase the number of search filters.
5) To step through the cells and choose whether to replace the contents:
a) Click Find Next to locate the first instance of the search criteria.
b) If necessary, click Replace to replace the search criteria with the contents of the
Replace box.
c) Repeat as required.
6) Or, to locate and replace all instances of the search criteria without stopping at each one,
click Replace All. A Search Results dialog will pop up, listing the affected cells.

Figure 57: Find and Replace dialog

Chapter 2 Entering and Editing Data | 83


Tip
To replace the first instance of the search criteria you can simply press Replace
without pressing Find Next first.

Caution
Use Replace All with caution; otherwise, you may end up with some highly
embarrassing mistakes. A mistake with Replace All might require a manual, word-
by-word search to fix, if it is not discovered in time to undo it.

Find and Replace options


The options available to refine your find and replace are as follows:
• Find – enter the text that you want to search for, or select a previous search in the list.
• Match case – distinguishes between uppercase and lowercase characters.
• Formatted display – searches for cell contents in a particular format. For example, if a
cell has a currency value, say $123.45 and another has the same contents but default
formatting (123.45), then searching for “$123.45” will find the currency cell but not the
default-formatted cell.
• Entire cells – searches for cells with contents that are identical to the search text.
• All sheets – Searches through all of the sheets in the current spreadsheet.
• Replace – enter the replacement text, or select a recent replacement text or style from
the list.
• Current selection only – searches only the selected text or cells.
• Replace backwards – search starts at the current cursor position and goes backwards
to the beginning of the spreadsheet.
• Wildcards – select to use wildcards in the search. A wildcard is a special character that
represents one or more unspecified characters. Wildcards make text searches more
powerful, but often less specific. The following wildcards are available:
– ? (question mark) matches any single character. For example, b?g finds “bag”, “beg”,
“big”, “bog”, and “bug”.
– * (asterisk) matches any sequence of characters, including an empty string. For
example, *cast finds “cast”, “forecast”, and “outcast”.
– ~ (tilde) escapes the special meaning of a question mark, asterisk, or tilde character
that follows immediately after the tilde character. For example, why~? finds “why?”.
• Regular expressions – select to use regular expressions in the search. Regular
expressions offer the most powerful method of searching for text strings. For more
information about regular expressions, see the section entitled “Searching and filtering
with regular expressions” later in this chapter.
• Similarity search – find terms that are similar to the Find text. Select this option, and
then click the Similarities button to define the similarity options on the Similarity Search
dialog.
• Cell Styles – searches for cell content formatted with the style that you specify. Select
this option and then select a style from the Find list. To specify a replacement style,
select a style from the Replace list.
• Diacritic-sensitive – include diacritics and accents in the search.

84 |Calc Guide 24.8


• Direction – determines the Rows or Columns order for searching the cells.
• Search in – select either Formulas, Values, or Comments to search for the characters
that you specify in the results of formulas, in values, or in comments.
Other options may appear depending on your language settings on the Tools > Options >
Languages and Locales > General page (for example, Match character width, Sounds like
(Japanese), Kashida-sensitive). See the Help system for more information about these
options.

Note
The Wildcards, Regular expressions, and Similarity search options are mutually
exclusive; only one can be selected.

Search Results dialog


After you select Find All on the Find toolbar, or Find All or Replace All on the Find and Replace
dialog, Calc’s initial default behavior is to display the Search Results dialog (Figure 58) after it
has completed the operation. This dialog summarizes the results. In addition, affected cells are
highlighted in the spreadsheet.
The Search Results dialog lists the affected cells and their current content (after any
replacement). It also states the number of affected cells. If you deselect the Show this dialog
checkbox on the Search Results dialog before pressing the Close button, then the dialog will not
be displayed after future uses of Find All or Replace All. The display of the Search Results
dialog can also be controlled by enabling or disabling the Tools > Options > LibreOffice Calc >
View > Window > Summary on search option.

Figure 58: Search Results dialog

Searching and filtering with regular expressions


Regular expressions, often known as regex or regexp, are very powerful and enable users to
define complex search patterns for locating data of interest within a spreadsheet.

Chapter 2 Entering and Editing Data | 85


A regular expression is a string of characters defining a pattern of text that is to be matched.
More detailed, general background information can be found on Wikipedia at
https://en.wikipedia.org/wiki/Regular_expression.
Regular expressions are widely used in many domains and there are multiple regular expression
processors available. Calc utilizes the open source Regular Expressions package from the
International Components for Unicode (ICU). See
https://unicode-org.github.io/icu/userguide/strings/regexp.html for further details, including a full
definition of the syntax for ICU Regular Expressions.
Regular expressions appear in three areas of Calc’s functionality, as follows:
• Searching with the Find and Replace dialog, accessed by selecting Edit > Find and
Replace on the Menu bar, by clicking the Find and Replace icon on the Find toolbar, or
by pressing Ctrl+H.
• Filtering using the Standard Filter and Advanced Filter dialogs, accessed by selecting
Data > More Filters > Standard Filter and Data > More Filters > Advanced Filter.
• Functions. Many of Calc’s functions can use regular expressions in search criteria.
However these only operate correctly if the Tools > Options > LibreOffice Calc >
Calculate > Formulas wildcards > Enable regular expressions in formulas option
has been selected. We also recommend that you enable the Tools > Options >
LibreOffice Calc > Calculate > General Calculations > Search criteria = and <>
must apply to whole cells option so that search criteria in formulas must match the
whole of the cell contents. See Chapter 9, Using Formulas and Functions, for more
information.
To illustrate the use of regular expressions we can use a sales data spreadsheet, the first few
rows of which are shown in Figure 59.

Figure 59: Spreadsheet data for example regular expressions


Unfortunately the data entry clerks do not know the sales personnel well and so the spreadsheet
contains a number of misspellings of Brigitte’s name. On inspecting the data, we notice that if we
could find all cells containing a string that begins with the characters “Bri” and then replace the
entire contents of each such cell with the string “Brigitte”, then the data in the spreadsheet would
be corrected. This can be achieved easily with a simple regular expression, as follows:
1) Select Edit > Find and Replace on the Menu bar. Calc opens the Find and Replace
dialog (Figure 60).
2) Type ^Bri.* into the Find field. The character “^” means match at the beginning; “.”
means match any character; and “*” means match 0 or more times.

86 |Calc Guide 24.8


3) Type Brigitte into the Replace field.
4) If necessary, click the icon to expand the Other options area of the dialog.
5) Make sure that the Regular expressions checkbox is checked.
6) Click Replace All. Calc updates the spreadsheet data, replacing all occurrences of
“Bridget” and “Brigid” with “Brigitte”.
7) Click Close to close the Find and Replace dialog.

Figure 60: Using a regular expression on the Find and Replace dialog
Suppose we want to filter the same spreadsheet (Figure 59) to show only data relating to the
Tennis and Golf categories, from the North and East regions. This is easily achieved using
regular expressions, using the following steps:
1) Click a cell within the sales data.
2) Select Data > More Filters > Standard Filter on the Menu bar. Calc opens the Standard
Filter dialog (Figure 61).
3) Select Category from the first drop-down menu in the Field name column.
4) Select = from the first drop-down menu in the Condition column.
5) Type Tennis|Golf in the first text box in the Value column.
6) Select AND from the first drop-down menu in the Operator column.
7) Select Region from the second drop-down menu in the Field name column.
8) Select = from the second drop-down menu in the Condition column.
9) Type North|East in the second text box in the Value column.
10) If necessary, click the icon to expand the Options area of the dialog.
11) Make sure that the Regular expressions checkbox is checked.
12) Click OK and Calc updates the data displayed in accordance with the specified filter
criteria.

Chapter 2 Entering and Editing Data | 87


Figure 61: Using regular expressions on the Standard Filter dialog
The data shown in Figure 62 can be used to show a simple example of a function call that
incorporates a regular expression. Suppose we wanted to calculate the revenue from the sale of
pencils, pencil cases, and pens. This can be achieved by entering the following formula into an
empty cell =SUMIFS(C2:C6; A2:A6; "^pen.*"), where the regular expression matches the
name of any product that starts with the characters “pen”. Alternatively we could calculate the
revenue from the sale of books and notebooks using the formula =SUMIFS(C2:C6; A2:A6;
".*book$"), where the regular expression matches the name of any product that ends with the
characters “book”.

Figure 62: Stationery sales and revenue data


In Calc there are 26 functions that support the use of regular expressions and these are listed in
Chapter 9, Using Formulas and Functions. The REGEX function is particularly powerful,
matching and extracting, or optionally replacing, text using regular expressions. For example the
formula =REGEX("123456ABCDEF";"[126]";"";"g") returns "345ABCDEF", where any
occurrence of "1", "2" or "6" is replaced by the empty string and is thus deleted.

Tip
The online help describes many more regular expressions and their uses.

Note
If interoperability with Microsoft Excel is important for your spreadsheet, then you
may not be able to fully utilize Calc’s regular expression facilities because Excel
does not provide equivalent facilities. Hence, when you export a Calc spreadsheet to
Excel format, information relating to regular expressions will not be usable within

88 |Calc Guide 24.8


Excel. In this case you can use the less powerful wildcards facility provided by Calc
because spreadsheets that utilize wildcards can be exported to Excel format without
loss of data. See Chapter 9, Using Formulas and Functions, for more information
about wildcards.
Additional information about regular expressions in Calc can be found in the Help system.

Chapter 2 Entering and Editing Data | 89


Calc Guide 24.8

Chapter 3
Formatting Data
Make your data shine
Introduction
As with any modern spreadsheet program, cell formatting is an important feature of Calc. Calc
formatting resources use an extensive set of attributes to enhance the visual display of relevant
information of your spreadsheet. Manual and style formatting, as well as conditional formatting,
are addressed in this chapter.

Formatting data

Note
All the settings discussed in this section can also be set as a part of the cell style.
See Chapter 4, Using Styles and Templates, for more information.
You can format the data in Calc in several ways. Formatting can be defined as part of a cell style
so that it is automatically applied, or it can be applied manually to the cell. The Format Cells
dialog can be used for more control and extra options, over a selected cell or cell range. All of
the format options are discussed below.

Multiple lines of text


Multiple lines of text can be entered into a single cell using automatic wrapping or manual line
breaks. Each method is useful for different situations.

Automatic wrapping
To automatically wrap multiple lines of text in a cell, use one of the following methods:
Method 1
1) Select a cell or cell range.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Alignment tab (Figure 63).
4) Under Properties, select Wrap text automatically and click OK.
Method 2
1) Select the cell.
2) On the Properties deck of the Sidebar, open the Alignment panel (Figure 64).
3) Select the Wrap text option to apply the formatting immediately.
Method 3
1) Select the cell.
2) Click on the toolbar Wrap Text tool.

92 |Calc Guide 24.8


Figure 63: Format Cells dialog – Alignment tab

Figure 64: Wrap text formatting

Manual line breaks


To insert a manual line break while typing in a cell, press Ctrl+Enter. When editing text,
double-click the cell, then reposition the cursor to where you want the line break. In the Input line
of the Formula bar, you can also press Shift+Enter.
When a manual line break is entered, the cell row height changes but the cell width may not
change and the text may still overlap the end of the cell. You have to change the cell width
manually or reposition the line break.

Shrinking text to fit a cell


The font size of the data in a cell can automatically adjust to fit inside cell borders:
1) Select a cell or cell range.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Alignment tab (Figure 63).
4) Under Properties, select Shrink to fit cell size and click OK.

Chapter 3 Formatting Data | 93


Formatting numbers
Several number formats can be applied to cells by using icons on the Formatting toolbar
(highlighted in Figure 65). Select the cell, then click the relevant icon to change the number
format.

Figure 65: Number icons on Formatting toolbar


For more control or to select other number formats, use the Numbers tab of the Format Cells
dialog (Figure 66):
• Apply any of the data types in the Category list to the data.
• Select one of the predefined formats in the Format list.
• Control the number of decimal places and leading zeroes in Options.
• Enter a custom format code. This is a very powerful facility that is detailed in the Number
Format Codes page of the Help.
• The Language setting controls the local settings for the different formats such as the
date format and currency symbol.

Figure 66: Formatting numbers

Formatting fonts
To select a font and format it for use in a cell:
1) Select a cell or cell range.
2) Click the down arrow on the right of the Font Name box on the Formatting toolbar
(highlighted in Figure 67) and select a font in the drop-down list. A font is temporarily
applied on selected cells by hovering or navigating in the Font Name drop-down list.
The font can also be changed using the Font tab on the Format Cells dialog.

94 |Calc Guide 24.8


3) Click on the down arrow on the right of the Font Size box on the Formatting toolbar and
select a font size from the drop-down list. The font size can also be changed using the
Font tab on the Format Cells dialog.
4) To change the character format, click on the Bold, Italic, or Underline icons on the
Formatting toolbar.
5) To change the paragraph alignment, click on one of the alignment icons (Align Left,
Align Center and Align Right). The Format > Align menu also provides these options
in addition to the Justified alignment.

Figure 67: Font Name and Size on Formatting toolbar

Note
To specify the language used in the cell, open the Font tab on the Format Cells
dialog. Changing language in a cell allows different languages to exist within the
same document. For more changes to font characteristics, see “Font effects” below.

Tip
To choose whether to show the font names in their font or in plain text, go to Tools >
Options > LibreOffice > View and select or deselect the Show preview of fonts
option in the Font Lists section. For more information, see Chapter 16 Setting up and
Customizing.

Font effects
1) Select a cell or cell range.
2) Right-click and select Format Cells in the context menu, or go to Format > Cells on the
Menu bar, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Font Effects tab (Figure 68).
4) Select the font effect you want to use from the options available. The options available
are described in Chapter 4, Using Styles and Templates.
5) Click OK to apply the font effects and close the dialog.
Changes are applied to selected text, the word containing the cursor, or to any new text you
type.

Chapter 3 Formatting Data | 95


Figure 68: Format Cells dialog – Font Effects tab

Text orientation
To change the text direction within a cell, use the Alignment tab on the Format Cells dialog
(Figure 63 on page 93):
1) On the Alignment tab of the Format Cells dialog, select the Reference edge from which
to rotate the text as follows:
– Text Extension From Lower Cell Border – writes the rotated text from the bottom cell
edge outwards.
– Text Extension From Upper Cell Border – writes the rotated text from the top cell edge
outwards.
– Text Extension Inside Cell – writes the rotated text only within the cell.
2) Click on the small indicator at the edge of the text orientation dial and rotate it until you
reach the required degrees.
3) Alternatively, enter the number of degrees to rotate the text in the Degrees box.
4) Select Vertically stacked to make the text appear vertically in the cell.
If Asian language support is enabled and the text direction is set to vertical, then an Asian layout
mode becomes available.. This option, which can be enabled using a checkbox on the
Alignment tab of the Format Cells dialog, aligns Asian characters one below the other in the
selected cell(s). If the cell contains more than one line of text, the lines are converted to text
columns that are arranged from right to left. Western characters in the converted text are rotated
90 degrees to the right. Asian characters are not rotated.

Using the Formatting toolbar tools


The tools on the Formatting toolbar can be used as follows after the cell has been selected:
• To change the text direction from horizontal (default direction) to vertical, click on the
Text direction from top to bottom icon.

96 |Calc Guide 24.8


• To change text direction from vertical to horizontal (default), click on the Text direction
from left to right icon.
• To change text direction from the left-to-right direction that is the default direction for
Western fonts to a right-to-left direction used in fonts like Arabic, click on the Right-To-
Left icon. This only works if a font has been used that requires a right-to-left direction.
• To change text direction back to the default left-to-right direction used for Western fonts,
click on the Left-To-Right icon.

Note
The text direction icons can only be made available if the Asian and Complex text
layout options are checked under Tools > Options > Languages and Locales >
General > Default Languages for Documents. If it is necessary to make the
buttons visible, right-click on the toolbar and select Visible Buttons in the context
menu. Then, click on the required icon to place it on the Formatting toolbar.

Asian typography
If Asian language support is enabled, then an Asian Typography tab is included on the Format
Cells dialog (Figure 69). This tab enables setting of typographic options for cells in Asian
language documents. To enable Asian language support, navigate through Tools > Options >
Languages and Locales > General > Default Languages for Documents > Asian.

Figure 69: Format Cells dialog - Asian Typography tab


The following options are provided:
• The Apply list of forbidden characters to the beginning and end of lines option
prevents the characters in the list of restricted characters from starting or ending a line.
The characters are relocated to either the previous or the next line. To edit the list of
restricted characters, go to Tools > Options > Languages and Locales > Asian
Layout > First and Last Characters.
• The Allow hanging punctuation option prevents commas and periods from breaking
the line. Instead, these characters are added to the end of the line, even in the page
margin.
• The Apply spacing between Asian and non-Asian text option inserts a space
between ideographic and alphabetic text.

Formatting cell borders


To format the borders of a cell or a group of selected cells, you can use the border icons on the
Formatting toolbar to apply the default styles to borders, or the Format Cells dialog for greater
control. See Chapter4, Using Styles and Templates, for more information on the options.

Chapter 3 Formatting Data | 97


Note
Cell border properties apply only to the selected cells and can only be changed if you
are editing those cells. For example, if cell C3 has a top border, that border can only
be removed by selecting C3. It cannot be removed in C2, even though it appears to
be the bottom border for cell C2.
1) Select a cell or a range of cells.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog.
3) On the Borders tab (Figure 70), select the options required.
4) Click OK to close the dialog and save the changes.
Alternatively, use the icons on the Formatting toolbar to apply default styles to borders:
1) Click the Borders icon and select one of the options displayed in the Borders palette.
2) Click the Border Style icon and select one of the line styles from the Border Style
palette.
3) Click the Border Color icon to apply the most recently selected color. Click the down
arrow to the right of the Border Color icon to select another color from the Border Color
palette.

Note
When entering borders with the border icons on the Formatting toolbar, you have two
choices: either left-click the required icon to add a border to the present borders or
Shift+click to add a border and remove the present borders.

Figure 70: Format Cells dialog – Borders tab

98 |Calc Guide 24.8


Formatting cell backgrounds
To format the background color for a cell or a group of cells (see Chapter 4, Using Styles and
Templates, for more information):
1) Select a cell or a range of cells.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog.
3) On the Background tab, click the Color button and select a color from the color palette.
4) Click OK to save the changes and close the dialog.
Alternatively, click on the Background Color icon on the Formatting toolbar to apply the most
recently selected color. Click the down arrow to the right of the Background Color icon to select
a different color from the Background Color palette.

AutoFormat of cells and sheets


Using AutoFormat
You can use AutoFormat to format a group of cells:
1) Select the cells in at least three columns and rows, including column and row headers,
that you want to format.
2) Go to Format > AutoFormat Styles on the Menu bar to open the AutoFormat dialog
(Figure 71).
3) Select the type of format and format color in the list.
4) Select the formatting properties to be included in the AutoFormat function.
5) Click OK to apply the changes and close the dialog.

Figure 71: AutoFormat dialog

Defining a new AutoFormat


You can define a new AutoFormat so that it becomes available for use in all spreadsheets:
1) Format the data type, font, font size, cell borders, cell background, and so on for a group
of cells.
2) Select a cell range of at least 4x4 cells.

Chapter 3 Formatting Data | 99


3) Go to Format > AutoFormat Styles to open the AutoFormat dialog and then click the
Add button.
4) In the resulting Add AutoFormat dialog, type a meaningful name for the new format in the
Name box and click OK.
5) The new AutoFormat is now available in the Format list on the AutoFormat dialog. Click
OK to close the AutoFormat dialog.

Note
Autoformatting does not use cell styles. It applies direct formatting to the selected
range. The new Autoformat is stored in the user profile and is not part of the
spreadsheet document. This means that you can reuse the new AutoFormat in
another spreadsheet document using your profile. However, under a different profile
or different user, the new AutoFormat will not be listed. See Chapter 4, Using Styles
and Templates.

Value highlighting
Sometimes, your spreadsheet can contain data of different types in the same column, row or
range. For example, a column with dates can have a string (text) written in the same format as
the default date format for the column. Because strings and numbers are treated differently in
some important functions, such as AVERAGE for example, the spreadsheet can display incorrect
results if your data has mixed types.
Value highlighting displays cell contents in different colors depending on the type of content. An
example of value highlighting is shown in Figure 72:
• Text is shown in black.
• Formulas are shown in green.
• Numbers (including date and time) are shown in blue.

Figure 72: Example of value highlighting


The value highlighting colors override any colors used in formatting. This color change applies
only to the colors seen on a display. When a spreadsheet is printed, the original colors used for
formatting are printed.
Go to View > Value Highlighting on the Menu bar, or use the keyboard shortcut Ctrl+F8, to
turn the function on or off. When value highlighting is switched off, the original formatting colors
are used for display.
You can make value highlighting the default when opening a spreadsheet in Calc, by selecting
Tools > Options > LibreOffice Calc > View > Display > Value highlighting. This default mode
for value highlighting may not be suitable for printing.

Tip
If the font color does not change when applied to a cell, check if the Value
highlighting is active.

100 |Calc Guide 24.8


Using conditional formatting
You can set up cell formats to change depending on conditions that you specify. Conditional
formatting is used to highlight data that is outside the specifications that you have set. Overuse
of conditional formatting is not advised as this could reduce the impact of data that falls outside
those specifications.

Note
To use conditional formatting, the AutoCalculate feature must be enabled and styles
must be used. See Chapter 4, Using Styles and Templates, for more information.

Setting up conditional formatting


1) Ensure that AutoCalculate is enabled: Data > Calculate > AutoCalculate.
2) Select the cells where you want to apply conditional formatting.
3) Go to Format > Conditional > Condition (Figure 77), Color Scale (Figure 82), Data
Bar (Figure 83), Icon Set (Figure 85), or Date (Figure 81), on the Menu bar to open the
Conditional Formatting dialog. Any conditions already defined are displayed.
4) Click Add to create and define a new condition. Repeat this step as necessary.
5) Select a style from the styles already defined in the Apply Style drop-down list. Repeat
this step as necessary.
6) Alternatively, select New Style to open the Cell Style dialog (Figure 86) and create a new
cell style. Repeat this step as necessary.
7) Click OK to save the conditions and close the dialog. The selected cells are now set to
apply a result using conditional formatting.

Figure 73: Conditional formatting toolbar icon

Chapter 3 Formatting Data | 101


Figure 74: Conditional Formatting dialog – Cell value

Tip
Although each condition type can be accessed using a different option in the Format
> Conditional menu of the Menu bar, the five variants of the Conditional Formatting
dialog shown in Figures 77 to 81 are not distinct. Once the dialog is open, you can
create conditions of all types without interacting with the Menu bar. For example, you
might create Condition 1 to select a cell style to be used if the cell takes a certain
value (Condition 1 is of type “Condition”). You might then press the Add button to
create Condition 2 by selecting All Cells in the condition’s upper left drop-down and
then selecting Data Bar in the adjacent drop-down (Condition 2 is of type “Data
Bar”). You might then press the Add button to create Condition 3 by selecting Date
is in the condition’s upper left drop-down (Condition 3 is of type “Date”). In this way
you can create many conditions of different types to control the conditional formatting
of the selected cells.

Types of conditional formatting


The Condition dialog is the starting point when using conditional formatting. Here you can define
what formats to use to highlight any data in the spreadsheet that meets the conditions you have
defined.

Cell value
Applies the selected style to the cell or cell range controlled by the condition set in the drop
down list. The formatting is applied to each cell individually and the condition may depend on
other cells values of the selected range. Valid conditions are described in tables 5, 6 and 7.
Table 5: Conditions for number and text in cells
Condition Applies the selected style to the cell...
...when the cell value equals the user defined value in text box in the
is equal to
right. Use text inside quotes if you compare text values.
the cell value is not equal (different) to the user defined value in the text
is not equal to
box in the right. Use text inside quotes if you compare text values.

is duplicate Applies the selected style to the cell when at least one other cell in the
range has equal contents.

102 |Calc Guide 24.8


Condition Applies the selected style to the cell...
Applies the selected style to the cell when the cell contents is unique in
is not duplicate
the range.
Applies the selected style to the cell when the cell contents begins with
begins with the text or number defined in the right text box.
See note on text conversion below.
Applies the selected style to the cell when the cell contents ends with the
ends with text or number defined in the right text box.
See note on text conversion below.
Applies the selected style to the cell when the cell contents contains the
contains text or number defined in the right text box.
See note on text conversion below.
Applies the selected style to the cell when the cell contents does not
does not contain contains the text or number defined in the right text box.
See note on text conversion below.

Note on text conversion conditions


The condition applies to the internal text conversion of the cell contents. Numeric
values are compared with their equivalent text representation. Numeric cell formats
(currency, scientific, user-defined, ...) are not considered for comparisons.
Table 6: Conditions for number-only cell values
Condition Applies the selected style to the cell when the cell value is...
is less than strictly less than the user defined value in the text box in the right.
is greater than strictly greater than the user defined value in the text box in the right.
is less than or
less than or equal to the user defined value in the text box in the right.
equal to
is greater than or
greater than or equal to the user defined value in the text box in the right.
equal to
between the two values defined in the text boxes on the right – lower and
is between
upper values – including the boundary values themselves.
not between the two values defined in the text boxes on the right – lower
is not between
and upper values – including the boundary values themselves.
is in top N Between the maximum value in the range and the Nth greater element of
elements the same. Enter the value of N in the text box on the right.
is in bottom N Between the minimum value in the range and the Nth lower element of
elements the same. Enter the value of N in the text box on the right.
In the top N percent of the number of cells in the range. For example, in
is in top N percent a 20 cells range and N equals 20, the style is applied to the 4 last cells of
the range. Enter the value of N in the text box on the right.
In the bottom N percent of the number of cells in the range. For example,
is in bottom N
in a 20 cells range and N equals 20, the style is applied to the 4 first cells
percent
of the range. Enter the value of N in the text box on the right.
strictly greater than the average of the cell range values.
is above average
See note below on average function.
the cell value is strictly less than the average of the cell range values.
is below average
See note below on average function.

Chapter 3 Formatting Data | 103


Condition Applies the selected style to the cell when the cell value is...
is above or equal greater or equal than the average of the cell range values.
average See note below on average function.
is below or equal is less or equal than the average of the cell range values.
average See note below on average function.

Note on AVERAGE function in conditions


The AVERAGE function ignores any text or empty cell within a data range. If you
suspect wrong results from this function, look for text in the data ranges. To highlight
text contents in a data range, use the Value highlighting feature above.
Table 7: Conditions for errors in cells
Condition Applies the selected style to the cell...
When the cell is in an error condition defined in the right text box. See
Appendix B "Error Codes".

is error Tip
A cell that references another cell with an error
condition is not in error itself.

When the cell is not in an error condition defined in the right text box.
is not error
See Appendix B "Error Codes".

Color Scale
Use Color Scale to set the background color of cells depending on the values of the data in
those cells. Color Scale can only be used when All Cells has been selected for the condition.
You can use either two or three colors for the color scale or gradient.

Figure 75: Conditional Formatting dialog – Color Scale


The Color Scale (2 entries) requires the definition of the colors for the minimum and the
maximum values in the range. These two values can be calculated in several ways:

104 |Calc Guide 24.8


• Min (Max): the minimum (maximum) value of the range.
• Percentile: A percentile is each of the 99 values which divide the sorted data in 100
equal parts, so that each part represents 1/100 of the sample population. A percentile
returns the value for a data series going from the smallest to the largest value in a set of
data. For P = 25, the percentile means the first quartile. P = 50 is also the MEDIAN of the
data set. Enter the percentile value in the text box just below. Valid values are from 0 to
100.
• Value: a fixed value set for the minimum (maximum) color. Enter the value in the text box
just below.
• Percent: a fixed value representing the percentage of the minimum (maximum) of the
length defined by minimum and maximum values in the range. A minimum of 10%
selects the values below 10% of the segment [Min,Max]. A maximum of 80% select
values above 80% of the segment [Min,Max]. Valid values are from 0 (zero) to 100. Do
not enter a percent (%) sign.
• Formula: A formula expression starting with the equal sign (=) that calculates the
numeric value for the minimum (maximum) colors. Values can be numbers, dates or
time. Enter the formula expression in the text box just below.

Figure 76: Color scale with 2 and 3 colors


The Color scale (3 entries) allows a third color for an intermediate data value. The third color
can be defined as for the Color scale (2 entries) above and with two more options:
• Min, Max: The minimum (maximum) value of the range.

Data Bar
Data bars provide a graphical representation of data in the spreadsheet. The graphical
representation is based on the values of data in a selected range. Click on More Options in the
Conditional Formatting dialog to define how the data bars will look. Data bars can only be used
when All Cells has been selected for the condition.

Chapter 3 Formatting Data | 105


Figure 77: Conditional Formatting dialog – Data Bar
To format all cells with data bars, you must set the minimum and maximum values of the data
range. The condition options are the same as the Color Scale above with the addition of:
• Automatic: Automatically sets the and maximum value based on the values in the data
set.

Figure 78: Data bars


Data bar options
Click on the More Options button to select attributes of the data bars. The Data Bar dialog
opens (Figure 79):
Entry values
Defines the minimum and maximum values for the data bar formatting. See the
dropdown items described in the minimum and maximum of the Color Scale above.

106 |Calc Guide 24.8


Bar Colors
Set the color for positive and negative values. Set the bar fill mode:
– Gradient: set a color scale between the color of positive (negative) values and white.
– Color: use the positive (negative) color for the entire data bar, no fade out gradient
(Figure 78).
Axis
Set the position of the vertical axis for the data bar. Values are:
– Automatic: position the vertical axis in the middle of the maximum and minimum
values.
– Middle: set the vertical axis in the middle of the column (Figure 78).
– None: do not display a vertical axis.
Bar Lengths
Sets the minimum (maximum) length of the data bars, as a percentage of the column
width.
Display bars only
Do not display values in the cell, only the data bars.

Figure 79: Data bars options

Icon Set
Icon sets display an icon next to the data in each selected cell to give a visual representation of
where the cell data falls within the defined range that you set. The operators in the drop down
menu include equal to, less than, greater than, less than or equal to, greater than or equal to,
and not equal to (Figure 17). The icon sets available include colored arrows, gray arrows,
colored flags, colored signs, symbols, bar ratings, and quarters (Figure 82 and Figure 83). Icon

Chapter 3 Formatting Data | 107


sets can only be accessed when the Conditional Formatting dialog has been opened and
All Cells has been selected for the condition (Figure 80).

Figure 80: Conditional Formatting dialog – Icon Set


Figure 81 shows the icon set used in conditional formatting to show the evolution of data in two
datasets.

Figure 81: Arrows icon set used to indicate evolution in data

108 |Calc Guide 24.8


Figure 82: Icon sets with 3 icons

Figure 83: Icon sets with 4 and 5 icons

Date
Date applies a defined style depending on a date range chosen in the drop-down menu. Date
range options are formed by applying the adjectives This, Last, and Next to the available
periods for Day, Week, Month, or Year with. Last 7 days is another option available. Examples
include Tomorrow (the word for next day), Last 7 days, This week, Next month, Last year.

Figure 84: Conditional Formatting dialog - Date

Note
The start and end of the week is locale dependent (set in Tools > Options >
Languages and Locales > General).

Chapter 3 Formatting Data | 109


Figure 85: Condition for dates in next week.

Formula is
Applies the selected style to the cell when the formula expression in the text box in the right is
not zero.
The formula is expressed similar to a test condition evaluating to TRUE or FALSE.
Figure 86 shows different cell styles applied based on conditions for dates before and after the
current date. The formulae are expressed in Table 8.

Figure 86: Conditions to set current, past, and future dates using formulas
Table 8: Current, past and future deadlines with formulas
Deadlines Formula is Style applied
Current date F3 = TODAY() "Neutral"
Past date F3 < TODAY() "Bad"
Future date F3 > TODAY() "Good"

Conditional formatting management


To see all the conditional formatting defined in the spreadsheet and any styles used:
1) Go to Format > Conditional > Manage on the Menu bar to open the Manage
Conditional Formatting dialog (Figure 87).

110 |Calc Guide 24.8


Figure 87: Manage Conditional Formatting dialog
2) Select a range in the Range list and click Edit to redefine the conditional formatting.
3) Select a range in the Range list and click Remove to delete the conditional formatting.
The deletion is immediate with no confirmation.
4) Select Add to create a new definition of conditional formatting.
5) Click OK to save the changes and close the dialog.

Copying cell styles


To apply the style used for conditional formatting to other cells later:
1) Click one of the cells that has been assigned conditional formatting and copy the cell to
the clipboard.
2) Select the cells that are to receive the same formatting as the copied cell.
3) Go to Edit > Paste Special > Paste Special on the Menu bar, or right-click and select
Paste Special > Paste Special in the context menu, or press Ctrl+Shift+V, to open the
Paste Special dialog (described in the “Paste Special dialog” section in Chapter 2,
Entering and Editing).
4) Make sure that only Formats is selected and click OK to paste the conditional formatting
into the cell.

Hiding and showing data


Calc elements can be hidden so that they cannot be viewed or printed. However, hidden
elements can still be selected for copying if you select the elements around them; for example, if
column B is hidden, it is copied when you select to copy columns A to C. When you require a
hidden element again, you can reverse the process and show the element.

Hiding data
Sheets
Select Sheet > Hide Sheet on the Menu bar, or right-click on the sheet tab for the sheet to be
hidden and select Hide Sheet in the context menu. There must always be one sheet that is not
hidden.

Rows and columns


1) Select a cell in the row or column you want to hide.

Chapter 3 Formatting Data | 111


2) Go to Format on the Menu bar and select Rows or Columns.
3) Select Hide from the menu and the row or column can no longer be viewed or printed.
4) Alternatively, right-click on the row or column header and select Hide Rows or Hide
Columns in the context menu.

Tip
To enable/disable a visual indicator of hidden columns and rows, go to View >
Hidden Row/Column Indicator.

Cells
Hiding individual cells is more complicated. First, you need to define the cells as protected and
hidden; then you need to protect the sheet:
1) Select the cells you want to hide.
2) Go to Format > Cells on the Menu bar, or right-click and select Format Cells in the
context menu, or press Ctrl+1, to open the Format Cells dialog (Figure 88).
3) Click the Cell Protection tab and select an option for hiding and printing the cells.
4) Click OK to save the changes and close the dialog.
5) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and select
Protect Sheet in the context menu, to open the Protect Sheet dialog (Figure 89).
6) Select Protect this sheet and the contents of protected cells.
7) Create a password and then confirm the password. The dialog provides a password
strength meter to indicate the strength of the entered password. This incorporates a
colored bar to reflect password strength, with red indicating a weak password and green
indicating a strong password. In addition, the longer the colored bar, the greater the
strength of the password.
8) Select or deselect the options in the Allow all users of this sheet to area so that users can
select protected or unprotected cells.
9) Click OK to save the changes and close the dialog.

Figure 88: Format Cells dialog – Cell Protection tab

112 |Calc Guide 24.8


Note
When content in cells is hidden, it is only the content contained in the cells that is
hidden and the protected cells cannot be modified. The blank cells remain visible in
the spreadsheet.

Figure 89: Protect Sheet dialog

Showing data
Sheets
Select Sheet > Show Sheet on the Menu bar, or right-click on any sheet tab and select Show
Sheet in the context menu. Choose which hidden sheets to show from the list on the Show
Sheet dialog. If there are no hidden sheets, the Show Sheet option will not appear in the context
menu and will be grayed on the Menu bar.

Rows and columns


1) Select the rows or columns on each side of the hidden row or column.
2) Go to Format on the Menu bar and select Rows or Columns. Select Show in the menu
and the row or column will be displayed and can be printed.
3) Alternatively, right-click on a row or column header and select Show Rows or Show
Columns in the context menu.

Cells
1) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and select
Protect Sheet in the context menu, to open the Protect Sheet dialog (Figure 89).
2) Enter the password to unprotect the sheet and click OK.
3) Go to Format > Cells on the Menu bar, right-click and select Format Cells in the context
menu, or press Ctrl+1, to open the Format Cells dialog (Figure 88).
4) Click the Cell Protection tab and deselect the hide options for the cells. Click OK.

Note
When protecting a sheet using the Protect Sheet dialog, you can leave the password
fields blank. In this case, the Protect Sheet dialog is not presented at step 1) above
and step 2) is not necessary.

Chapter 3 Formatting Data | 113


Calc Guide 24.8

Chapter 4
Using Styles and Templates
Using consistent formatting in spreadsheets
What are styles? Why use them?
A style is a set of formats that you can apply to selected elements in a document to quickly
change their appearance. Applying a style often means applying a group of formats at the same
time.
Many people manually format spreadsheet cells, shapes, and pages without paying any
attention to styles and are accustomed to formatting documents according to physical attributes.
For example, for the contents of a cell you might specify the font family, font size, and any
character formatting such as bold, italic, or underline.
Using styles means that you stop applying attributes and characteristics individually (for
example, font size 14 pt, Times New Roman, bold, centered) and start using a style, for example
Title. Applying attributes and characteristics is time-consuming and prone to errors. In contrast,
using a style, which has been defined to include the attributes and characteristics you want, will
save you time and give greater consistency in formatting.
Styles also make major formatting changes easy. For example, you may decide to change the
appearance of all subtotals in a spreadsheet to be 10 pt Arial instead of 8 pt Times New Roman
after you have created a 15-page spreadsheet. Assuming that you have formatted all subtotals
with a specific style, you can change all of the subtotals in the document by simply changing the
properties of that style.
In addition, Calc also provides drawing and page styles, as described below.
You can modify the attributes of the supplied styles and define as many new styles as you
require. Creating, modifying, and accessing styles is explained in the following sections.

Direct formatting and style formatting


Direct formatting (also called manual formatting) overrides styles. You cannot remove the direct
formatting by applying a style to it.
To remove manual formatting, select the object, and then do one of the following:
• Right-click and choose Clear Direct Formatting in the context menu (where available).
• Press Ctrl+M.
• Click the Clear Direct Formatting icon on the Standard toolbar.
• Select Format > Clear Direct Formatting on the Menu bar.

Calc style types


Calc offers three style types: cell styles, drawing styles, and page styles. These style types are
explained in the following sections.

Cell styles
Cell styles are similar to paragraph styles used in LibreOffice Writer. They are the most basic
type of style in Calc. Cell styles are used for applying fonts, alignment, borders, background,
number formats (for example, currency, date, number), and cell protection to format the data in
the cells.
A basic range of cell styles is supplied with Calc. Many of these styles are shown on the Styles
menu on the Menu bar and all are shown in the Styles deck of the Sidebar. If you create a new
cell style, it will be shown in the Sidebar. To add it to the Styles menu, see Chapter 15, Setting
up and Customizing, for instructions.

116 |Calc Guide 24.8


Initially, the basic styles are configured so that if you change the characteristics of the Default
cell style, then all of the other styles, inheriting from it, will change to match.

Drawing styles
Drawing styles in Calc are similar to the graphic styles used in LibreOffice Draw and can be
applied to shapes and comments. If the same area fill, lines, borders, and other relevant
attributes are to be applied to a set of such objects, this repetitive process can be simplified by
using drawing styles.
Two drawing styles (Default and Note) are supplied with Calc and these can be modified or used
as the basis for new custom drawing styles, but cannot be deleted.
• When a shape is added to a spreadsheet, the Default drawing style is initially applied to
that shape. Shapes may be inserted using several methods – for example by going to
the Insert > Shape menu on the Menu bar or by clicking icons on the Drawing toolbar.
• When a comment is inserted into a spreadsheet, the Note drawing style is initially
applied to that comment. Comments may be inserted using several methods – for
example by going to the Insert > Comment option on the Menu bar or by clicking the
Insert Comment icon on the Standard toolbar.

Tip
You can select the comment drawing object and apply another drawing style, and
have notes in different background colors, fonts and font sizes, for example.

Page styles
Page styles in Calc are applied to sheets. Although one sheet may print on several pages, only
one page style can be applied to a sheet. If a spreadsheet file contains more than one sheet,
then a different page style can be applied to each sheet. For example, a spreadsheet might
contain some sheets to be printed in landscape orientation and other sheets to be printed in
portrait orientation.
Two page styles are supplied with Calc: Default and Report. Page styles allow you to set page
size and orientation, page margins, headers and footers, borders and backgrounds, and the
sequence for printing sheets.

Applying cell styles


To apply cell styles in Calc, you can use the Styles menu on the Menu bar, the Styles deck on
the Sidebar, Fill Format mode, the Apply Style list on the Formatting toolbar, and keyboard
shortcuts.

Styles menu
By default, the Styles menu (Figure 90) lists many of the cell styles supplied with Calc. To apply
a cell style, select the cell or group of cells to be formatted, and then choose Styles and click on
the required style.

Chapter 4 Using Styles and Templates | 117


Figure 90: The Styles menu

Styles deck in Sidebar


The Styles deck on the Sidebar lists and optionally shows previews of the styles available.
1) If the Styles deck in the Sidebar is not open, do one of the following to open it:
– Select View > Styles on the Menu bar.
– Select Styles > Manage Styles on the Menu bar.
– Press the F11 function key.
– If another deck of the Sidebar is open, select the Styles icon in the tab panel at the
right of the Sidebar.
2) Click the Cell Styles icon on top of the Styles deck to open the list of cell styles. Figure
91 shows the deck with cell styles visible.
3) In the spreadsheet, highlight the cell or group of cells where you want to apply a cell
style.
4) Double-click on the cell style name in the Styles deck and the formatting attributes for
that style are applied to the data contained in the highlighted cells.

118 |Calc Guide 24.8


Figure 91: Styles deck in Sidebar, showing cell styles

Fill Format mode


Fill Format mode is useful when you want to apply the same style to many scattered cells.
1) Go to the Styles deck on the Sidebar (Figure 91).
2) Select the style you want to apply.
3) Click the Fill Format Mode icon in the top right of the Styles deck. The mouse pointer
changes shape.
4) Click in each cell where you want to apply the selected style.
5) When you have finished formatting cells, click the Fill Format Mode icon to exit the
mode.

Caution
When Fill Format mode is active, a right-click anywhere in the document cancels the
last Fill Format action. Be careful not to accidentally right-click and thus cancel any
formatting actions you want to keep.

Apply Style list


The Apply Style drop-down list is not included by default on the Formatting toolbar in Calc, but
you can add it as follows:
1) Right-click on any icon on the Formatting toolbar and select Visible Buttons in the
context menu (Figure 92).

Chapter 4 Using Styles and Templates | 119


2) Click Apply Style. The context menu closes and the Apply Style list appears at the left
end of the Formatting toolbar.

Figure 92: Adding the Apply Style list to the Formatting toolbar
To apply a style using the Apply Style list:
1) Select a cell or a group of cells in the spreadsheet.
2) Click the down arrow at the right of the Apply Style list to open the drop-down menu
(Figure 93).
3) Select the required style. The formatting attributes of that style are applied to the
selected cells.

Figure 93: Using the Apply Style list


Only the styles that are in use are shown on the list. Click More Styles to go to the Styles deck
where all cell styles are available.

Keyboard shortcuts
You can create keyboard shortcuts to apply commonly-used cell, drawing, or page styles,
including any custom styles that you have created. See Chapter 15, Setting up and Customizing,
for more information.

Applying drawing styles


To apply a different drawing style to a shape or comment:
1) Select the shape or comment to be styled.
2) Go to the Styles deck on the Sidebar (Figure 91).
3) At the top of the Styles deck, click the Drawing Styles icon.
4) Double-click on the required drawing style.

Applying page styles


The page style applied to a sheet within a spreadsheet is indicated on the Status Bar, as shown
in Figure 94.

120 |Calc Guide 24.8


Figure 94: Page style (Default) indicated on Status Bar
To apply a different page style:
1) Select the sheet to be styled by clicking its sheet tab.
2) Go to the Styles deck on the Sidebar (Figure 91).
3) At the top of the Styles deck, click the Page Styles icon.
4) Double-click on the required page style.

Creating new styles


To create a new style, follow the procedure described in this section.

Note
Any new styles, and any changes to existing styles, apply only to the spreadsheet in
use. To save new styles in a template, see “Creating a template” for more
information.
5) Go to the Styles deck on the Sidebar (Figure 91).
6) To create a new cell style, click the Cell Styles icon; or to create a new drawing style,
click the Drawing Styles icon; or to create a new page style, click the Page Styles icon.
7) Right-click in the Styles deck and select New in the context menu to open either the Cell
Style dialog, the Drawing Style dialog, or the Page Style dialog.
8) Use the various tabbed pages on the dialogs to set the attributes for the new style. See
“Cell style attributes”, “Drawing style attributes”, and “Page style attributes” for more
information.
9) Click OK to close the dialog and save the new style.

Note
Style names are case sensitive. You can define, for example, a style called red and
another style called Red. Make sure all style names are sufficiently different to
prevent any confusion.

Cell style attributes


The following attributes are available on the tabbed pages of the Cell Style dialog (Figure 95).

Organizer tab
• Name – displays the name of the selected style. If you are creating or modifying a
custom style, enter a name for the style. You cannot change the name of a predefined
style.
• Inherit from – you can choose to link the new style to an existing style and then modify
some of the attributes. If you do this, any change to the parent style’s attributes will affect
the new style. For example, you could make the styles identical except for the font color;

Chapter 4 Using Styles and Templates | 121


if you later change the font family of the parent style, the new style’s family will also
change.
• Edit Style – enables you to view and edit the properties of the parent style.
• Category – displays the category for the current style. If you are creating or modifying a
new style, select Custom Styles from the list. You cannot change the category for a
predefined style. Select Hidden Styles if you want that style to appear only in the Styles
list.
• Contains – describes the formatting used in the style.

Figure 95: Cell Style dialog – Organizer tab

Numbers tab
• Category – select a category from the list.
• Format – select how you want the contents of the selected cells to be displayed.
When you select Currency as a category, you need to select a currency in the drop-down list
and then select the format to use from the options available for that currency.
The currency format is not dependent on the language that you select in the Language box. The
default currency format for a cell is determined by the regional settings of your operating system.
• Language – specifies the language settings for the selected cells. With the language set
to the default, Calc automatically applies the number formats associated with the system
default language. The language setting ensures that date and currency formats are
preserved even when the document is opened in an operating system that uses a
different default language setting.
• Options – specify the options for the selected format:
– Decimal places – enter the number of decimal places that you want to display.
– Leading zeroes – enter the maximum number of zeroes to display in front of the
decimal point.
– Negative numbers red – select to change the font color of negative numbers to red.
– Thousands separator – select to insert a separator between thousands. The type of
separator (for example, a comma or a space) depends on your language settings.
• Format code – displays the number format code for the selected format. You can also
enter a custom format.
• Add – adds the number format code that you entered to the user-defined category.

122 |Calc Guide 24.8


• Edit Comment – adds a comment to the selected number format.
• Remove – deletes the selected number format.
• Preview field – displays a preview of the current selection.

Figure 96: Cell Style dialog – Numbers tab

Font tab
Depending on your language settings, you can change the formatting for the following font types
on this tab – Western text font (Latin character sets), Asian text font (Chinese, Japanese, or
Korean character sets), and Complex text layout font (right-to-left text direction). Figure 97
shows the Font tab of the Cell Style dialog when the Asian and Complex text layout options
are selected in the Default Languages for Documents area of the Tools > Options >
Languages and Locales > General page. The layout of the Font and Font Effects tabs are
modified if either of these two options is deselected.
• Font – select an installed font in the list.
• Style – select the formatting you want to apply, for example bold, Italic, or underline.
• Size – select or enter the font size that you want to apply. For scalable fonts, you can
also enter decimal values. If you are creating a style that is based on another style, you
can enter a percentage value or a point value (for example, 2 pt or 5 pt).
• Language – sets the language that the spelling checker is to use. The spelling checker
works only when you have installed the corresponding language module. A language
entry has a check mark in front of it if the spelling checker is activated for that language.
• Features – some fonts offer special features such as Discretionary Ligatures and
Horizontal Kerning. Click this button to access the Font Features dialog (not shown) to
select those features.
• Preview – displays a preview of the current selection.

Chapter 4 Using Styles and Templates | 123


Figure 97: Cell Style dialog – Font tab

Font Effects tab

Figure 98: Cell Style dialog – Font Effects tab

124 |Calc Guide 24.8


• Font color – sets the color for the text. If you select Automatic, the text color is set to
black for light backgrounds and to white for dark backgrounds.
• Transparency – sets the transparency of the character text. The value 100% means
entirely transparent, while 0% means not transparent at all.
• Overlining – select the overlining style that you want to apply. To apply the overlining to
words only (not the spaces between them), select the option box Individual words.
• Overline color – select the color for the overlining, in the pallet when you click the
button next to the Overlining field. Automatic matches the font color.
• Strikethrough – select a strikethrough style for the selected text. To apply the
strikethrough to words only (not the spaces between them), select Individual words.
• Underlining – select the underlining style that you want to apply. To apply the
underlining to words only (not the spaces between them), select Individual words.
If you apply underlining to a superscript text, the underlining is raised to the level of the
superscript. If the superscript is contained in a word with normal text, the underlining is
not raised.
• Underline color – select the color for the underlining, in the pallet when you click the
button next to the Underlining field. Automatic matches the font color.
• Individual words – applies the selected effect only to words and ignores spaces.
• Relief – select a relief effect to apply to the text. The Embossed relief makes the
characters appear as if they are raised above the page. The Engraved relief makes the
characters appear as if they are pressed into the page.
• Outline – displays the outline of the characters. This effect does not work with every
font.
• Shadow – adds a shadow that casts below and to the right of the characters.
• Emphasis Mark – select a character to display over or below the entire length of the
selected text.
• Position – specify where to display the emphasis marks (for Asian languages).
• Preview – displays a preview of the current selection.

Alignment tab
• Text Alignment – sets the alignment options for the contents of the current cell, or the
selected cells.
– Horizontal – select the horizontal alignment option that you want to apply to the cell
contents:
– Default – aligns numbers to the right and text to the left.
– Left – aligns the contents of the cell to the left.
– Center – horizontally centers the contents of the cell.
– Right – aligns the contents of the cell to the right.
– Justified – aligns the contents of the cell to the left and to the right cell borders.
– Filled – repeats the cell contents (number and text) until the visible area of the cell is
filled. This feature does not work on text that contains line breaks.
– Distributed – aligns contents evenly across the whole cell. Unlike Justified, it also
justifies the very last line of text.

Chapter 4 Using Styles and Templates | 125


– Indent – indents from the left edge of the cell by the amount that you enter.

Figure 99: Cell Style dialog – Alignment tab


– Vertical – select the vertical alignment option that you want to apply to the cell
contents:
– Default – aligns the cell contents to the bottom of the cell.
– Top – aligns the contents of the cell to the upper edge of the cell.
– Bottom – aligns the contents of the cell to the lower edge of the cell.
– Middle – vertically centers the contents of the cell.
– Justified – aligns the contents of the cell to the top and to the bottom cell borders.
– Distributed – similar to Justified, unless the text orientation is vertical. Then it behaves
in a similar manner to the horizontal Distributed setting, with the very last line justified.
• Text Orientation – defines the text direction of cell contents.
– ABCD wheel – click anywhere in the wheel to define the text orientation. The
characters “ABCD” on the wheel correspond to the new setting.
– Vertically stacked – assigns vertical text orientation for cell contents.
– Asian layout mode – only available if Asian language support is enabled and the text
direction is set to vertical. Aligns Asian characters one below the other in the selected
cell(s). If the cell contains more than one line of text, the lines are converted to text
columns that are arranged from right to left. Western characters in the converted text
are rotated 90 degrees to the right. Asian characters are not rotated.
– Degrees – allows you to manually enter the orientation angle.
– Reference edge – specify the cell edge from which to write the rotated text:

126 |Calc Guide 24.8


– Text Extension From Lower Cell Border – writes the rotated text from the bottom cell
edge outwards.
– Text Extension From Upper Cell Border – writes the rotated text from the top cell edge
outwards.
– Text Extension Inside Cell – writes the rotated text only within the cell.
• Properties – determine the text flow in a cell.
– Wrap text automatically – wraps text onto another line at the cell border. The number
of lines depends on the width of the cell. To enter a manual line break, press
Ctrl+Enter in the cell.
– Hyphenation active – enables word hyphenation for text wrapping to the next line.
– Shrink to fit cell size – reduces the apparent size of the font so that the contents of the
cell fit into the current cell width. You cannot apply this command to a cell that contains
line breaks.
– Text direction – choices are Left-to-right, Right-to-left, and Use superordinate
object settings (the settings applied to the preceding cell).

Asian Typography tab


If Asian language support is enabled, the Asian Typography tab is displayed on the Cell Style
dialog. For more details of the options available on this tab, see the description of the
corresponding tab of the Format Cell dialog in Chapter 2, Entering and Editing Data.

Figure 100: Cell Style dialog - Asian Typography tab

Borders tab
Sets the border attributes for the selected cells.
• Line Arrangement – select a preset border style or define your own combination by
clicking in the diagram.
• Line – select the line style, thickness, and color that you want to apply. The style is
applied to the borders selected in the preview.
• Padding – specify the amount of space that you want to leave between the border and
the contents of the cell. You can set each distance (left, right, top, bottom) individually or
select Synchronize to apply the same padding to all four borders when you enter a new
value.

Chapter 4 Using Styles and Templates | 127


Figure 101: Cell Style dialog – Borders tab
• Shadow Style – applies a shadow effect to borders. You can specify the position of the
shadow (bottom right, top right, bottom left, or bottom right), the distance it extends, and
its color.

Background tab
Click Color to select a color to use as a background for the formatted cells. You can choose
from several palettes. To change the color, select another one. To remove the background color,
select None.

Figure 102: Cell Style dialog – Background tab

128 |Calc Guide 24.8


Cell Protection tab
In this tab you can set some basic protection to you spreadsheet.
Protection
• Hide all – hides formulas and contents of the selected cells.
• Protected – prevents the selected cells from being modified. This cell protection only
takes effect if you also protect the sheet.
• Hide formula – hides formulas in the selected cells.
Print
• Hide when printing – prevents the selected cells from being printed.

Figure 103: Cell Style dialog – Cell Protection tab

Resetting cell style attributes


The buttons at the bottom of the Cell Style dialog have the following functions:
• Reset – returns values on the current tab to those applicable when the dialog was
opened.
• Standard – for a style that inherits settings from a parent style, updates the settings on
the current tab to match those of the parent style.
• Cancel – cancels any changes made (to all tabs in the dialog) since the last save of this
dialog (by clicking OK).
• OK – saves all changes made (to all tabs in the dialog).

Drawing style attributes


The Drawing Style dialog (Figure 104) in Calc is equivalent to the Graphics Styles dialog in
LibreOffice Draw. The Graphics Styles dialog is described in the Draw Guide, Chapter 4,
Changing Object Attributes, section entitled “Drawing Styles”.
The following tabbed pages are provided on the Drawing Style dialog (Figure 104).
• Organizer. This tab is similar to the Organizer tab of the Cell Style dialog (Figure 95).
• Line. Set line properties (style, color, width, and transparency), arrow styles, and corner
and cap styles.
• Area. Set the fill options (none, color, gradient, image, pattern, or hatch).

Chapter 4 Using Styles and Templates | 129


• Shadowing. Add a shadow and set the properties of the shadow (position, color,
distance, blur, and transparency).
• Transparency. Set the area transparency mode. This may be no transparency, fixed
transparency (expressed as a percentage), or gradient transparency (linear, axial, radial,
ellipsoid, square, or rectangular).
• Font. This tab is similar to the Font tab of the Cell Style dialog (Figure 97).
• Font Effects. This tab is similar to the Font Effects tab of the Cell Style dialog (Figure 98).
• Indents & Spacing. Set paragraph indenting, paragraph spacing and line spacing
options.
• Text. Set layout and anchoring properties for text, covering drawing object text, custom
shape text, spacing to borders, and text anchor type.
• Text Animation. Add a text animation effect (blink, scroll through, scroll back and forth, or
scroll in) and set its properties.
• Dimensioning. Set line and legend properties for dimension lines.
• Alignment. Set the alignment of paragraphs relative to margins and select the text
direction.
• Asian Typography. This tab is similar to the Asian Typography tab of the Cell Style dialog
(Figure 100).
• Tabs. Set the position, type, and fill character for tab stops.
• Highlighting. This tab is similar to the Background tab of the Cell Style dialog (Figure
102).
Additional information can be found in the Draw Guide and the system help.

Figure 104: Drawing Style dialog - Organizer tab

130 |Calc Guide 24.8


Page style attributes
The following attributes are available on the tabs of the Page Style dialog (Figure 105).

Organizer tab
This tab is similar to the Organizer tab for the Cell Style dialog, although page styles cannot
inherit settings from other styles.
• Name – displays the name of the selected style. If you are creating or modifying a
custom style, you can enter or change the name of the style. You cannot change the
name of a predefined style.
• Category – displays the category of the current style. If you are creating or modifying a
new style, select Custom Styles in the list. You cannot change the category for a
predefined style.
• Contains – describes the formatting used in the style.

Page tab
You can define page layouts for single and multiple-page spreadsheets, as well as page
numbering and paper formats.
• Paper Format – select from a list of predefined paper sizes, or define a custom paper
format.
– Format – select a predefined paper size, or create a custom format by entering the
dimensions for the paper in the Height and Width boxes.
– Width – displays the width of the selected paper format. To define a custom (user)
format, enter a width here.
– Height – displays the height of the selected paper format. To define a custom (user)
format, enter a height here.
– Orientation – Portrait displays and prints the spreadsheet with the paper oriented
vertically. Landscape displays and prints the spreadsheet with the paper oriented
horizontally.
– Text direction – select the text direction that you want to use in your document. The
"right-to-left (vertical)" text flow direction rotates all layout settings to the right by 90
degrees, except for the header and footer. This option is only available if Complex
text layout is selected at Tools > Options > Languages and Locales > General.
– Preview Field – displays a preview of the current selection.
– Paper tray – select the paper source for your printer. You can assign different paper
trays to different page styles. For example, you can assign a different tray for the first
page style in the spreadsheet and load the tray with your company letterhead paper.
• Margins – specify the amount of space to leave between the edges of the paper and the
spreadsheet contents.
– Left/Inner – the space between the left edge of the page and the spreadsheet. If you
are using Mirrored page layout, enter the space between the inner edge of the paper
and the spreadsheet. You may want to have a wider space as the left/inner margin if
you will be punching or binding the pages.
– Right/Outer – the space between the right edge of the paper and the spreadsheet. If
you are using Mirrored page layout, enter the space between the outer edge of the
paper and the spreadsheet.
– Top – enter the space between the upper edge of the paper and the spreadsheet.

Chapter 4 Using Styles and Templates | 131


– Bottom – enter the space between the lower edge of the paper and the spreadsheet.

Figure 105: Page Style dialog – Page tab


• Layout settings – select the page layout style to use for the spreadsheet.
– Page layout – Right and left – both odd (right) and even (left) pages have the same
margins on all four sides. Mirrored – odd and even pages with inner and outer margins
as specified (Use this layout if you want to bind the printed pages like a book. Enter
the binding space as the Inner margin). Only right – the current page style shows only
odd (right) pages (Even pages are shown as blank pages). Only left – the current page
style shows only even (left) pages (Odd pages are shown as blank pages).
– Page numbers – select the page numbering format to use for the page style. Typically
this will be 1,2,3; or a,b,c; or i,ii,iii.
– Table alignment – Horizontal centers the cells horizontally on the printed page. Vertical
centers the cells vertically on the printed page (the Preview Field will change
according to the selected in this option).

Borders and Background tabs


The Borders and Background tabs of the Page Style dialog are similar to those on the cell Style
dialog. See “Borders tab” and “Background tab” in “Cell style attributes” above for information on
how to set the borders and background for page styles. Page styles can have a bitmap
background, which is not available for cell styles.

Header and Footer tabs


Adds a header or footer to the page style. A header is an area in the top page margin where you
can add text or graphics. A footer is a similar area in the bottom page margin. See Chapter 7,
Printing, Exporting, Emailing, and Signing for details.

132 |Calc Guide 24.8


Sheet tab
Specifies the elements to be included in the printout of all sheets with the page style.
Additionally, you can set the print order, the first page number, and the page scale. See
Chapter 7, Printing, Exporting, E-mailing, and Signing for details.

Using themes
Using spreadsheet themes
Calc comes with a predefined set of formatting themes that you can apply to spreadsheets. It is
not possible to add new themes to Calc and the predefined styles cannot be modified. You can
modify styles after you apply them to a spreadsheet, but the modified styles are only available
for use for that spreadsheet.
To apply a theme to a spreadsheet:
1) Go to Format > Spreadsheet Theme on the Menu bar, or click the Spreadsheet Theme
icon on the Tools toolbar, to open the Theme Selection dialog (Figure 106), which lists
the available themes for the whole spreadsheet.
2) Select the theme that you want to apply. As soon as you select a theme, the theme styles
are applied to the spreadsheet and are immediately visible.
3) Click OK.

Figure 106: Theme Selection dialog


Using spreadsheet themes is effective when you format a range in the spreadsheet as a table.
Selecting a spreadsheet theme adds new cell styles to the spreadsheet and modifies the Default
cell style. The added cell styles are:
• “Card” cell styles: Column Header, Card, Card B (bottom), Card BL (bottom left), Card
BR (bottom right), Card L (left), Card R (right), Card T (top), Card TL (top left), and Card
TR (top right) of the selected range.
• Background: The background style of the range. Apply this style to the table contents
not in the table edges.
• Input: Used for data input. This cell style has the cell protection property unchecked.
• Result2: A secondary option for formula results.

Chapter 4 Using Styles and Templates | 133


If required, you can now use the Styles deck on the Sidebar to modify specific styles. These
modifications do not modify the spreadsheet theme; they only change the appearance of the
style in the spreadsheet you are creating.

Using document themes


Document themes collect various format selections into a set that can be applied and changed
quickly. LibreOffice supplies several sets of theme colors, and you can define other sets (see
Chapter 16, Setting up and Customizing). Theme colors have names like Dark 1, Light2, Accent
3, and so on. They can be used in styles or applied manually.
To set up a spreadsheet to use themes, choose colors for fonts, backgrounds, or objects from
the Theme colors palette (Figure 107), not an ordinary color palette. The first row of the palette
contains the theme colors, with other rows containing modifications. For example, the top-left
color in the palette is the currently selected theme’s Dark 1 color; the leftmost color in the second
row is a 50% lighter version of Dark 1; the entry at the intersection of the second column and
third row is a 15% darker version of Light1; and so on. You can hover the pointer over any
palette cell to see a tooltip indicating the detail of that color.

Figure 107: A palette of theme colors


To change the set of theme colors, choose Format > Theme on the Menu bar and select a
different theme in the Theme dialog (Figure 108). Colors defined as theme colors change in the
document. You need not change any style and need not change any object individually.

Figure 108: Theme dialog


Figure 109 shows an example in which the background colors of cells in the range B3:B14 have
been set to the theme color indicated by the corresponding labels in cells A3:A14. Initially, the
default LibreOffice theme was applied and this is shown on the left of the figure. The transition to

134 |Calc Guide 24.8


the configuration on the right of the figure requires only a cosmetic change to the text in cell B1
and selection of the Sunset theme via Format > Theme on the Menu bar.

Figure 109: Example of changing a document's theme

Managing styles
Modifying styles
1) Go to the Styles deck on the Sidebar and click the icon for the type of style you want to
modify.
2) Right-click on the name of the style and select Modify in the context menu to open either
the Cell Style dialog (Figure 95), or the Drawing Style dialog (Figure 104), or the Page
Style dialog (Figure 105).
3) Make the necessary changes to the style attributes. For more information on style
attributes, see “Cell style attributes”, Drawing style attributes, and “Page style attributes”.
4) Click OK to save the changes and close the dialog.

Note
The Modify command is unavailable if one or more sheets are protected, even if the
cell style to be modified is being used in an unprotected sheet.

Renaming styles
You can rename custom styles, but not the styles supplied with Calc.
1) Go to the Styles panel on the Sidebar (Figure 91) and click the icon for the type of style
you want to rename.
2) Right-click on the style you want to rename and select Modify in the context menu to
open either the Cell Styles dialog, the Drawing Style dialog, or the Page Styles dialog.
3) On the Organizer tab, rename the style, and click OK.

Deleting styles
You can delete custom styles, but not the styles supplied with Calc. Custom cell styles can only
be deleted if they are not applied. If an applied page style is deleted, affected sheets revert to
the Default page style.
1) Go to the Styles deck in the Sidebar (Figure 91) and click the icon for the type of style
you want to delete.

Chapter 4 Using Styles and Templates | 135


2) Right-click on the style you want to delete and select Delete in the context menu.
3) Select Yes on the warning message, if displayed.

Hiding and showing cell styles


You can shorten the list of cell styles by hiding some of them. Only styles that are not being used
in the spreadsheet can be hidden.
1) Go to the Styles deck in the Sidebar and click on the Cell Styles icon.
2) Right-click on an unused cell style and select Hide in the context menu. The style is then
moved to the Hidden Styles category in the Styles deck.
To show hidden cell styles:
1) Go to the Styles deck on the Sidebar.
2) Click on the drop-down list at the bottom of the panel and select Hidden Styles in the
list.
3) To revert, right-click on the hidden style you want to show and select Show in the context
menu.

Filtering the list of styles


You can filter the list of styles as follows:
1) Go to the Styles deck on the Sidebar.
2) Click on the drop-down list at the bottom of the panel.
3) Select the category of styles to display on the Styles deck:
– Hierarchical – lists the styles in their hierarchical relationship, for example Heading 1
and Heading 2 under Heading, or Accent 1, Accent 2, Accent 3 under Accent.
– All Styles – lists all the styles that are available in Calc and in the spreadsheet, except
for hidden styles, in alphanumeric order.
– Hidden Styles – lists all the styles that have been hidden in the spreadsheet.
– Applied Styles – lists only the styles that have been applied to the spreadsheet. Not
applicable for page styles.
– Custom Styles – lists only the user-defined styles defined for the spreadsheet.

What is a template? Why use one?


A template is a model that you use to create other documents in a standard format. For example,
you can create a template for invoices that has your company logo and address at the top of the
page. This means that any new spreadsheets (invoices) created from this template will have the
company logo and address on the first page of the spreadsheet.
A significant advantage of using templates is that when a spreadsheet is created, the custom
styles of the template are integrated into the new spreadsheet, so you will already have your
styles defined without needing to create or modify them.
Templates can contain anything that regular documents can contain, such as text, graphics,
styles; user-specific setup information such as measurement units, language, default printer; and
toolbar and menu customization.
All documents in LibreOffice are based on templates. You can create, or download and install, as
many templates as you wish. If you do not specify a template when you start a new spreadsheet,

136 |Calc Guide 24.8


then that new spreadsheet is based on the included Calc default template. This default template
consists of a blank spreadsheet which you can customize to your needs and then, if you wish,
use as a basis to create a custom default template.

Using a template to create a spreadsheet


A new installation of LibreOffice may not include any spreadsheet templates other than the Calc
default, but you can create your own (see “Creating a template”) or install templates obtained
from other sources (see “Adding templates obtained from other sources”).
When you have an available spreadsheet template, you can use it to create a new spreadsheet
from the Templates dialog or the LibreOffice Start Center.

Creating a spreadsheet from the Templates dialog


To use a template to create a spreadsheet:
1) On the Menu bar, choose File > New > Templates, or click the small arrow next to the
New icon on the Standard toolbar and select Templates, or press Ctrl+Shift+N. The
Templates dialog (Figure 110) opens.
2) In the Filter lists at the top of the Templates dialog, select Spreadsheets and the
category of template you want to use. All the templates in that category are then listed on
the page, as shown in Figure 110.
3) Select the required template and click Open, or double-click the required template, or
right-click the required template and select Open in the context menu. A new
spreadsheet based on the template opens in Calc.
In the spreadsheet, the template it is based upon is listed in File > Properties > General. The
connection between a template and a spreadsheet remains until that template is modified. The
next time a spreadsheet based on that template is opened, you can choose either to update, or
not update, the spreadsheet to match the modifications.
Figure 110 shows the default configuration for the Templates dialog, with the available templates
represented by thumbnails. It is also possible to view the available templates in a list format that
includes additional information which may help identify the template of interest, as shown in
Figure 111. To switch between these two views, use the Thumbnail View and List View icons
located at the bottom left of the dialog.

Figure 110: Templates dialog, showing a selected template in thumbnail view

Chapter 4 Using Styles and Templates | 137


Figure 111: Templates dialog, list view

Creating a spreadsheet from a template in the Start Center


You can create a spreadsheet from the Template view of the LibreOffice Start Center, which is
visible when no other document is open. (See Chapter 1, Introduction.)
Click the Templates button in the left pane and icons are displayed in the Start Center for all
available LibreOffice templates. At the top left of the Start Center is a Filter drop-down list to
select the templates of a given type of document. If you select the Spreadsheets option on the
list, only the available spreadsheet templates are displayed in the Start Center. Click on the
required template to create a new document based on that template.

Creating a template
You can easily create a template from any spreadsheet:
1) Open a new or existing spreadsheet that you want to use as a base for the template.
2) Add any necessary pre-defined content that you want to appear in a spreadsheet each
time you use the new template, for example company logo and name, company
information, page numbers, and so on. Delete any information that you do not want in the
template.
3) Create or modify the cell, drawing, and page styles that you want to use in the template.
4) On the Menu bar, choose File > Templates > Save as Template, or click the down
arrow at the right of the Save button on the Standard toolbar and select Save as
Template, or press Shift+F11. The Save As Template dialog (Figure 112) opens,
displaying the existing template categories and a name box.
5) Type a name for the new template and select the required template category. You can
also choose to make this the default template (see “Setting the default template” for more
information).
6) Click Save to save the new template.

Note
Although the Save as Template dialog shows no document type when saving a new
template of any type, the template will appear on the correct tab (Spreadsheets, in
this case) when you return to the Templates dialog. It is unnecessary to save or do
anything further with the spreadsheet file you have been using to create the new
template. It can be safely closed without saving.

138 |Calc Guide 24.8


Figure 112: Save As Template dialog

Note
You can also save a template through the Save As dialog, accessed by a variety of
interactions including selecting File > Save As on the Menu bar or pressing
Ctrl+Shift+S. Select the ODF Spreadsheet Template option in the Save as type
menu and navigate to the appropriate template folder before clicking the Save
button.

Editing a template
You can edit a template’s styles and content. If you wish, you can then apply the new styles to
spreadsheets that were created from the original template (see below for details).
To edit a template:
1) On the Menu bar, choose File > Templates > Manage Templates, or press
Ctrl+Shift+N, to open the Templates dialog. You can also manage templates from the
Start Center.
2) Navigate to the spreadsheet template that you want to edit. Right-click to open the
context menu and choose Edit (Figure 113). The template opens in Calc.

Figure 113: Templates dialog – Editing templates

Chapter 4 Using Styles and Templates | 139


3) Edit the template as you would edit any other spreadsheet. To save the changes, choose
File > Save on the Menu bar or perform any equivalent action. To save the edited
template as a new template, choose File > Save As Template or perform any equivalent
action.

Updating styles from a changed template


If you make any changes to a template and its styles, the next time you open a spreadsheet that
was created before you changed the template, a confirmation message is displayed.
1) Click Update Styles to apply the changed styles in the template to the spreadsheet.
2) Click Keep Old Styles if you do not want to apply the changed styles in the template to
the spreadsheet.

Caution
If you select Keep Old Styles, the confirmation message will not appear again the
next time you open the spreadsheet using the same changed template. Although the
template is still listed under File > Properties > General, the spreadsheet is no
longer connected to the template, so it will not update. You can still import styles
manually from the template, but to reconnect the spreadsheet to the template, you
need to use one of the procedures described in “Changing the template assigned to
a document” below.

Changing the template assigned to a document


You can change the template assigned to a document, or reconnect a document to a template,
in two ways: manually or using the Template Changer extension to LibreOffice.
To change or reassign a template manually, first create a new, blank document from the required
template, as described above. Then copy the contents of the old document into the new
document.
To use the Template Changer extension, first you need to download and install it, then restart
LibreOffice to activate it. After that, you can open the document and use File > Templates >
Change template (current document) on the Menu bar.
The Template Changer extension works with Writer, Calc, Draw, and Impress.

Adding templates obtained from other sources


LibreOffice refers to sources of templates as repositories. A repository can be local (a directory
on your computer to which you have downloaded templates) or remote (a URL from which you
can download templates).
To get to the official LibreOffice template repository, type https://extensions.libreoffice.org/en in
your browser’s address bar. This opens the Extensions web page. In the Search section, click
the Templates tag filter. You can narrow your search by also choosing other tag filters. After
setting the filters, click the Search button. In the search results, find the required template and
click on its name to display a page with details; click the Download button to put the template
anywhere on your computer. Proceed to “Installing templates” below.
You can also use the Extensions button in the Manage menu of the Templates dialog, as shown
in Figure 114, to open an Extensions: Templates dialog, where you can scroll through a list of
extensions. In this version of LibreOffice, there is no easy way to filter this list, so you may prefer
to go directly to the web page, as described above.

140 |Calc Guide 24.8


Figure 114: Getting more templates for LibreOffice
On other websites you may find collections of templates that have been packaged into extension
(.OXT) or .ZIP files.

Installing templates
You can import and add templates to your collection as follows:
1) Find and download the template you want to use, as described in the previous section.
2) Open the Templates dialog and click the Import button in the Manage menu.
3) In the pop-up dialog, select the category where you want to store the template. (You can
change this later, as described in “Moving a template” below.)
4) A file browser opens. Navigate to the location of the downloaded template on your
computer.
5) Select the template and click Open. After import, the template becomes available in the
Templates dialog.

Tip
You can manually copy new templates into the template folders. The location varies
with your computer’s operating system. To learn where the template folders are
stored on your computer, go to Tools > Options > LibreOffice > Paths.

Installing collections of templates


The Extension Manager provides an easy way to install collections of templates that have been
packaged as extensions. Follow these steps:
1) Download the extension package (.OXT file) and save it anywhere on your computer.
2) In LibreOffice, select Tools > Extension Manager on the Menu bar, or press
Ctrl+Alt+E. In the Extension Manager dialog, click Add to open a file browser window.
3) Find and select the package of templates you want to install and click Open. The
package begins installing. You may be asked to accept a license agreement.
4) When the package installation is complete, you may need to restart LibreOffice. The
templates are available for use through the Templates dialog and the extension is listed
in the Extension Manager.
See Chapter 15, Setting up and Customizing, for more about the Extension Manager.

Tip
Some extensions are packaged as .ZIP files.

Chapter 4 Using Styles and Templates | 141


Setting the default template
If you create a new spreadsheet using File > New > Spreadsheet on the Menu bar or an
equivalent action, Calc creates the document from the default template for spreadsheets. You
can set any template as the default template. You can also reset the default template to the Calc
default template.

Setting a template as the default


Most default settings, such as page size and page margins, can be changed but those changes
normally apply only to the spreadsheet you are working on. To make those changes the default
settings for spreadsheets, you need to replace the default Calc template with a new one.
You can set any template displayed in the Templates dialog to be the default for that document
type:
1) On the Menu bar, choose File > Templates > Manage Templates or press
Ctrl+Shift+N.
2) In the Templates dialog, open the category containing the template that you want to set
as the default.
3) Right-click on the template and click the Set as Default option (Figure 113). The
template is now indicated by a green check mark in the upper left.
The next time you create a spreadsheet by choosing File > New, by clicking the New icon on the
Standard toolbar, or by pressing Ctrl+N, it will be created from this template.

Resetting the default template


To set the default spreadsheet template back to the default template supplied with Calc:
1) In the Templates dialog, click the Manage button on the upper right (Figure 115).
2) Point to Reset Default Spreadsheet in the drop-down menu. The green check mark is
removed from the template.
This choice does not appear unless a custom template has been set as the default, as described
in the previous section.

Figure 115: Resetting the default template for spreadsheets


You can also reset the default template as follows:
1) Go to the Templates dialog and open the category containing the template you set as
default. It is indicated by a green check mark.
2) Right-click on this template and select Reset Default in the context menu. The next time
that you create a new spreadsheet, it will be created using the Calc default template.

142 |Calc Guide 24.8


Note
Resetting the default template back to the Calc default template is only available if
the default has been changed previously.

Organizing templates
LibreOffice can only manage templates that are in its template folders (categories), although you
can create a spreadsheet from a template that is not in one of these folders. You can create new
template folders and use them to organize your templates and import templates into these
folders. For example, you might have one template folder for sales templates and another for
invoice templates. You can also export templates.

Tip
The location of template folders in LibreOffice depends on the operating system of
your computer. If you want to know where the template folders are located, go to
Tools > Options > LibreOffice > Paths.
To begin, choose File > Templates > Manage Templates, or press Ctrl+Shift+N, to open the
Templates dialog.

Creating a template category


1) Click the Manage button on the Templates dialog and select New Category in the drop-
down menu (Figure 116).
2) In the pop-up dialog (not shown), type a name for the new category and click OK. The
new category now appears in the list of categories.

Note
You cannot create a sub-category inside a template category.

Figure 116: Creating a new category

Deleting a template category


You cannot delete template categories supplied with LibreOffice. Nor can you delete categories
added by the Extension Manager unless you first remove the extension that installed them.
However, you can delete a category that you created:
1) Click the Manage button on the Templates dialog and select Delete Category in the
context menu (Figure 116).
2) Select the category to be deleted in the Delete Category dialog (not shown) and click
OK.

Chapter 4 Using Styles and Templates | 143


3) Select Yes in the confirmation dialog to confirm the deletion.
4) Calc displays a warning if it is unable to delete the category.

Moving a template
To move a template from one template category to another:
1) Open the Templates dialog and select the template you want to move.
2) Right-click the template you want to move and select the Move option from the context
menu, select the destination category from the popup dialog (Figure 117), and click OK.
The selected template is moved to the folder. You can also create a new category into
which to move the template.

Figure 117: Moving a template to another category

Deleting a template
You cannot delete templates supplied with LibreOffice. Nor can you delete any templates
installed by the Extension Manager except by removing the extension that installed them. You
can only delete templates that you have created or imported.
1) In the Filter drop-down lists at the top of the Templates dialog, select the category that
contains the template you want to delete.
2) Right-click on the template that you want to delete to open the context menu and click
Delete (Figure 113).
3) A message box appears and asks you to confirm the deletion. Click Yes.

Note
Moving or deleting a template has no impact on any document that was created from
that template. The spreadsheet will retain the style definitions that it inherited from
the moved or deleted template. The Template field on the File > Properties >
General page can continue to show the name of a template that no longer exists.

144 |Calc Guide 24.8


Exporting a template
The easiest way to send a template to someone else, or to store it on a network, is to export it:
1) Open the Templates dialog and find the template that you want to export.
2) Right-click the template you want to export and select the Export option from the context
menu.
3) The Select Folder dialog opens. Navigate to the location where you want to export the
template and click Select Folder. You can also rename the template.

Note
Exporting a template does not remove it from the Templates dialog. The action
places a copy of the template in the location you specify.

Chapter 4 Using Styles and Templates | 145


Calc Guide 24.8

Chapter 5
Using Images and Graphics
Introduction
Calc is used to present and analyze data and to make forecasts and predictions. Graphics can
turn an average spreadsheet into a more memorable document. Calc can import various vector
(line drawing) and raster (bitmap or photo) file formats. Commonly used graphic formats include
GIF, JPG, and PNG. See the LibreOffice Help for a full list of the formats that Calc can import.
Graphics in Calc are of three basic types:
• Image files, such as photographs, drawings, and scanned images
• Diagrams created using LibreOffice’s drawing tools
• Charts and graphs created using LibreOffice’s Chart facility; see Chapter 3, Creating
Charts and Graphs, for more information
Using graphics in Calc is similar to using graphics in other components of LibreOffice. For more
detailed descriptions, please refer to the Getting Started Guide or the Draw Guide.

Note
In LibreOffice, the terms graphics and images refer to both pictures and drawing
objects. Often the word images is used when referring to pictures and other graphics
that are not drawing objects.

Adding graphics (images) to a spreadsheet


Images, such as corporate logos and photographs, are probably the most common types of
graphics added to a spreadsheet. They may be downloaded from the Internet, scanned, created
with a graphics program, photographs taken with a digital camera, or clip art in the Gallery.

Inserting an image file


When the image is in a file stored on the computer, you can insert it into a spreadsheet using
one of the following methods.

Drag and drop


1) Open a file browser and locate the image you want to insert.
2) Drag the image into the spreadsheet and drop it where you want it to appear.
This method embeds (saves a copy of) the image file in the document. To link the file instead of
embedding it, hold down the Ctrl+Shift keys while dragging the image. See “Linking or
embedding an image file” below for more information.

Insert Image dialog


1) Click in the spreadsheet where you want the image to appear.
2) Choose Insert > Image on the Menu bar.
3) On the Insert Image dialog (Figure 118), navigate to the file to be inserted, and select it.
4) Select the Link option if you want to link the file instead of embedding it.
5) Select the required option in the Anchor menu: To cell, To cell (resize with cell), or To
page. See “Anchoring images” below for more information about these options.
6) Click Open. The image is inserted into the spreadsheet.

148 |Calc Guide 24.8


Note
If you have selected to link the image, Calc may present a confirmation dialog with
options to continue with the link or to embed the image instead. An option is provided
on this dialog to prevent it being displayed in future.

Figure 118: Insert Image dialog

Linking or embedding an image file


Embedding an image into a spreadsheet makes the image a permanent part of the spreadsheet
file. Any changes you make to an embedded image will appear only in that spreadsheet; the
original image will not be affected.
If you select the Link option in the Insert Image dialog, or use Ctrl+Shift during the drag and
drop method, Calc creates a link to the file containing the image instead of embedding it. The
image is displayed in the document, but when the document is saved, it contains only a
reference to the image file, not the image itself. The document and the image remain as two
separate files, and they are merged together only when you open the document again.
Linking an image has two advantages and one disadvantage:
• Advantage – You can modify the image file separately. The modified image will appear
on the next time you open the spreadsheet. This can be a big advantage if you (or
someone else, perhaps a graphic artist) is updating images.
• Advantage – Linking can reduce the file size of the spreadsheet when it is saved,
because the image file itself is not included. However, file size is usually not a problem
on modern computers, and Calc can easily handle large files.
• Disadvantage – If you send the document to someone else, or move it to a different
computer, you must also send the image files and keep the same file structure. For
example, you might keep image files in a subfolder named Images inside the same folder
containing the Calc document. Any recipient of the spreadsheet needs to put the image
files in a subfolder with the same name in the same named folder as the spreadsheet.

Note
When inserting the same image several times in a document, it might appear
beneficial to create links. However, this is not necessary, as LibreOffice embeds only

Chapter 5 Using Images and Graphics | 149


one copy of the image file in the document. Deleting one or more of the copies does
not affect the other copies of the same file.

Embedding linked images


If you originally linked the images, you can easily embed one or more of them later.
1) Open the spreadsheet in Calc.
2) Choose Edit > Links to External Files on the Menu bar to open the Edit Links dialog
(Figure 119), which shows all the linked files.

Figure 119: Edit Links dialog


3) Select the files you want to change from linked to embedded.
4) Click Break Link and confirm you want to remove the selected link. The file then
becomes embedded into the spreadsheet.

Note
Going from embedded to linked images is not so easy. You must replace them one at
a time, selecting the Insert as Link option when you reinsert each file.

Inserting an image from the clipboard


Using the clipboard, you can copy images into a Calc spreadsheet from another LibreOffice
document and from other programs. To do this:
1) Open both the source document and the target document.
2) In the source document, copy the image to the clipboard – the exact interactions will vary
from program to program.
3) Switch to the target document and click to place the cursor in the cell where the image is
to be anchored.
4) Select Edit > Paste on the Menu bar, or click the Paste icon on the Standard toolbar, or
right-click and select Paste in the context menu, or press Ctrl+V.

Caution
If the application from which the image was copied is closed before the image is
pasted into the target, the image stored on the clipboard could be lost.

150 |Calc Guide 24.8


Inserting an image using a scanner
If a scanner is connected to your computer, Calc can call the scanning application and insert the
scanned item into the document as an image. To start this procedure, choose Insert > Media >
Scan > Select Source. After selecting the scanner, place the cursor where you want the image
to be inserted, and choose Insert > Media > Scan > Request.
Although this practice is quick and easy, it is unlikely to result in a high-quality image of the
correct size. You may get better results by passing scanned material into a graphics program
and cleaning it up there, before inserting the resulting image into Calc.

Inserting an image from the Gallery


The Gallery (Figure 120) provides a convenient way to group reusable objects such as images
and sounds that you can insert into your documents. The Gallery is available in all components
of LibreOffice. You can add your own images as well as using the ones supplied with LibreOffice.
For more information, see the Getting Started Guide.

Figure 120: The Gallery in the Sidebar


To insert an image from the Gallery:
1) Click the Gallery icon on the Sidebar, or select View > Gallery on the Menu bar.
2) Select a theme.
3) Select an object with a single click.
4) Drag and drop the image into the document.
5) Alternatively right-click on the object in the Gallery and choose Insert in the context
menu, in which case the image will be positioned according to the cells selected in the
spreadsheet.

Tip
If you wish to use gallery images from earlier versions of LibreOffice, go to
https://extensions.libreoffice.org/ and search for items with a tag filter of “Gallery” or
click on the Add more galleries via extension button, on the bottom right of the
Gallery to open the Extensions: Gallery dialog.

Chapter 5 Using Images and Graphics | 151


Modifying images
When you insert a new image, you may need to modify it to suit the document. Any changes
made in Calc do not affect the original image, whether it is an embedded or a linked image file.
Calc provides several tools for working with images. These tools are sufficient for most
requirements. However, for professional results it is generally better to use Draw or other
software designed to modify image files, and then insert the result into Calc.

Using the Image toolbar


When you insert an image or select one already present in the spreadsheet, the Image toolbar
(Figure 121) replaces the Formatting toolbar. If it does not appear, go to View > Toolbars >
Image on the Menu bar. The tools available on the Image toolbar are described below.

Figure 121: Image toolbar

Note
Changes to image properties affect only the display and printing of the image. The
original image file remains unchanged.
• Anchor – choose between anchoring the image to a cell (with or without resize) or to a
page. See “Anchoring images” below.
• Align Objects – if two or more images are selected, you can adjust the horizontal and
vertical alignment of the images in relation to each other. See “Aligning images” below.
• Six buttons for arrangement (positioning images in the stacking order): Bring to Front,
Forward One, Back One, Send to Back, To Foreground, To Background. See
“Arranging images” below.
• Line Style, Line Width, Line Color – set the attributes of the border around the image.
• Area Style / Filling – sets the color or other characteristics of the background area that
contains the image, not the image itself. To see the background, you must set the
transparency of the image to a suitably high value. See the Draw Guide for more
information on how to modify areas.
• Shadow – sets the default shadow effect around the image. To adjust the shadow effect,
open the Area dialog (Format > Object > Area) and choose the Shadow tab.
• Filter – opens the Image Filter toolbar. See the Draw Guide for details on image filters.
• Image Mode – changes the display of the image from color (Default) to grayscale, black
and white, or a watermark. This setting affects only the display and printing of the image;
the original image file remains unchanged.
• Crop Image – places cropping handles around the image. Drag a handle to crop (hide)
the edges of the image.
• Flip Horizontally and Flip Vertically – changes the orientation of the image.
• Rotate – places rotation handles around the image.

152 |Calc Guide 24.8


• Transparency – adjusts the degree of transparency of the image between 0% (opaque)
and 100% (fully transparent).
• Color – opens the Color toolbar (Figure 122) to adjust the values of the red, green, blue
colors, brightness, contrast and gamma.

Figure 122: Color toolbar

Using the Properties deck in the Sidebar


Some of the settings in the Image toolbar are also available in the Properties deck on the
Sidebar when an image is selected. The options in the Properties deck include the Image, Line,
Position and Size, and Columns settings.

Adding text
You can add text to an image or drawing object. That text will move with the image when the
image is re-positioned. For more information on adding text to images, see the Draw Guide.
1) Double-click on the image. The text cursor flashes in the center of the image. The Text
Formatting toolbar automatically opens at the top of the spreadsheet.

Figure 123: Text Formatting toolbar for images


2) Type your text and use the tools on the Text Formatting toolbar to format it. Most of the
tools are the same as those for formatting text in cells.
3) To adjust the position of the text or how it appears in the image, right-click on the image
(when the text cursor is flashing) and select Text in the context menu to open the Text
dialog (Figure 124).
4) Make any necessary changes and click OK to close the dialog.

Chapter 5 Using Images and Graphics | 153


Figure 124: Text dialog

Positioning, resizing, and arranging images


Using the mouse
To move an image to a new position in your spreadsheet, click on the image and drag it to a new
position. The image will still be anchored as it was originally.
To resize an image:
1) Click on the image to display the selection handles.
2) Position the mouse pointer over one of the selection handles. The pointer changes
shape, giving a graphical representation of the direction of the resizing. The corner
handles resize both the width and the height of the image simultaneously. The top,
bottom, left and right handles only resize one dimension at a time.
3) Click and drag to resize the image.

Tip
To retain the original proportions of the image, click and drag one of the corner
handles. If you want to change the original proportions, Shift+Click one of the
corner handles, then drag.

Using the Position and Size dialog


To accurately position and size an image in your spreadsheet, click on the image and then go to
Format > Object > Position and Size on the Menu bar, or right-click on the image and select
Position and Size in the context menu.
On the Position and Size tab (Figure 128) of the Position and Size dialog, you can set these
values:
• Position – the location of the selected image on the spreadsheet.
– Position X – the horizontal distance from the base point selected in the grid.
– Position Y – the vertical distance from the base point selected in the grid.

154 |Calc Guide 24.8


• Size – the width and height of the image with respect to the selected base point.
• Protect – to prevent accidental movement or resizing of the image, select the relevant
option.
The units of measurement used for X / Y coordinates and the width and height of the image are
set by going to Tools > Options > LibreOffice Calc > General > Measurement unit.
The default location of the base points for position and size is the upper left corner of the
spreadsheet. You can temporarily change this base point to make positioning or dimensioning
simpler by clicking on a position corresponding to the location of the base point you want to use.
This change in base point is only valid for single use and the base point is reset to the standard
position of top left corner when you close the Position and Size dialog.
You can also rotate or slant an image (using the Rotation or Slant & Corner Radius tabs of the
Position and Size dialog). See the Draw Guide for details.

Arranging images
Each image that you place in a spreadsheet is successively stacked on the preceding image,
whether or not they overlap. Use the arrange commands to change the stacking order of
images. You cannot change the stacking order of text.
1) Select the image you want to change.
2) Go to Format > Arrange on the Menu bar, or right-click on the image and select
Arrange in the context menu, then select one of the available arrangement options.
3) Alternatively, click on one of the six arrangement icons on the Image toolbar to quickly
move the image up or down the stacking order.
The arrangement options are as follows:
• Bring to Front – moves the selected image to the top of the stacking order, so that it is
in front of other images.
• Forward One – moves the selected image up one level, so that it is closer to top of the
stacking order.
• Back One – moves the selected image down one level, so that it is closer to the bottom
of the stacking order.
• Send to Back – moves the selected image to the bottom of the stacking order, so that it
is behind the other images.
• To Foreground – moves the selected image in front of text.
• To Background – moves the selected image behind text. To select a background image
so that you can modify or replace it, you have to use the Navigator. Other methods of
selection, such as clicking or double-clicking, do not work.

Anchoring images
Anchor images so they stay in their position in relation to other items.
• To Page – anchor an image to the page to position it in a specific place. The image does
not move when cells are added or deleted; it will always stay in the same position on the
page where it is placed.
• To Cell – anchor an image to a cell to ensure that the image always stays with the
content it is originally anchored to. If an image is anchored to cell B10, and a new row is
inserted above row 10, the image will then be anchored to cell B11.

Chapter 5 Using Images and Graphics | 155


• To Cell (resize with cell) – similar to To Cell but with the additional property that the
image resizes as you resize the cell to which it is anchored.
To anchor a selected image or change the type of anchor used:
• Go to Format > Anchor on the Menu bar, or right-click on the image and select Anchor
in the context menu, or click on the Anchor icon on the Image toolbar.
• Select To Page, To Cell, or To Cell (resize with cell) in the menu.

Tip
Use Fit to Cell Size in the graphic (image) context menu to resize the image to the
cell dimensions. You may want to adjust the row height and column width
accordingly.

Aligning images
When you have more than one image in your spreadsheet, you can align these images to give
your spreadsheet a more professional look. The options include three for aligning the images
horizontally (left, centered, right) and three for aligning the images vertically (top, center,
bottom).
1) Select all of the images to be aligned (select one and hold down the Shift key while
selecting others).
2) Go to Format > Align Text on the Menu bar, or click the down arrow at the right of the
Align Objects icon on the Image toolbar, or right-click on one of the images and select
Align Objects in the context menu.
3) Select one of the options available for alignment.

Tip
Press the main area of the Align Objects icon on the Image toolbar (to the left of its
down arrow) to quickly left align the selected images.

Grouping and ungrouping images


To group several images so that they become a single object in the spreadsheet:
1) Select the images you want to group (select one and hold down the Shift key while
selecting others).
2) Go to Format > Group > Group on the Menu bar, or right-click on one of the selected
images and select Group in the context menu.

Note
When grouping images, the resulting image is anchored To Page. You can change
the anchor as usual.
To ungroup images:
1) Select the image group you want to ungroup.
2) Go to Format > Group > Ungroup on the Menu bar, or right-click on one of the selected
images and select Ungroup in the context menu.
To edit an image in a group:
1) Select the image group where you want to edit an image within the group.

156 |Calc Guide 24.8


2) Go to Format > Group > Enter Group on the Menu bar, or right-click on one of the
selected images and select Enter Group in the context menu.
3) Select the image you want to make changes to and make the changes.
4) Go to Format > Group > Exit Group on the Menu bar, or right-click on one of the
selected images and select Exit Group in the context menu.

Using LibreOffice’s drawing tools


Calc, like all other components of LibreOffice, has a range of tools to create drawings such as
simple diagrams, using rectangles, circles, lines, text, and other shapes. You can group several
drawing objects to make sure they maintain their relative position and proportion if you move or
resize them.
You can also use the drawing tools to annotate photographs, screen captures, or other
illustrations produced by other programs, but this is not recommended. If you need to create
complex drawings, it is recommended to use LibreOffice Draw and then insert the drawing into
your spreadsheet. For a more detailed explanation, see the Draw Guide.

Drawing toolbar
To begin using the drawing tools, go to View > Toolbars > Drawing to open the Drawing toolbar,
which appears in its default position at the bottom of the spreadsheet. You can make this toolbar
a floating toolbar and move it to a more convenient position.
When the Drawing toolbar opens, it displays a default set of tools as shown in Figure 125. Hover
the mouse pointer over a tool to see a tooltip describing its function. Icons with small arrows on
the right side open with palettes of tools. To add tools to the Drawing toolbar, right-click in an
empty area on the toolbar and select Visible Buttons from the context menu.

Figure 125: Drawing toolbar


To use a drawing tool:
1) Click on the tool in the Drawing toolbar (Figure 125). The mouse pointer changes to a
drawing-functions pointer and the normal Formatting toolbar changes to the Drawing
Object Properties toolbar (Figure 127).
2) Move the cross-hair pointer to the place in the document where you want the drawing
object to appear and then click and drag to create the object. Release the mouse button.
The selected drawing function remains active, so that you can draw another object of the
same type.
3) To cancel the selected drawing function, click on the tool’s icon again, press the Esc key,
or click on the Select icon (the arrow) on the Drawing toolbar.
4) You can now change the properties (fill color, line type and weight, anchoring, and
others) of the drawing object using the Drawing Object Properties toolbar (Figure 127),
the Properties deck on the Sidebar, or the choices reached by right-clicking on the
drawing object.

Setting the properties of drawing objects


For more information on the properties of drawing objects, see the Draw Guide.

Chapter 5 Using Images and Graphics | 157


You can set some default properties for a drawing object before you draw an object. These
default properties are applied only to the current spreadsheet and are not retained when you
close the spreadsheet. The properties apply only to drawing objects.
1) Click Select on the Drawing toolbar (Figure 125).
2) On the Drawing Object Properties toolbar (Figure 126), some controls are active, so you
can set the default values you want to use for each property. When you select area or
line properties, palettes open where you can choose the values to be used for areas or
lines.

Figure 126: Drawing Object Properties toolbar


3) After you draw an object or group it with another object, more properties become active.
These appear on the toolbar (Figure 127) and some are shown in the Properties deck of
the Sidebar (Figure 129).

Figure 127: Drawing Object Properties toolbar after inserting an object


You can change the properties of an existing drawing object (fill color, line type and weight,
anchoring, and so on) using the Drawing Object Properties toolbar (Figure 126), the Properties
deck on the Sidebar, or the context menu when you right-click on the drawing object.

Figure 128: Position and Size dialog – Position and Size tab

158 |Calc Guide 24.8


Figure 129: Properties deck in Sidebar for drawing object

Resizing drawing objects


Select the object and click on one of the selection handles then drag the object to its new size.
For a scaled resizing, select one of the corner handles and keep the Shift key pressed while
dragging the handle. For more information, see “Positioning, resizing, and arranging images”
above.

Grouping and ungrouping drawing objects


For grouping, ungrouping, and editing grouped drawing objects, see “Grouping and ungrouping
images” above.

Chapter 5 Using Images and Graphics | 159


Additional tools
Some additional tools are available when you right-click on an image or drawing object and open
the context menu.
Description
You can add metadata in the form of a title and description to an image. This information
is used by accessibility tools (such as screen reader software) and as ALT (alternative
text) attributes if you export the document to HTML.
Name
You can add a custom name to be assigned to an image; this will make the image easier
to find in the Navigator. Also, assigning names to images helps identify them when teams
of people are working on the same multi-page spreadsheet.
Rotate or Flip
You can rotate the image or flip it horizontally or vertically.
Assign Macro
Opens the Assign Macro dialog so you can add programmable functionality to the
graphic. Calc has a very good macro functionality. For more information, see Chapter 13,
Macros.
Edit Hyperlink
You can define a hyperlink from an image to another location in your spreadsheet,
another document, or a web page. Select Edit Hyperlink in the context menu to open
the Hyperlink dialog. See Chapter 11, Linking Data, for more information on hyperlinks.
Compress
You can compress images to reduce the file size of the spreadsheet. Select Compress
in the context menu to open a Compress Image dialog where you can set the
compression options. (Option not available for drawing objects.)
Edit with External Tool
You can edit an image with an external tool. The dialog that opens will depend on your
computer setup. (Option not available for drawing objects.)

Using Fontwork
With Fontwork, you can create graphical text art objects to make your work more attractive.
There are many different settings for text art objects (line, area, position, size, and more), so you
have a large choice.
Fontwork is available with each component of LibreOffice, but you will notice small differences in
the way that each component displays it.

Creating a Fontwork object


1) On the Fontwork toolbar (View > Toolbars > Fontwork, see Figure 130) or the Drawing
toolbar (View > Toolbars > Drawing), click the Insert Fontwork Text icon.

Figure 130: Fontwork toolbar


2) In the Fontwork Gallery (Figure 131), select a Fontwork style, then click OK. The
Fontwork object will appear in the document.

160 |Calc Guide 24.8


3) Double-click the object to edit the Fontwork text (Figure 132). Select the text and type
your own text in place of the black Fontwork text that appears over the object.
4) Click anywhere in a free space or press Esc to apply your changes.

Figure 131: The Fontwork Gallery

Figure 132: Editing Fontwork text

Editing a Fontwork object


Now that the Fontwork object is created, you can edit some of its attributes. To do this, you can
use the Fontwork toolbar, the Formatting toolbar, or menu options. For more information, see the
Getting Started Guide.

Generating a QR or Barcode
The QR and Barcode generation feature allows you to encode any text string or URL as a
barcode or QR code and insert it into your spreadsheet as an image.

Chapter 5 Using Images and Graphics | 161


Choose Insert > OLE Object > QR and Barcode on the Menu bar to open the QR and Barcode
dialog (Figure 133).

Figure 133: QR and Barcode dialog


Fill in the URL/Text field, select an Error correction factor (the complexity of the graphic
generated), enter the width in dots of the border around it, and then click OK. Figure 134 shows
the code generated by the inputs in Figure 133.

Figure 134: QR code example


After the QR or Barcode has been generated, it is possible to edit it by right-clicking in its image
and selecting Edit Barcode.

162 |Calc Guide 24.8


Calc Guide 24.8

Chapter 6
Creating Charts and Graphs
Presenting information visually
Introduction
Charts and graphs can be powerful tools for conveying information and Calc offers a variety of
ways to present data. They can be customized to a considerable extent, enabling information to
be shown in the clearest manner.
For readers interested in effective ways to present information graphically, two excellent
introductions to the topic are William S. Cleveland’s The Elements of Graphing Data, 2nd edition,
Hobart Press (1994) and Edward R. Tufte’s The Visual Display of Quantitative Information, 2nd
edition, Graphics Press (2001).

Chart Wizard
Use the Chart Wizard to create an initial chart using data in a spreadsheet. Then use the Chart
Wizard options to change the type of chart, adjust data ranges, and edit some chart elements.
Each change is immediately seen in the underlying chart.

Overview of Chart Wizard

Figure 135: Example data for creating a chart


To demonstrate the process of using the Chart Wizard to create charts, the data shown in
Figure 135 is used in the following sections. Here is an overview of the basic steps:
1) Select the cells containing all of the data—including names, categories, and labels—to
be included in the chart. The selection can be a single block, individual cells, or groups of
cells (columns or rows). In this example, it may be best to select the cell range A2:D8,
which will intentionally omit the overall title “Equipment Rentals” from the chart.

Tip
When the data is in one place, the Chart Wizard can guess the range and create an
initial chart even if all of the data is not selected. Before opening the Chart Wizard,
just place the cursor or select a cell anywhere in the area of the data.
2) To place a chart on the spreadsheet as an object (Figure 136) and open the Chart
Wizard dialog (Figure 137), do one of the following.
– Go to Insert > Chart on the Menu bar.
– Click the Insert Chart icon on the Standard toolbar.
3) Choose the chart type and make any other selections desired. The options are explained
below.
4) Click Finish to save the selections and close the Chart Wizard.
The following sections provide further details about using the Chart Wizard.

164 |Calc Guide 24.8


Figure 136: Example chart automatically created using the Chart Wizard

Selecting chart type


Calc offers a choice of ten basic chart types. Further options vary according to the type of chart
selected. For more information about the different chart types, see Chapter 7 Gallery of Chart
Types.

Figure 137: Chart Wizard dialog – selecting chart type


The initial chart created using the Chart Wizard is a 2D column chart. A small preview of the
selected variant is highlighted with a surrounding border, as shown in Figure 137. The name of
the variant (Normal in Figure 137) is shown below the preview.
To change chart types and options:
1) Select the type of chart from the list under Choose a Chart Type.
2) If needed, select a chart variant in the preview box by clicking on it. The options available
depend on the type of chart selected. The chart changes instantly to reflect the selection.

Chapter 6 Creating Charts and Graphs | 165


To use a 3D chart, select the checkbox 3D Look and select the type of 3D view (Realistic or
Simple). This option is available only for column, bar, pie, or area charts.
1) Click Next to make changes to data range, data series, and chart elements, explained in
greater detail below.
2) When satisfied with the chart, click Finish to close the Chart Wizard.

Note
To recreate many of the charts shown in the following sections, select the Column
chart type, Normal variant, with the 3D Look option unchecked.

Selecting data range


The data range contains all of the cells with data (including labels and categories) that should be
included in the chart. In the Data Range step of the Chart Wizard (Figure 138), manually correct
any mistakes in data selection for the chart.

Figure 138: Chart Wizard dialog – selecting data range


To use the Data Range page:
1) If necessary, change the rows and columns used as data for the chart by editing the cell
references in the Data range text box. Edit the cell references in one of these two ways:
– Directly modify the text in the Data range text box.
– Click the Select data range button to the right of the Data range box. Then use the
pointer to select the data range(s) on the spreadsheet.
2) Specify whether the data series are arranged in rows or in columns. In the example data,
shown in Figure 135, the data series are in columns.
3) Select whether to use the first row, or first column, or both, as labels.
4) Click Next to move to making changes to the data series (Figure 139).
5) When satisfied with the chart, click Finish to close the Chart Wizard.

Note
If the syntax for a data range is not correct, Calc highlights the Data range text box to
indicate the error and disables the Back, Next, and Finish buttons.

Selecting non-adjacent data


To create a complete data range from multiple cells that are not next to each other, use a
delimiter between individual ranges. For example, the English (USA) locale uses a comma as a
delimiter and “$Sheet1.A1:A5,$Sheet1.D1:D5” is a valid data range. A semi-colon is
another commonly used delimiter.

166 |Calc Guide 24.8


The appropriate delimiter depends on the option selected in the Locale setting menu on the
Formats section at Tools > Options > Languages and Locales > General. See or change the
default delimiter for a locale at Tools > Options > LibreOffice Calc > Formula. In the
Separators section, Array column shows the default delimiter.

Note
The options under Tools > Options may not be available when the chart is in edit
mode. If desired, click outside the chart to leave edit mode and see the options. Click
the chart twice to enter edit mode again.
To select non-adjacent data, do one of the following while in step 1) above:
• Manually enter the data ranges in the text box with delimiter(s) between them.
• Select the data with the mouse pointer by first clicking the Select data range button to
the right of the Data range box. Place the pointer at the end of the first data range in the
text box (otherwise the first range is selected and then deleted) and enter the delimiter.
Then drag the pointer in the spreadsheet to select the next data range.

Note
When the data is in the same document as the chart, changes to the data are
instantly reflected in the chart.

Linking to external data


Calc offers several options for linking data to external sources. This enables data (and the chart
using the data) to automatically update when the external data changes. The following types of
files can be linked: HTML, Calc, Base, CSV, Excel, and registered data sources. For further
information, refer to Chapter 12, Linking Data.

Selecting data series


The Data Series page of the Chart Wizard (Figure 139) enables fine tuning of the data. Each
data series contains a set of data that have something in common, such as the types of rental
equipment listed in Figure 135. Use the Data Series page to change the source range of each
data series and to organize how the data is presented in the chart. This includes removing
unnecessary data and specifying how data is plotted along the axes.

Organizing data series

Tip
The Chart Wizard makes initial assumptions about how the data should be
displayed, but the assumptions could be incorrect. If a chart does not look as
expected, the first thing to check is if all data series are defined correctly.
Also, check the settings on the Data Range page that define whether the data are in
rows or columns and whether the first row or first column should be considered
labels.
The names of each data series appear in the Data series list box (the middle box in Figure 139).
To organize the data series, select an entry in the Data series list and do one or more of the
following:
• To change the name of the data series, select Name in the Data ranges list on the right.
Edit the cell references in the Range for Name text box below.

Chapter 6 Creating Charts and Graphs | 167


• To change the cell references for data series categories, edit the cell references in the
Categories text box below the Data ranges box.
• Click Add to add another data series below the selected entry. The data ranges for the
new data series will then need to be defined.
• Click Remove to remove the selected entry from the Data series list.
• Click the Up or Down button to move the selected entry up or down in the Data series
list. This does not change the order in the data source table, but changes the
arrangement in the chart.

Note
Different data series must be in separate columns or rows. Otherwise Calc will
assume that they are the same data series.

Setting data series ranges


To understand how Calc treats data in charts, it is important to understand the distinction
between values and categories. Values are numeric data that vary continuously. By contrast,
categories have no mathematical relationship with each other. For example, the categories for
the chart data referred to in Figure 139 and the chart shown in Figure 136 are months of the
year.
Most Calc charts require both value and category data, with values plotted along the Y axis and
categories plotted along the X axis. The exceptions are XY (scatter) charts and bubble charts,
which use value data along both axes.

Figure 139: Chart Wizard dialog - selecting data series


Data ranges that may be defined for a specific chart type appear in the Data ranges box on the
right side of the Data Series page, shown in Figure 139. Not all data ranges may need to be
filled in.
The data ranges may include:
Border Color and Fill Color
Border and fill colors for each data point in the data series can be specified here using
numeric values for the RGBA color system. If not specified here, Calc will use default
colors. Conditional formatting can also be used. This enables data point colors to vary,
depending on whether they meet certain conditions or values. For further information,
refer to “Assigning colors” on page 188.

168 |Calc Guide 24.8


Name
When Data series in columns and First row as label are selected on the Data Range
page, Calc assumes that the column labels of the selected data are the data series
names. Thus, Calc assumes that the data series names of the data in Figure 135 are
“Canoes”, “Boats”, and “Motors”. Similarly, when Data series in rows and First column
as label are selected, Calc assumes that the row labels of the selected data are the data
series names.
The only way to change a data series name is by selecting Name in the Data ranges box
in the upper right of the Data Series page (Figure 139). To change it enter a different cell
range in the Range for Name box that appears below the Data ranges box. (Note that the
data series name is often contained in a single cell, rather than a range of cells.)
Y-Values
These are numeric values that are often plotted along the vertical axis. However, this is
not always the case. For example, while Y-values are plotted on the vertical axis in
column charts, they are plotted along the horizontal axis in bar charts.
Categories
The range for category data is defined in a separate Categories box below the Data
ranges box. Note the difference between categories and data series names. For the
data in Figure 135, the categories are the row labels while the data series names are the
column labels.

Note
XY (scatter) and bubble charts are unlike other chart types because they use value
data for their X axis rather than category data. For the XY (scatter) and bubble chart
types, the Data Series page of the Chart Wizard includes a Data labels box instead
of the Categories box displayed for other chart types. To create a set of data labels
(one for each data point), enter the required text strings into a range of spreadsheet
cells and then enter details of that cell range into the Data labels box. The labels can
then be displayed on the chart by selecting the Show category option on the Data
Labels dialog (see Figures 169 and 170).
Depending on the type of chart, other data ranges may need to be defined in addition to those
shown in Figure 139.

Selecting chart elements


On the Chart Elements page of the Chart Wizard dialog (Figure 140), add or change the title,
subtitle, axes names, and grids. Use titles that draw the attention of viewers to the purpose of
the chart and describe what they should focus on.
The chart elements for 2D and 3D charts are illustrated in Figure 141.
• The chart wall contains the graphic displaying the data.
• The chart area is the background of the entire chart.
• The chart title and subtitle, chart legend, axes labels, and axes names are in the chart
area.
• The chart floor is only available for 3D charts.

Chapter 6 Creating Charts and Graphs | 169


Figure 140: Chart Wizard dialog – selecting and changing chart elements

Figure 141: Chart elements


To add elements to a chart, do one or more of the following on the Chart Elements page (Figure
140):
• Enter a title and subtitle (if desired) in the Title and Subtitle text boxes.
• Enter names to be used in the X axis and Y axis text boxes. The Z axis text box is only
active if creating a 3D chart.
• Select the Display legend checkbox (turned on by default) and choose where to display
the legend – Left, Right, Top, or Bottom. The names in the legend are the data series
names. Specify the names in the Range for Name field on the Data Series page.
• Under Display Grids, select the Y axis or X axis check boxes to display horizontal or
vertical grid lines respectively. For some charts, the axis grids are displayed by default.
Grids are not available for pie charts. The Z axis checkbox is only active when creating a
3D chart. For further information about grids, refer to Grids on page 204.

170 |Calc Guide 24.8


Note
While clicking Finish closes the Chart Wizard, the chart remains in edit mode,
indicated by gray borders, and can still be modified. Click outside the chart in any cell
to exit the edit mode.

Using the Sidebar to change chart settings


The Properties deck of the Sidebar (Figure 142) makes some basic options readily available for
specifying the appearance of charts. To open the Sidebar, first click outside the chart to deselect
it, then go to View > Sidebar on the Menu bar or press Ctrl+F5. By default, the Sidebar opens
on the right side of the screen.

Figure 142: Sidebar Properties deck with chart selected (left) and in edit mode (right)
The contents of the Sidebar depend on whether the chart is selected or is in edit mode. The
Sidebar on the left in Figure 142 shows the Properties deck when a chart is selected (by clicking
on it once). When a chart is in edit mode (by clicking on it twice), the Properties deck on the right
in Figure 142 appears.

Tip
If you follow the directions above and the Properties deck of the Sidebar does not
appear, click the Properties icon on the upper right of the Sidebar.

Chapter 6 Creating Charts and Graphs | 171


The options available on the Properties deck of the Sidebar are also available elsewhere. They
may be found in the Menu bar, the Formatting toolbar, or context menus (made available by
right-clicking a chart element).

Note
The Sidebar can be quite useful. However, because the options are easy to see and
are available elsewhere, further references to it are not included in this chapter.

Modifying charts
The Chart Wizard establishes basic features of a chart. After using it, you may want to change
data ranges or modify the look of the chart. Calc provides many options for formatting and fine-
tuning the appearance of charts. This includes tools for editing the chart type, chart elements,
data ranges, fonts, colors, and many other options.
Modify charts in one of two ways, depending on what you want to change.
Edit object properties
Click on a chart once to edit its object properties. These include size, position on the
page, alignment, outer borders, copying, exporting, and more. See the sections starting
with “Resizing, moving, and positioning charts” on page 218 for more information.
Use edit mode
Use edit mode to change data selection and chart type as well as elements such as
axes, titles, backgrounds, grids, data series, data labels, trend lines, and more.

Overview of using edit mode


Here are some general ways to modify charts in edit mode. These are discussed in greater detail
in the following sections.
• To add an element not already in the chart, use the Insert menu on the Menu bar. Insert
titles, legends, axis labels, grids, data labels, trend lines, mean value lines, error bars,
and special characters.
• To move or change the size of titles, axis names, chart walls, and legends, click on them
once. The pointer changes to a move icon (appearance depends on the system). Drag
the element to the new location. To change the size, drag the selection handles.
• Modify elements in a few basic ways. The following methods may open the appropriate
dialog or menu. Not all of these methods will work for every element:
– Double-click the element (see an exception below).
– Select the element from the Insert menu (Figure 143) or from the Format menu
(Figure 144) on the Menu bar.
– Click the element once, then click on the Format Selection icon on the Formatting
toolbar (Figure 145).
– Select the element from the Select Chart Element drop-down list, then click the
Format Selection icon next to it on the Formatting toolbar.
– Right-click the element to open the context menu.
• Double-click titles and axis names to change their spelling. To modify the spelling of
other text, such as categories, data labels, and legend entries, change the text in the
data on the spreadsheet.

172 |Calc Guide 24.8


• Click once on a data point (such as a column or bar) to select and edit the associated
data series.
– With a data series selected, double-click a single data point to edit its properties (for
example, a single column in a column chart).

Entering edit mode


To edit or format charts, double-click on the chart to place it in edit mode. The chart is now
surrounded by a gray border. In edit mode, the Menu bar changes and the Formatting toolbar
contains a number of formatting options and icons, as discussed in the following sections.

Note
The next several sections (until “Resizing, moving, and positioning charts” on page
218) require a chart to be in edit mode.

Insert menu
In edit mode, the Insert menu on the Menu bar displays the options shown in Figure 143.

Figure 143: Insert menu when chart is in edit mode


Titles
Provides text boxes for entering chart title and subtitle as well as titles for X-, Y-, and Z-
axes, including secondary axes. For more information, see “Titles, subtitles, and axis
names” on page 177.
Legend
Specifies if a legend should be included and if so, where. For more information, see
“Legends” on page 179.
Axes
Provides options for showing or not showing axis labels. The Chart Wizard shows the
labels by default. For more information, see “Axes” on page 190.
Grids
Provides options for showing or not showing major and minor grids for X, Y, and Z axes.
To format grids, see “Grids” on page 204.

Chapter 6 Creating Charts and Graphs | 173


Data Labels
Provides options for text attributes, whether to show categories, and the position and
rotation of the labels. These labels appear on each data point. For more information, see
“Data labels” on page 197.
Trend Line
Specifies the type of regression line to be used, options for extrapolation, where the axes
should intersect, the name of the trend line, and whether and how the equation should be
displayed. The option is grayed out until a data series is selected. For more information,
see “Trend and mean value lines” on page 209.
Mean Value Lines
Displays mean value lines for selected or all data series. For more information, see
“Mean value lines” on page 213.
X Error Bars and Y Error Bars
Specifies the error category to be used, parameters, and display options for positive and
negative indicators. For more information, see “Error bars” on page 214.
Special characters
Enables the input of special characters in text strings (for example, title and subtitle). The
option is disabled if not relevant for the selected chart element. See Chapter 2, Entering
and Editing Data, for more information about inserting special characters.

Format menu
In edit mode, these settings appear on the Format menu (Figure 144) of the Menu bar.

Figure 144: Format menu when chart is in edit mode


Title
Formats the title and subtitle for the chart as well as axis names. The text must first be
entered on the Chart Elements page of the Chart Wizard or by going to Insert > Titles.
Legend
Formats the appearance and position of the legend. The legend must first be turned on
by using the Chart Elements page of the Chart Wizard or by going to Insert > Legend.

174 |Calc Guide 24.8


Axis
Formats properties such as where the axes cross each other, the scale of units, and
formatting of the axis labels.
Grid
Formats the grid lines. Use the Chart Elements page of the Chart Wizard to turn on grids
or go to Insert > Grids to turn grids on or off.
Chart Wall, Chart Floor, or Chart Area
Formats borders, area, and transparency of these elements. Note that the chart floor is
available only for 3D charts. See “Formatting chart backgrounds” on page 181 for more
information.
Chart Type
Changes the type of chart and whether it is a 2D or 3D chart. The various chart types are
explained in Chapter 7 “Gallery of Chart Types”.
Data Ranges
Sets ranges for all data in the chart and for individual data series, as explained in
“Selecting data range” on page 166 and “Selecting data series” on page 167.
3D View
Formats 3D charts and is only available for 3D charts. Note that only column, bar, pie,
and area charts can be displayed as 3D charts. See “3D charts” on page 205 for
information.
Format Selection
Opens a dialog with settings for whatever element is selected. Options may include area
fill, borders, positioning, transparency, fonts, labels, scale, and other attributes.
Position and Size
Enables precise specification of the position and size of a selected element. The position
is defined in relationship to the chart. See “Position and Size dialog” on page 219 for
more information.
Arrangement
Provides two options: Bring Forward and Send Backward. Only one option may be
active for some items. Use these options to arrange overlapping data series.

Formatting toolbar
In edit mode, the Formatting bar appears as in Figure 145. Click one of the icons to open a
dialog or turn an option on or off. The Insert and Format menus on the Menu bar, described
above, contain the same options, with one exception.
The option Select Chart Element drop-down list does not appear elsewhere. Use it to easily
select individual chart elements. It can be especially helpful when the chart is crowded or it is
otherwise difficult to select elements using the pointer. Note that options such as Data Labels or
Trend Line do not appear on this list unless they have already been inserted using the Insert
menu.

Chapter 6 Creating Charts and Graphs | 175


Figure 145: Formatting toolbar when chart is in edit mode
1. Select Chart Element 7. Data Ranges 13. Vertical Grids
2. Format Selection 8. Data Table 14. X Axis
3. Chart Type 9. Titles 15. Y Axis
4. Chart Area 10. Legend On/Off 16. Z Axis
5. Chart Wall 11. Legend 17. All Axes
6. 3D View 12. Horizontal Grids

Selecting and moving chart elements


Selecting chart elements
After double-clicking on the chart to enter edit mode, select chart elements using one of the
following methods:
• Click once on the element in the chart (to select individual data points, click twice—but
not too quickly—after clicking once on the data series).
• Select the element from the Select Chart Element drop-down list that appears on the left
of the Formatting toolbar, as shown in Figure 145.
When selected, the chart element will be highlighted with square selection handles.

Tip
When you hover the pointer over an element, Calc will display the element name,
making it easier to select the correct element. The name of the selected element also
appears in the Status Bar and it is displayed in the Select Chart Element area of the
Formatting toolbar.

Moving chart elements


You may wish to move individual elements of a chart, independent of other chart elements. For
example, you may wish to reposition the title or axis names. To do so:
1) Select the element as described above.
2) Keep pressing the mouse button. The pointer changes to the move icon (appearance
depends on computer setup).

176 |Calc Guide 24.8


3) Drag the pointer to move the element.
4) Release the mouse button when the element is in the desired location.
Alternatively, use the Position and Size dialog for some elements, as described on page 219.
Individual points or data series cannot be moved, with the exception of pie charts. Individual
wedges of a pie can be moved or the entire pie can be exploded. See “Pie charts“ on page 229
for information.
To move axis labels, see “Positioning axis, labels, and interval marks” on page 193. To move
data labels, see “Adding and formatting data labels for a data series” on page 197.

Tip
For some chart elements (such as title, subtitle, axis name, and legend), press the
arrow keys to move the object in small steps.

Note
When a 3D chart element is selected, round selection handles may appear. These
handles control the 3D angle of the element. You cannot resize or reposition the
element while they are showing. Click again to obtain the square selection handles
that allow you to resize and reposition the 3D chart graphic.

Changing chart type


To change the type of chart (bar, column, pie, line, and so on):
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Open the Chart Type dialog using one of these methods:
– Go to Format > Chart Type on the Menu bar.
– Click the Chart Type icon on the Formatting toolbar.
– Right-click on the chart and select Chart Type in the context menu.
The dialog is the same as the first page of the Chart Wizard dialog shown in Figure 137
on page 165.
3) Select the chart type and variant desired.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
For further information about the types of charts, please refer to the Chapter 7 “Gallery of Chart
types.”.

Titles, subtitles, and axis names


Creating or changing text
To create or change the text of a chart title, subtitle, or axis name:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Use one of these methods to open the Titles dialog (Figure 146):
– Go to Insert > Titles on the Menu bar.

Chapter 6 Creating Charts and Graphs | 177


– Click on the Titles icon on the Formatting toolbar.
– Right-click in the chart area and select Insert Titles in the context menu.
3) Enter or edit the text in the appropriate text box.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Tip
The text of a title (but not formatting) can be modified directly. With the chart in edit
mode, double-click on the text to directly change it. Use Shift+Enter at the end of
the line to create an additional line that splits the text.

Figure 146: Titles insertion dialog

Formatting text
Use a more extensive Titles dialog to format the appearance of a chart title, subtitle, or axis
name. To access this dialog:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to open the Titles dialog for formatting (Figure 147):
– Click Format > Title and select the desired type of title or the All Titles option.
– Click on the element in the chart, right-click, and select Format Title (or appropriate
element) from the context menu.
– Click on the element in the chart or select it in the Select Chart Element drop-down list
on the Formatting toolbar. Then select Format > Format Selection on the Menu bar
or click on the Format Selection icon on the Formatting toolbar.
3) Format titles or names as needed. The options are self-explanatory or easily researched.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

178 |Calc Guide 24.8


Figure 147: Titles formatting dialog (after selecting All Titles option)
Text inside chart's titles, text boxes and shapes (and parts thereof) can be formatted with the
Character dialog (available with the Character button in the Formatting toolbar, with the right-
click context menu, or with the top-bar menu: Format > Character). This allows, for example, to
use subscripts and superscripts in formulas annotating the chart.

Legends
When a legend is displayed, it shows data series names along with their graphical
representations, such as bars, lines, or points. It will also show trend and mean lines when those
are turned on, as shown in Figure 148.

Figure 148: Example of a chart legend at the bottom of a chart

Positioning, inserting, or deleting legends


Inserting or deleting only
To only insert or delete a legend:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Do one of the following:
– Click on the Legend On/Off icon on the Formatting toolbar. The default position for
inserting a legend is on the right side of the chart.
– Right-click in the chart area and select Insert Legend or Delete Legend in the context
menu.
3) If desired, click outside the chart to leave edit mode.

Note
The names in the legend are the data series names. They are taken from the Name
data range, discussed in “Selecting data series” on page 167. Change a legend
name by changing the text in the spreadsheet.

Chapter 6 Creating Charts and Graphs | 179


Positioning, inserting, and deleting
To position a legend using the Legend dialog (Figure 149) as well as insert or delete it:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Go to Insert > Legend on the Menu bar to open the basic Legend dialog.

Figure 149: Legend insertion dialog


3) Select or deselect the Display legend checkbox to either display or not display the
legend.
4) Select the desired location for the legend – Left, Right, Top, or Bottom.
5) Click OK to close the dialog.
6) If desired, click outside the chart to leave edit mode.

Tip
For finer positioning of the Legend, use one of the methods described in “Moving
chart elements” on page 176.

Formatting legends
For advanced editing of a legend’s appearance, a more extensive Legend dialog (Figure 150)
has several options for formatting borders, fill, fonts, transparency, and position.
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Do one of the following to open the Legend dialog (Figure 150):
– Click on the Legend icon on the Formatting toolbar.
– Select Format > Legend on the Menu bar.
– Right-click on the legend and select Format Legend in the context menu.
– Click on Legend in the Select Chart Element drop-down list on the Formatting toolbar
or click the legend in the chart to select it. Then click on the Format Selection icon on
the Formatting toolbar or select Format > Format Selection.
3) Make any desired changes. The options are self-explanatory or easily researched.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

180 |Calc Guide 24.8


Figure 150: Legend formatting dialog

Formatting chart backgrounds


The background of a chart is divided into chart area, chart wall, and chart floor, as shown in
Figure 141 on page 170. To set border, area, and transparency options for these areas:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to open the appropriate dialog (such as Figure 151):
– Go to Format on the Menu bar and select Chart Wall, Chart Floor, or Chart Area.
– Right-click the chart wall, chart floor, or chart area in the chart and select Format Wall,
Format Floor, or Format Chart Area in the context menu. (For help with selecting
these areas, see “Selecting chart elements” on page 176.)
– On the Formatting toolbar, click on the Chart Area icon or the Chart Wall icon (there
is no icon for chart floor).
– Click on Chart Area, Chart Wall, Chart Floor, or Chart in the Select Chart Element
drop-down list on the Formatting toolbar. Then click the adjacent Format Selection
icon or select Format > Format Selection.
– Double-click on the chart area, chart wall, or chart floor.
3) Select the desired settings from the Borders, Area, and Transparency tabs.
4) Click OK to save the changes and close the dialog. If desired, click outside the chart to
leave edit mode.
In the steps above, references to the chart floor are only applicable for 3D charts.

Chapter 6 Creating Charts and Graphs | 181


Figure 151: Chart Area dialog – Transparency tab

Data range and series


The goal of making a chart is to clearly present one or more data series and Calc provides a
number of ways to define and present those data. The following sections discuss topics such as
defining and changing data ranges, aligning data to a secondary Y axis, and formatting the
appearance of the data series.

Changing data ranges


When data ranges change in the spreadsheet, modify the chart settings to reflect those
changes. Use one of the following methods.

Note
The chart automatically reflects changes in the spreadsheet data. Thus, changing a
number from 5 to 50 in the data will instantly show the new number in the chart.

Replacing data by dragging


It is easy to manually replace one set of data with another set of data. Do this in the following
way:
1) Use the mouse to select all of the new data.
2) Drag the data over the chart, then release the mouse. This opens the Change Source
Data Range dialog shown in Figure 152.
3) Specify whether or not the first column or row contains labels, then click OK.

182 |Calc Guide 24.8


Figure 152: Change Source Data Range dialog

Modifying the data range and data series


To change the data range or data series, do the following:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Open the Data Ranges dialog using one of these methods:
– Go to Format > Data Ranges on the Menu bar.
– Click on the Data Ranges icon on the Formatting toolbar.
– Right-click on the chart and select Data Ranges from the context menu.
3) Edit the data range on the Data Range tab, which is similar to the Choose a Data Range
area shown in Figure 138 on page 166.
4) Edit data series on the Data Series tab, which is similar to the Customize Data Ranges
for Individual Data Series area shown in Figure 139 on page 168.
5) Click OK to save changes and close the dialog. If desired, click outside the chart to leave
edit mode.

Tip
If Calc is taking a significant amount of time to process a large amount of data for a
chart, try this: Select only limited data for each data series to initially organize the
chart. Adjust the settings until the chart looks as desired, then select all of the data.
For further information, see “Selecting data range” on page 166 and “Selecting data series” on
page 167.

Opening the Data Series dialog


The Data Series dialog offers several options for presenting data in the chart. Note that only one
data series can be selected at a time.
To open the Data Series dialog (Figure 153):
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to select the data series:
– Click on the data series in the chart.
– Click the data series name in the Select Chart Element drop-down list on the
Formatting toolbar.
3) Do one of the following to open the Data Series dialog:

Chapter 6 Creating Charts and Graphs | 183


– Go to Format > Format Selection on the Menu bar.
– Click on the Format Selection icon on the Formatting toolbar.
– Right-click on the data series and select Format Data Series.
4) Click on the tab of the appropriate page to make the changes needed. The options for
each page are explained below.
5) Click OK to save changes and close the dialog. If desired, click outside the chart to leave
edit mode.

Figure 153: Data Series dialog – Options tab

Note
The tabs that appear on the Data Series dialog depend on the type of chart selected.
Similarly the controls that appear on each tab may differ depending on the type of
chart.

Alignment, spacing, and plot options


Aligning data to secondary Y axis
A secondary axis may be helpful when data differ in units or scale, as in Figure 154. In our
example, one of the data series (kayaks) has considerably larger numbers than the others. To
plot all three data series on the same chart, and keep the plotted lines close to each other, the
kayak data series is aligned to a secondary Y axis, which has a wider scale. The color of the
secondary Y axis and the axis titles help to show this relationship.

Note
A data series can be associated with a secondary Y axis only after the Chart Wizard
has finished creating the chart.

184 |Calc Guide 24.8


Figure 154: Data series aligned to a secondary Y axis
To align a data series to a secondary Y axis:
1) Select the data series and open the Data Series dialog as described in the previous
section.
2) On the Options tab, under Align Data Series to, select Secondary Y axis.
3) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Aligning data series to a secondary Y axis is not possible for pie and net charts.
Data can only be aligned to a secondary Y axis, not a secondary X axis. However, it is possible
to create secondary X and Y axes that duplicate the primary axes on the opposite sides of a
chart. This is described in “Add or remove axis labels” on page 190. It is also possible to show
different units or scales on the secondary axis (with or without aligning data to it), as described
under “Defining scales” on page 192.

Spacing and plot options


The Options tab of the Data Series dialog (Figure 153) contains additional settings that depend
on the type of chart. These include:
Spacing
Sets the spacing interval of columns or bars between category settings, such as time.
Values above 100% increase the spacing while values below 100% decrease the
spacing. Maximum spacing is 600%.
Overlap
Sets overlap of columns or bars within the same category setting, such as a specific
time. The higher the percentage, the greater the overlap (maximum of 100%). Negative
percentages increase the separation (minimum of -100%).
Show bars side by side
When checked, shows no gap in columns or bars in the interval between categories.
When this option is not checked, data aligned to a secondary Y axis may hide other data.
Enable the option to prevent this.
Connection lines
For stacked and percent column (vertical bar) charts, mark this checkbox to connect the
column layers that belong together with lines.

Chapter 6 Creating Charts and Graphs | 185


Plot missing values
Specifies handling of missing values, with options depending on the type of chart.
Include values from hidden cells
Enables data from hidden cells to be included or not included.
Hide legend entry
Enables the name of the selected data series to be included or removed from the legend.
For pie or donut charts, in addition to the Include values from hidden cells option, two more
are available (not shown in Figure 153):
Orientation
Specifies the order of the pie sections (data points) – clockwise or counterclockwise. The
default direction is counterclockwise.
Starting Angle
Specifies the starting angle of the first pie section (data point), in the range 0 to 359
degrees. Drag the small dot around the circle or enter a number for the degrees. Use 0
degrees to start the first section at the 3 o’clock position and 90 degrees to start the first
section at 12 o’clock.

Area, transparency, and borders


For chart types other than line and scatter, the Data Series dialog (Figure 155) contains tabs for
formatting the fill and borders of graphical representations such as columns and bars. The Area
tab offers options for selecting color by clicking directly on a color in a palette, adding a custom
palette, specifying the RGB or Hex color codes, or by selecting a custom color using the Pick
button. Other pages contain options for gradient, bitmap, pattern, hatch, transparency, and
borders. The options are self-explanatory or can be readily researched.

Tip
If applying a gradient does not work as expected, do this: After selecting the desired
options on the Gradient page, click Add, provide a name for the gradient (or accept
the default), and click OK.

186 |Calc Guide 24.8


Figure 155: Data Series dialog – Area tab, Gradient page

Lines, areas, and data point icons


For some chart types (such as line charts and xy (scatter) charts), the Data Series dialog
contains only an Options tab and a Line tab (Figure 156).
Specify style, color, width, and transparency of the line in the Line Properties section on the left
side of the Line tab. In the Icon section, select an option for the symbol from the drop-down list:
No Symbol, Automatic, From file, Gallery, or Symbols.
• From file opens a browser for selecting the file that contains the desired symbol.
• Gallery opens a list of available graphics that can be selected.
• Symbols opens a list showing available symbols that can be selected.
A preview of the selection is shown in the preview box at the bottom of the dialog. Enter the
desired width and height of the symbol. Select Keep ratio if the ratio of width to height of the
symbol should be maintained.

Chapter 6 Creating Charts and Graphs | 187


Figure 156: Data Series dialog for line and scatter charts – Line tab

Assigning colors
Colors for the display of data series can be specified in three ways: changing the default color
scheme, using the Data Series dialog, or using data ranges to set colors for border and fill.

Changing default color scheme


To modify the default color scheme for data series, go to Tools > Options > Charts > Default
Colors to specify colors for each data series. Changes made here affect the default colors for
any future chart.

Using Data Series dialog


As discussed in the previous section, the Data Series dialog has options for assigning colors for
lines, areas, and borders. Available options depend on the type of chart.

Using data ranges to assign colors


Use the COLOR function in the Function Wizard (described in Chapter 9, Using Formulas and
Functions) to specify colors with numbers based on combined RGB values. Then assign the
numbers to data ranges for border and fill colors in the Data Series page of the Chart Wizard
(see “Selecting data series” on page 167) or in the Data Series tab of the Data Ranges dialog
(see “Changing data ranges” on page 182).
For example, using the COLOR function in the Function Wizard, enter 255 for R (red), 0 for G
(green), and 255 for B (blue). The COLOR function calculates a combined RGB value of
16711935. Then, when defining data ranges, enter the RGB value(s) in the cell range for border
or fill color. Optionally, include a value for the alpha channel (A) in the COLOR function. The
value of A can range from 0 (fully transparent) to 255 (fully opaque).

Note
Data ranges for border color and fill can only be specified for column, bar, pie,
bubble, and column and line charts.

188 |Calc Guide 24.8


In addition to directly assigning colors, you can use conditional formatting to define criteria for
when specific colors will be used. (Conditional formatting is described in Chapter 3, Formatting
Data.)
Figure 157 shows an example of using conditional formatting to specify colors. The COLOR
function in the Formula Wizard was used to create the conditional formula
=IF(B2>100,COLOR(240,240,0,20),COLOR(150,0,150,20))
This formula says that when the value in column B is over 100, the first RGB setting is used to
color that data point in the chart. When the value in column B is 100 or less, the default color
(150, 0, 150) is used. This formula is in all cells of column C. The numbers appearing in column
C are the RGB values calculated using the conditional formula (with cell references changed
accordingly).

Figure 157: Using the COLOR function and a conditional formula to specify colors
The chart on the right in Figure 157 shows how the colors change to reflect the conditional
formatting.

Formatting data points


Modify the appearance of an individual data point such as a column or bar using the Data Point
dialog. For most chart types, the dialog contains the same Area, Transparency, and Borders tabs
as the Data Series dialog shown in Figure 155 on page 187. For line, scatter, net, and stock
charts, the dialog contains the same options as the Line tab of the Data Series dialog shown in
Figure 156 on page 188.
To format data points:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Click two times (but not too quickly) on the data point to be formatted. The data point will
show square selection handles.
3) To open the Data Point dialog, do one of the following:
– Go to Format > Format Selection.
– Right-click on the data point and select Format Data Point in the context menu.
– Click the Format Selection icon on the Formatting toolbar.
4) Apply formatting options as desired.
5) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Chapter 6 Creating Charts and Graphs | 189


Tip
As shown in Figure 158, hover the pointer over a data point to show the number of
the data point, the number of the series, and the X and Y values of the data point.

Figure 158: Tooltip showing information about a data point

Axes
Add or remove axis labels
Use the Axes dialog shown in Figure 159 to add or remove axis labels, such as numbers or
categories. (To change the name of an axis, see “Titles, subtitles, and axis names” on page
177).
To use the Axes dialog:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Open the Axes dialog by doing one of the following:
– Go to Insert > Axes on the Menu bar.
– Right-click on the chart and select Insert/Delete Axes in the context menu.
3) Select or deselect the check boxes for axis labels. The Z-axis checkbox is only active
when editing a 3D chart.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Figure 159: Axes insertion dialog


Selecting a secondary X axis or a secondary Y axis in this dialog creates duplicate labels on the
opposite side of the chart, as shown in Figure 160. To specify different units or intervals for the
secondary axis, use the Scale tab of the more extensive Axis dialog described in the following
section.
It is also possible to align one or more data series to the secondary Y axis. Do this using the
Data Series dialog, described in “Aligning data to secondary Y axis” on page 184.

190 |Calc Guide 24.8


Figure 160: Both secondary axes enabled

Edit and format axes


In addition to the simple dialog above, a more extensive Axis dialog contains options for grid
intervals, positioning the axis, formatting the axis line and axis labels, and defining the scale,
among other settings. Use a dialog for a specific axis, or use a dialog that applies to all axes.
The options in the dialog depend on which axis was selected, type of chart, and whether the
chart is 2D or 3D.
To open the more extensive Axis dialog:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by a
gray border.
2) Open a specific axis dialog (Figure 161) by doing one of the following (some options do
not allow choosing all axes):
– Go to Format > Axis on the Menu bar and select the desired axis (X Axis, Y Axis, Z
Axis, Secondary X Axis, Secondary Y Axis, or All Axes).
– Right-click on the desired axis in the chart to open the context menu. Then select
Format Axis.
– Click the axis on the chart or select the axis in the Select Chart Element drop-down list
on the Formatting toolbar and click the adjacent Format Selection icon or select
Format > Format Selection on the Menu bar.
– Click on the icon for X Axis, Y Axis, or Z Axis on the Formatting toolbar. Or click on
the All Axes option to the right of the other icons.
3) Click the tab of the appropriate page to make the changes needed. The options for each
page are explained below.
4) Click OK to save changes and close the dialog. If desired, click outside the chart to leave
edit mode.

Chapter 6 Creating Charts and Graphs | 191


Figure 161: Y Axis formatting dialog – Scale tab

Defining scales
Use the Scale tab to modify the automatically generated scale for a primary axis. In addition, use
the Scale tabs for secondary axes to specify scales that are different from the scales for primary
axes. This can be quite useful for showing Celsius and Fahrenheit scales on the same chart, for
example, or for when data are aligned to a secondary Y axis (see “Aligning data to secondary Y
axis” on page 184).

Figure 162: Result when direction is reversed on the Y axis


The contents of the Scale tab (Figure 161) vary with chart type but may contain the following
options:
Reverse direction
Defines the order of lower and higher values along the axis. When not selected, the
X axis shows the lower values on the left and the Y axis shows the lower values at
the bottom. When selected, the orientation of the data display is reversed, as shown
in the Y axis in Figure 162.
Logarithmic scale
Specifies that the axis is to be subdivided logarithmically. Logarithmic scaling makes the
grid lines of the axis equidistant from each other, but the values between the lines are not
equal. Use this option when working with values that differ sharply from each other.

192 |Calc Guide 24.8


Minimum/Maximum
Sets the first/last value for the axis. Automatic must be deselected to set this option
manually.
Major interval
Defines the intervals between major divisions of the axis. These intervals will be used for
interval marks (specified on the Positioning tab of the Axis dialog) and gridlines.
Automatic must be deselected to set this option manually.
Minor interval count
Defines the number of intervals (not the values between intervals) that subdivide the
major intervals. The same as for major intervals, the interval count defined here will be
used for interval marks (specified on the Positioning tab of the Axis dialog) and gridlines.
Automatic must be deselected to set this option manually.
For some types of charts, additional options may be available:
Type
Specifies whether the labels are text, date, or should be detected automatically.
Resolution
For dates, specifies that the interval steps should be days, months, or years.

Tip
If the X axis is not displaying time as expected, manually entering the minimum and
maximum times on the Scale tab may solve the problem.

Positioning axis, labels, and interval marks

Figure 163: Axis formatting dialog – Positioning tab


The Positioning tab (Figure 163) controls the position of axis labels and interval marks.
Axis Line
Sets where the axis crosses the other axis, as shown in Figure 164. The options on the
drop-down list are Start, End, or Category. If Category is selected, a further drop-down
menu is displayed enabling selection of the value required.

Chapter 6 Creating Charts and Graphs | 193


Figure 164: Y axis set to cross X axis at specified value
Labels
Sets where axis labels are placed, using the Place labels drop-down list. The Outside
end and Outside start options are useful for positioning labels on axes with negative
numbers, as shown in Figure 165.
Interval Marks
– Major/Minor – specifies whether interval marks are displayed for major/minor
intervals. These intervals are defined on the Scale tab, described above.
– Inner/Outer – specifies whether interval marks are placed on the inner or outer side of
the axis. The interval marks in Figure 165 are on both sides.
– Place marks – specifies where to place the marks: At labels, At axis, or At axis and
labels. (The top two charts in Figure 165 show the labels along the axes. The marks
are thus both at axis and labels. The marks in the bottom two charts are located at the
labels.)

Figure 165: Axis label positions

Line tab
The Line tab has options for formatting the axis line style, color, width, and transparency. It has
the same contents as the Line tab of the Data Series dialog shown in Figure 156 on page 188
but excluding the Icon section.

194 |Calc Guide 24.8


Label tab
On the Label tab (Figure 166), choose whether to show or hide the labels and specify how to
handle them when they do not fit neatly in the chart. The options are described below.

Figure 166: Axis formatting dialog – Label tab


Show labels
Sets whether to show or hide the axis labels.
Order
Defines the horizontal or vertical alignment of the labels on the X or Y axis. These
options are available only for 2D charts.
– Tile – arranges labels on the axis side by side.
– Stagger odd – staggers labels on the axis, with even numbers lower than odd
numbers (even numbers to the left on vertical axis).
– Stagger even – staggers labels, with odd numbers lower than even numbers (odd
numbers to the left on vertical axis).
– Automatic – automatically arranges labels on the axis.

Note
Problems may arise in displaying labels if the chart is too small. Avoid this by either
enlarging the chart or decreasing the font size.
Text flow
Determines how text flows in axis labels.
– Overlap – allows axis labels to overlap.
– Break – allows text breaks, enabling text to wrap into new lines in the available space.
Text Orientation
Defines the direction and orientation of label text.
– Vertically stacked – Stacks characters vertically so that text is read from top to
bottom.

Chapter 6 Creating Charts and Graphs | 195


– ABCD wheel – Defines text orientation by clicking and dragging the indicator on the
wheel. Orientation of the characters “ABCD” on the wheel corresponds to the new
setting.
– Degrees – Shows the orientation angle of the text as determined by the ABCD wheel
or by manually entering the degrees in the spin box.
– Text direction – Specifies the direction for any text that uses complex text layout
(CTL). CTL is only available if Tools > Options > Languages and Locales > General
> Default Languages for Documents > Complex text layout is enabled.

Numbers
Use the Numbers tab (Figure 167) to set the attributes for any numbers used on the axis. When
Source format is selected (as it is by default), numbers are formatted exactly as they are
formatted on the spreadsheet. Deselect this option to change number formatting. For information
about formatting numbers, see Chapter 3, Formatting Data, as well as the online Help.

Figure 167: Axis formatting dialog – Numbers tab

Font and Font effects


Use the Font and Font Effects tabs to set the font and font effects for the axis labels. These tabs
are the same as the tabs for specifying fonts and font effects in cells. See Chapter 3, Formatting
Data, for more information.

Asian Typography
Sets the Asian typographic options for axis labels. This tab is the same as that for specifying
Asian typographic options for cells. See Chapter 3, Formatting Data, for more information.

196 |Calc Guide 24.8


Hierarchical axis labels
Multiple levels of categories can be displayed in a hierarchical manner along the axis of a chart.
Hierarchical axes labels are created automatically if the first column or row defined as data is
text (as opposed to the first column or row defined as labels). An example of hierarchical labels
is shown in Figure 168. In this case, Calc automatically defines the data range for categories as
the first two columns in the spreadsheet. This is reflected in the chart, which shows the
hierarchical relationship between quarters and months.

Figure 168: Example of hierarchical axes labels

Data labels
Data labels display information next to data points on the chart. They can be quite useful for
highlighting specific data when presenting detailed information, but be careful not to create a
chart that is too cluttered to read easily.

Adding and formatting data labels for a data series


To add or format data labels for a data series:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to select a specific data series:
– Click once somewhere in the data series.
– In the Select Chart Element drop-down list of the Formatting toolbar, select the data
series name.

Note
If no data series is selected, then all data series on the chart will be labeled.
3) To open the Data Labels dialog (Figure 170), do one of the following:
– Go to Insert > Data Labels on the Menu bar. If you selected a data series, Calc
displays data labels for that data series using default settings, and displays the Data
Labels dialog for the selected data series. In this case, the data labels will remain
displayed even if you press Cancel on the dialog. If no data series was selected, Calc
displays the Data Labels for all Data Series dialog (Figure 169). The controls on this

Chapter 6 Creating Charts and Graphs | 197


dialog are similar to those on the Data Labels tab of the Data Labels dialog, which are
described below.
– Right-click on the selected data series in the chart and select Insert Data Labels in
the context menu. Calc displays data labels with default settings. Then right-click again
and select Format Data Labels in the context menu.
– Select the intended data labels on the chart or in the Select Chart Element drop-down,
and then select Format > Format Selection on the Menu bar or press the Format
Selection icon on the Formatting toolbar.

Figure 169: Data Labels for all Data Series dialog


4) Select the options as desired. The options are explained below.
5) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Tip
Select a data series by clicking once on a column, bar, or other graphic
representation of the data series. Select a single data point by pausing, then clicking
again.
Most of the tabs in the Data Labels dialog are used in other dialogs and can be readily
understood or easily researched. The exception is the Data Labels tab (Figure 170), which
contains the following options:
Value as number
Displays the numeric value of a data point. When selected, this option activates the
Number format button.
Number format
Opens the Format Number dialog, which is the same as the Numbers tab of the Format
Cells dialog discussed in Chapter 3, Formatting Data. Deselect Source format to
activate options on the Format Number dialog.
Value as percentage
Displays the percentage value of the data points in each data series. When selected, this
option activates the Percentage format button. Note that the percentage referred to is a
data point’s Y value as a percent of total Y values for a specific X category or value.

198 |Calc Guide 24.8


Thus, in Figure 171, the February canoe value 9 is 10% of the total February value of 94
(the sum of 9, 31, and 54).
Percentage format
Opens the Number Format for Percentage Value dialog. which is the same as the
Numbers tab of the Format Cells dialog discussed in Chapter 3, Formatting Data.
Deselect Source format to activate options on the Number Format for Percentage Value
dialog.
Category
Displays the category next to each data point. This option is activated for all data labels
in Figure 171. Thus, all data labels show the month. The text for data labels comes from
the category data series and cannot be changed in the chart. It can only be changed in
the spreadsheet data.

Figure 170: Data Labels tab of the Data Labels dialog

Figure 171: Examples of data label options


Series name
Displays the data series name next to each data point.

Chapter 6 Creating Charts and Graphs | 199


Legend key
Displays the legend icon for the data series next to each data point. Figure 171 shows
the legend keys for motors and boats, but not for canoes.
Auto text wrap
Wraps data label text if needed.
Separator
Selects what will be used to separate multiple text strings when at least two options
above are selected. In Figure 171, the separator is Semicolon for the canoes data
labels, New line for the motors data labels, and Comma for the boats data labels (with
the exception of the June label, which was modified for better fit). Further options are
Space and Period.
Placement
Specifies the placement of data labels relative to the data point representation. In Figure
171, the placement of data labels is Below for canoes, Above for boats, and Right for
motors. Other available options depend on chart type but may include Left, Center,
Outside, Inside, and Near Origin.
Rotate Text
Sets the text orientation of data labels by using the dial or entering the rotation angle in
degrees.
Text Direction
Specifies the text direction for a paragraph that uses complex text layout (CTL).
Leader Lines
When you choose to display data labels, Calc automatically determines where to place
each label on the chart. However, you can move a data label (by dragging) to a more
convenient position. By default, a “leader line” is drawn that connects such a displaced
data label to its associated data point. Untick the Connect displaced data labels to
data points checkbox to hide any leader lines for the selected data series.

Data labels for individual data points


Sometimes it is appropriate to apply data labels to one or a few data points rather than all data
points. This reduces clutter and highlights the most important data.

Adding a single data label


Insert a data label for a single data point in the following way:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Click the data point once, pause, then click again to select it. (Clicking too quickly opens
the Data Series dialog.)
3) Right-click on the selected data point and select Insert Single Data Label in the context
menu. The data label will have the default settings.
4) If desired, click outside the chart to leave edit mode.

Formatting the label for a single data point


To format an existing label for a single data point, follow the directions above but instead of step
3), do the following to open the Label for Data Series dialog (similar to Figure 170): right-click on
the data point and select Format Single Data Label from the context menu.

200 |Calc Guide 24.8


The options in the Label for Data Series dialog are the same as for the Data Labels dialog
described above.
You can also access the Label for Data Series dialog by clicking on the data label, pausing, and
then clicking on it again. Then right-click and select Format Single Data Label in the context
menu.

Removing data labels


Remove labels from a single data point, a single data series, or all data points using one of the
methods below.
Before doing any of the following, first select the chart by double-clicking on it to enter edit mode.
The chart should now be surrounded by a gray border. When finished, if desired, click outside
the chart to leave edit mode.

Removing all data labels from a single data series


Method One
Right-click somewhere in the data series and select Delete Data Labels in the context
menu.
Method Two
1) Do one of the following to open the Data Labels dialog (Figure 170):
– Click somewhere in the data series to select it. Go to Insert > Data Labels on the
Menu bar.
– In the Select Chart Element drop-down list of the Formatting toolbar, select the data
labels entry for the required series name or select one of the labels for the data series.
Then click the adjacent Format Selection icon or select Format > Format Selection
on the Menu bar.
– Right-click in the data series or on the labels of the data series and select Format
Data Labels in the context menu.
2) On the Data Labels tab, deselect all of the options and click OK.

Removing a data label from a single data point


1) Click once on the data point, pause, then click again to select it.
2) Right-click to open the context menu and select Delete Single Data Label.

Removing all data labels


1) Make sure that no data label or data series is selected.
2) Go to Insert > Data Labels on the Menu bar.
3) On the Data Labels for all Data Series dialog, deselect all of the options for the data
labels to be removed, then click OK.

Chart Data Tables


Sometimes when you design a chart, it is useful to display the source data with the chart and
this can be achieved easily by adding a chart data table. Chart data tables display the underlying
data represented by a chart, in a tabular form positioned automatically below the chart. For
certain chart types, the data table replaces the x-axis labels.
Chart data tables can be formatted freely and a simple example is shown in Figure 172.

Chapter 6 Creating Charts and Graphs | 201


Figure 172: Chart data table displayed below chart
Data tables can be shown for most chart types, apart from Net and Pie charts.

Note
The nature and volume of data shown on a chart, and the type of chart, may not be
suitable for displaying a usable chart data table. In such cases, the chart data table
can simply be removed.

Inserting a chart data table


To display a chart data table:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Go to Insert > Data Table on the Menu bar to open the Data Table dialog (Figure 173).
3) Select the Show data table option.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Tip
The content of the chart data table inherits the formatting of the chart’s source data.

Removing a chart data table


To remove a chart data table:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Go to Insert > Data Table on the Menu bar to open the Data Table dialog (Figure 173).
3) Deselect the Show data table option.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
Alternatively, with the chart in edit mode, right-click on the chart data table and select Delete
Data Table in the context menu.

202 |Calc Guide 24.8


Modifying the properties of a chart data table
The Data Table dialog shown in Figure 173 is accessed using Insert > Data Table on the Menu
bar. In addition to providing a display on/off control for the chart data table (Show data table), it
also provides options to control the basic formatting properties of the chart data table:
• Show horizontal border: show or hide internal row borders.
• Show vertical border: show or hide internal column borders.
• Show outline: show or hide borders around the table.
• Show keys: show or hide the color keys associated with each data series. These are
similar to the color keys used in the chart legend.

Figure 173: Data Table dialog


Each of the following interactions leads to the display of the larger Data Table dialog shown in
Figure 174. In all cases, first select the chart by double-clicking on it to enter edit mode.
• Double-click the chart data table.
• Right-click on the chart data table and select Format Selection in the context menu.
• Select the chart data table and go to Format > Format Selection on the Menu bar.
• Select the Data Table option in the Select Chart Element drop-down list on the
Formatting toolbar and then click the adjacent Format Selection icon.
This version of the dialog has five tabs – Data Table, Line, Area, Font, and Font Effects. Through
these tabs it is possible to change the line, fill and font properties of the data table. For example,
the line properties define how the borders (lines) will be shown – it is possible to change the line
style (for example, continuous line, dashes, or dots), the color of the line, transparency, and line
thickness. The fill properties define the color of the cell background. The font properties define
the font and size to be used for the text in the data tables.
• The Data Table tab provides the same four options that appear in the Data Table
Properties area of the Data Table dialog shown in Figure 173.
• The Line tab provides similar options to those on the Line tab of the Data Series dialog
shown in Figure 156 on page 188 but excluding the Icon section.
• The Area tab provides similar options to those on the Area tab of the Data Series dialog
described in the “Area, transparency, and borders” section on page 186.
• The Font and Font Effects tabs provide similar options to those on the corresponding
tabs of the Cell Style dialog, described in the “Cell style attributes” section of Chapter 4,
Using Styles and Templates.

Chapter 6 Creating Charts and Graphs | 203


Figure 174: Data Table dialog with multiple tabs

Grids
Grid lines or grids divide the intervals along axes to help estimate data point values. Major and
minor grid lines are shown in Figure 175. The darker lines with numbers are major grid lines
while the lighter lines between them are minor grid lines. Note that the Y-axis major grid line is
activated by default.

Figure 175: Major and minor grid lines for the X and Y axes
Grids are available for all chart types with the exception of pie charts.

Adding/removing grid lines


1) First select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following:
– Go to Insert > Grids on the Menu bar to open the Grids dialog (Figure 176).
Select/deselect the check boxes as needed. The Z axis checkbox is only active for a
3D chart. Click OK to close the dialog.

Figure 176: Basic Grids dialog


– Click the Horizontal Grids icon or the Vertical Grids icon, both located on the
Formatting toolbar. Clicking once turns on the major grid lines. Clicking twice turns on
the minor grid lines as well. Clicking again turns off the grids.

204 |Calc Guide 24.8


3) If desired, click outside the chart to leave edit mode.

Note
In the Formatting toolbar, the Horizontal Grids icon and the Vertical Grids icon set
grid lines for the Y axis and X axis, respectively. This can be misleading because
both the Y axis and the X axis can be horizontal or vertical, depending on the type of
chart. Thus, for a bar chart, click the Horizontal Grids icon to control the vertical
grids.

Formatting grids
In addition to the Grids dialog shown in Figure 176, there is another dialog for formatting grids.
To open the grid formatting dialog:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Go to Format > Grid on the Menu bar and select the appropriate type of grid to open the
Grid formatting dialog (Figure 177).

Figure 177: Grid formatting dialog


3) Set formatting options for line style, color, width, and transparency.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Note
Use the Scale tab of the Axis dialog to specify the intervals between grid lines. This
is described in “Defining scales” on page 192.

3D charts
Setting 3D look
Column, bar, pie, and area charts can be displayed as 3D charts. The setting to make a chart 3D
is on the first page of the Chart Wizard. If the chart has already been created, do the following to
give it a 3D look:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.

Chapter 6 Creating Charts and Graphs | 205


2) Do one of the following:
– Go to Format > Chart Type.
– Click on the Chart Type icon on the Formatting toolbar.
– Right-click in the chart and select the Chart Type option in the context menu.
3) Select 3D Look in the Chart Type dialog.
4) Select the basic rendering scheme as Simple or Realistic from the adjacent drop-down.
5) For column and bar charts, select the shape as Bar, Cylinder, Cone, or Pyramid.
6) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Formatting 3D view
To make changes to a 3D chart, use the 3D View dialog (Figure 178).

Figure 178: 3D View dialog – Perspective tab


Use the 3D View dialog to change the 3D settings, including perspective, appearance, and
illumination. Note that the chart must already be set to show a 3D look, as described above. To
open the 3D View dialog:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following:
– Right-click on the chart and select 3D View in the context menu.
– Go to Format > 3D View.
– Click on the 3D View icon on the Formatting toolbar.
3) Make any changes required.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.
This dialog has three tabs, which are explained below.

Rotation and perspective


Some hints for using the Perspective tab (Figure 178) to rotate a 3D chart or change its
perspective view:
• Set all angles to 0 degrees for a front view of the chart. Pie charts and donut charts are
shown as circles.

206 |Calc Guide 24.8


• With Right-angled axes enabled, the chart can be rotated only in the X and Y direction;
that is, parallel to the chart borders.
• An X value of 90 degrees, with Y and Z set to 0 degrees, provides a view from the top of
the chart. With X set to –90 degrees, the view is from the bottom of the chart.
• Rotation is applied in the following order: X axis first, then Y axis, and Z axis last.
• When shading is enabled (see below) and the chart is rotated, the lights are rotated as if
they are fixed to the chart.
• The rotation axes always relate to the page, not to the axes of the chart. This is different
from some other chart programs.
• Select the Perspective option to view the chart in central perspective as through a
camera lens (as opposed to using a parallel projection). Set the focal length with the spin
box or type a number in the box. With a 100% setting, a far edge in the chart looks
approximately half as big as a near edge.

Rotating 3D charts interactively


In addition to using the Perspective tab of the 3D View dialog, rotate 3D charts interactively in
the following way:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Click once on the chart wall to select it, causing round selection handles to appear. The
pointer changes to a rotation icon.
3) Press and hold the left mouse button while dragging in the desired direction. A dashed
outline of the chart is visible to help see how the result will look.
4) Release the mouse button when satisfied.
5) Click outside the chart to exit edit mode.

Appearance
Use the Appearance tab of the 3D View dialog (Figure 179) to modify some aspects of the
appearance of the data in a 3D chart.
First select a rendering scheme from the Scheme drop-down list – Realistic (default) or Simple.
The scheme selected sets the options and light sources. Depending on the scheme selected,
not all options may be available. To create a custom scheme, select or deselect a combination of
Shading, Object borders, and Rounded edges.
Some hints:
• Select Shading to use the Gouraud method for rendering the surface. Otherwise, a flat
method is used. The flat method sets a single color and brightness for each polygon. The
edges are visible but soft gradients and spotlights are not possible. The Gouraud method
applies gradients for a smoother, more realistic look. See the Draw Guide for more
information on the use of shading.
• Select Object borders to draw lines along the edges.
• Select Rounded edges to smooth the edges of box shapes.

Chapter 6 Creating Charts and Graphs | 207


Figure 179: 3D View dialog – Appearance tab

Illumination
Use the Illumination tab (Figure 180) of the 3D View dialog to control light sources for the 3D
view.

Figure 180: 3D View dialog – Illumination tab


Here are the options with some hints:
• Click any of the eight buttons to switch a directed light source on or off.
• The first light source projects a specular light with highlights.
• By default, the second light source is switched on. It is the first of seven normal, uniform
light sources. To activate the others sources, click twice on their respective button.
• For the selected light source, select a color from the first drop-down list below the eight
light source buttons. Alternatively press the adjacent button to select a color using the
Pick a Color dialog. Note that the brightness values of all lights are added together, so
use dark colors when enabling multiple lights.
• The small preview in the dialog shows the effect of repositioning the light source.
• Each selected light source appears as a small colored sphere in the specified color. The
sphere is larger when the light source is actively selected.

208 |Calc Guide 24.8


• Each light source always points at the middle of the object initially. Move the vertical
slider to adjust the lighting angle. The horizontal slider rotates the light around the object.
In addition, click the light source and drag it to the desired location.
• Click the button in the bottom right corner of the preview to switch the internal
illumination model between a sphere and a cuboid.
• Use the Ambient light drop-down list to define the ambient light, which shines with a
uniform intensity from all directions. Alternatively press the adjacent button to select a
color using the Pick a Color dialog.
See the Draw Guide for more information on setting the illumination.

Trend and mean value lines


Trend lines help show the relationships among scattered data points of a data series. Calc has a
good selection of regression types for creating trend lines: linear, logarithmic, exponential,
power, polynomial, and moving average. Choose the type that comes closest to passing through
all of the points in a data series.
Trend lines can be added to all 2D chart types except for pie, net, bubble, and stock charts.
When inserted in the chart, representations of the trend lines are automatically shown in the
chart legend.

Note
For chart types that use categories for the X axis, such as column, bar, or line charts,
the numbers 1, 2, 3… are used as values for calculating trend lines. By contrast, XY
(scatter) chart types show data rather than categories along the X axis. Thus, only
XY (scatter) chart types can show meaningful regression equations.

Adding and modifying trend lines


Trend lines can only be added to one data series at a time. To add a trend line to a data series:
1) Double-click on the chart to enter edit mode. The chart should now be surrounded by a
gray border.
2) Select the data series by doing one of the following:
– Click once on a data series representation such as a bar, column, line, or point.
– Select the data series from the Select Chart Element drop-down list on the Formatting
toolbar.
3) Do one of the following to open the Trend Lines dialog (Figure 181):
– Go to Insert > Trend Line on the Menu bar.
– Right-click on the data series and select Insert Trend Line in the context menu.
4) Select the type of regression and choose the desired options. These are explained
below.
5) Click OK to close the dialog and place the trend line in the chart. If desired, click outside
the chart to leave edit mode.

Chapter 6 Creating Charts and Graphs | 209


Figure 181: Trend Line dialog – Type tab

Regression types
By default, x is used for the abscissa variable and f(x) for the ordinate variable. Change the
names under X Variable Name and Y Variable Name on the Trend Line dialog.
Linear
Regression through equation y = a ∙ x+b. Intercept b can be forced.
Logarithmic
Regression through equation y = a ∙ ln(x) + b. Only positive x values are used.
Exponential
Regression through equation y = b ∙ exp(a ∙ x).This equation is equivalent to y = b ∙ mx,
with m = exp(a). Intercept b can be forced. Only positive y values are considered, except
if all y values are negative. In that case, the equation used is y = -b∙exp(a ∙ x).
Power
Regression through equation y = b ∙ xa. Only positive x values are considered. Only
positive y values are considered, except if all y values are negative. In that case, the
equation used is y = -b ∙ xa.
Polynomial
Regression through equation y = Σi (ai ∙ xi). Intercept a0 can be forced. Degree of
polynomial must be given (at least 2).
Moving Average
Simple moving average for n previous y-values, with n being the period. No equation is
available for this trend line. The type of moving average regression curve is selected as
Prior, Central, or Averaged Abscissa.

Tip
It is possible to add multiple trend lines to a single data series. This could be useful
when you want to compare different regression types for your data.

210 |Calc Guide 24.8


Search for the term “Trend Lines” in the index of the Help system for more information about
these regression types.

Trend line options


Trendline Name
Specifies the name to be used for labeling the equation in the legend; see Figure 182.
Extrapolate Forward/Backward
Specifies the number of units the trend line should be extended forward or back. This
only works for charts that have numeric values along the X axis rather than categories.
Force Intercept
Forces the line to cross the Y axis at the specified value.
Show Equation
Displays the equation in the chart, as shown in Figure 182.
Show Coefficient of Determination (R2)
Displays the coefficient of determination in the chart. Shown with the polynomial equation
in Figure 182.
X and Y Variable Names
Enables changing the names of X or Y variables for displaying the equation in the chart.
The Show Equation option must be checked for these options to be active.

Figure 182: Trend lines showing various equations


Select a trend line to display information about it in the Status bar, as shown in Figure 183. The
Status bar is normally located at the bottom of the spreadsheet.

Figure 183: Equation information displayed in the Status bar

Formatting trend lines


When originally inserted, a trend line has the same color as the corresponding data series. To
change the style, color, width, or transparency of a trend line, use the Line tab of the Trend Line
dialog (Figure 184). The options are easily understood or researched.

Chapter 6 Creating Charts and Graphs | 211


Figure 184: Trend Line dialog – Line tab

Formatting trend line equations


Display the equation in the chart by selecting Show Equation on the Type tab of the Trend Line
dialog (Figure 181). Options for the trend line equation include formatting the border around the
equation, area fill, transparency, font, and alignment. The number style can also be specified—
this may be quite useful, especially for specifying the number of decimal places.
To format trend line equations:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to open the Equation dialog:
– Select the equation on the Select Chart Element drop-down list and then click the
Format Selection icon on the Formatting toolbar or select Format > Format
Selection on the Menu bar.
– Click once on the equation to select it then click the Format Selection icon on the
Formatting toolbar or select Format > Format Selection on the Menu bar.
– Right-click on the equation and select Format Trend Line Equation in the context
menu.
3) Select the desired options on the dialog. The options are self-explanatory or easily
researched. The Numbers tab has the same options as the Numbers tab of the Axis
dialog, Figure 167 on page 196.
4) Click OK to close the dialog.
5) If desired, click outside the chart to leave edit mode.

Deleting trend lines


1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following:
– Select the trend line and press the Delete key.
– Right-click on the trend line and select Delete Trend Line in the context menu.
3) If desired, click outside the chart to leave edit mode.

212 |Calc Guide 24.8


Mean value lines
Mean value lines are a special type of trend line. To create one, Calc calculates the average of a
data series and places a colored line at that value in the chart, as shown in Figure 185. They can
only be created for 2D charts and cannot be created for pie, bubble, net, or stock charts.

Figure 185: Mean value lines

Inserting mean value lines


For all data series (if no data series is selected, mean value lines are inserted for all data series):
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Go to Insert > Mean Value Lines on the Menu bar.
3) If desired, click outside the chart to leave edit mode.
For a single data series:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Select a data series by doing one of the following:
– Click once somewhere in the data series.
– Select the data series from the Select Chart Element drop-down list on the Formatting
toolbar.
3) Add the mean value line by doing one of the following:
– Go to Insert > Mean Value Lines on the Menu bar.
– Right-click on the data series and select Insert Mean Value Line in the context menu.
4) If desired, click outside the chart to leave edit mode.

Modifying mean value lines


When inserted, a mean value line has the same color as the corresponding data series. To
modify the style, color, width, and transparency of a mean value line:
1) Double-click on the chart to enter edit mode. The chart should now be surrounded by a
gray border.
2) Do one of the following to open the Mean Value Line dialog (the dialog has the same
options as the Line tab of the Trend Line dialog in Figure 184):

Chapter 6 Creating Charts and Graphs | 213


– Right-click on the mean value line and select Format Mean Value Line in the context
menu.
– Left-click on the mean value line or select the appropriate mean value line from the
Select Chart Element drop-down list on the Formatting toolbar, then click the Format
Selection icon in the Formatting toolbar, or select Format > Format Selection.
3) Make the desired changes.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Deleting mean value lines


1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following:
– Left-click on the mean value line or select the appropriate mean value line from the
Select Chart Element drop-down list on the Formatting toolbar and then press the
Delete key.
– Right-click on the data series and select Delete Mean Value Line in the context menu.
3) If desired, click outside the chart to leave edit mode.

Error bars

Figure 186: Chart with error bars


Error bars, shown in Figure 186, can be useful for presenting data that has a known possibility of
error, such as social surveys using a particular sampling method, or for showing the measuring
accuracy of the tool used. In Figure 186 variance is shown for canoes, standard deviation for
boats, and standard error for motors. Error bars can be created for 2D charts only and cannot be
created for pie, bubble, net, or stock charts.

Inserting error bars


If no data series is selected, X or Y error bars are inserted for all data series. To add error bars
for all data series:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Go to Insert > X Error Bars or Insert > Y Error Bars on the Menu bar to open the Error
Bars dialog (Figure 187). The Line tab is not present if you are inserting error bars for all

214 |Calc Guide 24.8


data series; in this circumstance, an extra None option appears in the Error Category
area.
3) Select the desired options. See below for more information about the options.
4) Click OK to close the dialog and add the error bars to the chart. If desired, click outside
the chart to leave edit mode.

Figure 187: Error Bars dialog – Error Bars tab


To insert error bars for a single data series:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to select the data series:
– Click once on a bar, column, line, or other graphical representation in the data series.
– Select the data series from the Select Chart Element drop-down list on the Formatting
Toolbar.
3) Do one of the following to open the Error Bars dialog (Figure 187):
– Go to Insert > X Error Bars or Insert > Y Error Bars on the Menu bar.
– Right-click on the data series and select Insert X Error Bars or Insert Y Error Bars in
the context menu.
4) Select the desired options. See below for more information about these options.
5) Click OK to close the dialog and add the error bars to the chart. If desired, click outside
the chart to leave edit mode.

Error Bars dialog options


Under Error Category, only one of the following options can be selected at a time.
None – does not show any error bars. This option is only available when no data series
is selected.
Constant Value – shows the error as constant positive and/or negative value(s). Specify
these values in the Parameters section.
Percentage – shows the error as a percentage of the data points. Specify this
percentage in the Parameters section.

Chapter 6 Creating Charts and Graphs | 215


The drop-down list has four measures of the error value:
– Standard Error
– Standard Deviation
– Variance
– Error Margin – uses the value for the error margin that is specified in the Parameters
section.
Cell Range – uses error values defined in a range of cells. Specify the range in the
Parameters section.
Under Parameters, specify positive and negative values or ranges for the error bars. Constant
Value, Percentage, Error Margin, or Cell Range must be checked for these options to be
active.
Under Error Indicator, select whether the error graphic shows both positive and negative errors,
only positive errors, or only negative errors.
On the Line tab you can adjust the line style, color, width, and transparency for the error bars.

Modifying error bars


Error bars can only be changed one data series at a time, using the Error Bars dialog (Figure
187). Do one of the following to open the Error Bars dialog:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) Do one of the following to open the Error Bars dialog:
– Click once on the data series to select it, then go to Insert > X Error Bars or Insert >
Y Error Bars on the Menu bar.
– Select the error bars for the specific data series from the Select Chart Element drop-
down list on the Formatting toolbar. Then go to Format > Format Selection or click
the Format Selection icon on the Formatting toolbar.
– Right-click on the data series and select Format X Error Bars or Format Y Error
Bars in the context menu.
3) Select the desired options on the Error Bars and Line tabs of the Error Bars dialog.
4) Click OK to close the dialog and update the error bars for the selected series. If desired,
click outside the chart to leave edit mode.

Deleting error bars


To delete X or Y error bars for all data series:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now be
surrounded by a gray border.
2) With no data series selected, go to Insert > X Error Bars or Insert > Y Error Bars on
the Menu bar to open the Error Bars dialog (Figure 187).
3) Select None.
4) Click OK to close the dialog and delete the error bars.
5) If desired, click outside the chart to leave edit mode.

216 |Calc Guide 24.8


To delete error bars for a single data series, follow the same steps as above but instead of steps
2) to 4), right-click on the data series and select Delete X Error Bars or Delete Y Error Bars in
the context menu.

Adding drawing objects to charts


Use the Drawing toolbar to add shapes such as lines, rectangles, circles, text objects, or more
complex shapes such as symbols or block arrows. Use additional shapes to add explanatory
notes, highlight points of interest on a chart, or even hide certain data or text.
Open the Drawing toolbar by going to View > Toolbars > Drawing. Note that it can be moved
around the workspace as needed. For more information on using the Drawing toolbar and
drawing shapes, see Chapter 5, Using Images and Graphics, as well as the Draw Guide.
The Drawing toolbar (Figure 188) appears when the chart is in edit mode (by clicking on it twice).

Tip
To place arrows, text, or other drawing objects in a chart, be sure that the chart is in
edit mode. Otherwise, an object will not be connected to the chart and will not be
moved with it.

Figure 188:Drawing toolbar when chart is placed in edit mode


1. Select 6. Freeform Line 11. Block Arrows
2. Insert Line 7. Insert Text Box 12. Flowchart
3. Line Ends with Arrow 8. Callouts 13. Callouts
4. Insert Rectangle 9. Basic Shapes 14. Stars and Banners
5. Insert Ellipse 10. Symbol Shapes

Most of these options are self-evident or can be readily researched, especially by referring to the
Draw Guide. Clicking on the icon for an option changes the pointer’s appearance, depending on
the option. Click and drag the pointer to create the desired drawing object in the chart.
Information that may be helpful for charts follows.
Insert Line
Draws a straight line where dragged.

Note
If you draw a line in the spreadsheet (outside any chart), you can hold down Shift
while dragging to constrain angles of the line to multiples of 45 degrees. This facility
is not applicable when inserting a line on a chart.
Write on the line by double-clicking the line and typing or pasting text. If the text is too
low, press Enter to raise it above the line.
Insert Text Box
Draws a text box with horizontal text direction. To place the text at an angle, click once
on the text box to select it, right-click, and select Position and Size from the context
menu. Specify the angle on the Rotation tab.

Chapter 6 Creating Charts and Graphs | 217


Callouts
Draws a line that ends in a graphic in which text can be placed. Use a callout to describe
or draw attention to a specific point or area. Double-click the callout to write text in it. In
Figure 188, Callouts option 8 creates a default callout while option 13 opens a tool
palette of callout styles.
Clicking the down arrows next to the last six options on the right of the Drawing toolbar (Figure
188) opens tool palettes similar to those shown in Figures 189 to 194.

Figure 189: Basic Shapes Figure 190: Symbol Shapes Figure 191: Block Arrows

Figure 192: Flowcharts Figure 193: Callouts Figure 194: Stars and Banners

Resizing, moving, and positioning charts


To resize or move a chart, click it once to put it in selection mode. Resize or move a chart in two
ways: interactively, or by using the Position and Size dialog. Combining both methods may be
useful. Position a chart interactively for quick and easy changes, then use the Position and Size
dialog for precise sizing and positioning.

Changing interactively
Resizing
To resize a chart interactively:
1) Click once on the chart to select it. Square selection handles appear around the border
of the chart.
2) Click and drag one of the selection handles. The pointer indicates the direction to
increase or decrease the chart size. Clicking and dragging a corner handle preserves the
horizontal to vertical size ratio.
3) When finished, click outside the chart to leave selection mode.

218 |Calc Guide 24.8


Moving
Move a chart interactively using one of two methods:
For small moves
1) Click once on the chart to select it. Square selection handles appear around the border
of the chart.
2) Press an arrow key to move the chart a few pixels at a time, or press Alt + an arrow key
to move the chart one pixel at a time.
3) When finished, click outside the chart to leave selection mode.
For larger moves
1) Click once on the chart to select it. Square selection handles appear around the border
of the chart.
2) Hover the pointer anywhere over the chart until it changes to a move pointer (shape
depends on computer setup).
3) Click and drag the chart to its new location.
4) Release the mouse button when the chart is in the required position.
5) When finished, click outside the chart to leave selection mode.

Position and Size dialog


The Position and Size dialog contains options for defining the position of the chart on the page,
specifying its size, rotating it, and slanting it.

Note
In addition to charts, the Position and Size dialog can also be used to modify and
position other graphic elements, such as those available on the Drawing toolbar.
To resize or move a chart using the Position and Size dialog:
1) Right-click on the chart and select Position and Size in the context menu to open the
Position and Size dialog (Figure 195).
2) Select the desired options on the Position and Size, Rotation, and Slant & Corner Radius
tabs on this dialog. See below for further information about the options on these tabs.
3) Click OK to close the dialog and save changes.
4) When finished, click outside the chart to leave selection mode.
When positioning or resizing, click one of the points in the Base point graphic corresponding to
the location to use for anchoring either the position of the chart or its size.
Note that either the position or the size can be protected from unwanted changes by clicking the
appropriate box in the Protect section. Either or both option(s) selected will remain active after
the dialog is closed. By contrast, Calc resets the base point to the default position after the
dialog is closed.

Chapter 6 Creating Charts and Graphs | 219


Figure 195: Position and Size dialog — Position and Size tab

Position and Size


The options available on the Position and Size tab (Figure 195) are as follows:
Position
Determines the location of the chart on the page. The position of a chart is coordinated
relative to a fixed point (the base point). By default, this base point is located at the upper
left of a chart. To make positioning of a chart simpler, the base point can be temporarily
changed.
– Position X – specifies the horizontal location of the chart relative to the base point.
– Position Y – specifies the vertical location of the chart relative to the base point.
– Base point – specifies a temporary base point for the chart.
Size
Specifies the amount by which to resize the selected chart with respect to the selected
base point.
– Width – sets a width for the selected object.
– Height – sets a height for the selected object.
– Keep ratio – maintains proportions between width and height when resizing the chart.
– Base point – determines the directions in which the chart size will be increased or
decreased.
Protect
Prevents unintended changes to the position or the size of the chart.
– Position – prevents unintentionally moving the chart.
– Size – prevents unintentionally resizing the chart.

220 |Calc Guide 24.8


Adapt
These options are always unavailable for charts.

Rotation
The options for the Rotation tab (Figure 196) are as follows:

Figure 196: Position and size dialog – Rotation tab


Pivot Point
The chart can be rotated around a pivot point. The default pivot point is at the top left of
the chart. Note that if there is not enough room to rotate the chart, it could be rotated off
of the page.
– Position X – specifies the horizontal distance from the left edge of the page to the pivot
point.
– Position Y – specifies the vertical distance from the top edge of the page to the pivot
point.
– Default settings – sets the location of the pivot point in a visual approach. The pivot
point can be temporarily changed. However, when the dialog is opened again, the
pivot point will return to its default location and the X and Y positions will reflect the
default location.
Rotation Angle
Specifies the number of degrees that the chart is rotated.
– Angle – shows the number of degrees of rotation (in the range 0 to 359 degrees). The
number can be entered directly or it can be set using the indicator labeled Default
settings.
– Default settings – graphically shows the rotation angle. The angle can be set by
clicking and dragging the indicator. The number of degrees rotated is shown in the
Angle box.

Slant & Corner Radius


The options for the Slant & Corner Radius tab (Figure 197) are as follows:
Corner Radius
This option is not available for charts.

Chapter 6 Creating Charts and Graphs | 221


Slant
Slants the chart along an axis. Specify the angle of the axis (in the range -89° to +89°).
Control Points
These options are not available for charts.

Figure 197: Position and Size dialog – Slant and Corner Radius tab

Selecting multiple charts


Select multiple charts by clicking once on the first chart then pressing Shift while clicking on
additional charts. An invisible selection rectangle covers all of the selected charts and selection
handles appear at the corners and midway between corners. The multiple charts are now treated
as a single object and actions such as the following can be conducted.
• Cut and paste or drag them to new locations.
• Use the Position and Size dialog described in the previous section.
• Use the Drawing Object Properties toolbar to align all of the charts, format the outer
borders, or anchor the charts to the same cell or page.

Changing overall appearance of charts


When a chart is selected (by clicking on it once) it can be formatted as an object. The Drawing
Object Properties toolbar (Figure 198) usually appears below the Standard toolbar (but the
location depends on setup) and shows tools available for all objects, including charts.
Most of the options are self-evident or can be easily researched. Please refer to Chapter 5,
Using Images and Graphics, and the Draw Guide for further information. Following are a few tips
for using these tools with charts.
Anchor
Connects a chart to either remain in the same position on a page or to move with a cell
(when rows and columns are inserted or deleted). When To cell (resize with cell) is
chosen, the chart or object increases or decreases in size when the cell is made larger or
smaller.

222 |Calc Guide 24.8


Align Objects
Click the icon to open options for aligning multiple charts horizontally (left, centered,
right) or vertically (top, center, bottom). This option is only active when two or more
charts (or other objects) are selected.

Figure 198: Drawing Object Properties toolbar that appears when chart is selected
1. Anchor 7. To Foreground 13. Fill Color
2. Align Objects 8. To Background 14. Arrow Style
3. Bring to Front 9. Line Style 15. Rotate
4. Forward One 10. Line Width 16. Points
5. Back One 11. Line Color 17. Group
6. Send to Back 12. Area Style/Filling

Bring to Front/Forward One/Back One/Send to Back


Stacks charts or other objects in front of or behind other objects.
To Foreground/To Background
Places charts or stacks of objects in either the foreground or the background. In Calc,
objects in the background are behind the cell grid and may be difficult to select. Use the
Select tool (arrow icon) on the Drawing toolbar (Figure 188) to select them.
Line Style/Line Width/Line Color
Formats the outer borders of charts.
Area Style/Filling and Fill Color
Colors objects such as arrows, shapes, and callouts. For charts, use the fill options
available in edit mode.
Arrow Style
Specifies the appearance of line arrows and lines. Does not apply to the block arrows
shown in Figures 188 and 189.
Rotate
Rotates the chart around a base point. When selected, places round rotation handles at
each corner. Move these to rotate the chart. Move the small circle in the center of the
chart to change the base point. Move the handles midway between the corners to slant
the chart or other object.
Points
Changes the shape of curved objects. Move the points to shape curves created with the
Curve tool on the Drawing toolbar.
Group
Groups or ungroups two or more objects. When grouped, the objects can be moved
together and global changes can be applied to them. From left to right, the four icons are
Group, Enter Group, Exit Group, and Ungroup.

Chapter 6 Creating Charts and Graphs | 223


Copying, exporting, and deleting charts
Copying charts in the same spreadsheet document
When a chart is copied, it retains a connection to the source data it is built on as long as it is in
the same document. This means that changes made to the source data will be reflected in the
chart.
Copying and pasting the chart is easy. Just click the chart once to select it, then either press
Ctrl+C, or right-click on the chart and select Copy in the context menu, or click the Copy icon
on the Standard toolbar, or select Edit > Copy on the Menu bar. To paste the chart in the
desired location, press Ctrl+V, or right-click and select Paste in the context menu, or click the
Paste icon in the Standard toolbar, or select Edit > Paste on the Menu bar.

Copying to another LibreOffice document


When a chart is copied and pasted into another LibreOffice document, any connection to the
data it is based on is lost. The data is kept with the chart and is now called a data table rather
than a data range. Figure 199 shows an example of this internal data table.

Note
A copied chart links to or retains its data only when pasted into a LibreOffice
document. To retain data or links outside LibreOffice, use embedding or linking, as
explained in Chapter 12, Linking Data.

Keeping original data


If the goal is to use the original data for the chart, follow the same procedure as above to copy
and paste the chart to another document. Nothing more needs to be done.

Modifying original data


If the original data for the chart needs to be modified, do the following:
1) Select the copied chart by double-clicking on it to enter edit mode. The chart should now
be surrounded by a gray border.
2) Right-click on the chart and select Data Table to open the Data Table dialog shown in
Figure 199.
3) Modify the data as desired. In addition to changing numbers in the data, use options to
insert, move, or delete columns and rows.
4) Click Close to close the dialog.
5) If desired, click outside the chart to leave edit mode.

224 |Calc Guide 24.8


Figure 199: Data Table dialog when a chart is copied into another document

Dragging replacement data


If the chart is still in Calc and replacement data is in the same spreadsheet, select and drag the
new data onto the chart. This is described in “Replacing data by dragging” on page 182.

Note
Calc does not provide a direct way to save chart settings for creating another chart in
LibreOffice. Here are three options for using the same chart settings: 1) copy and
paste the chart into another file; 2) save the file containing the chart as a new file;
and 3) save the chart in a template. Depending on the method used, create a new
chart by modifying either the data range or the data table.

Exporting chart images


Charts can be exported in a variety of image formats for use in other documents. File types
include BMP, EMF, EPS, GIF, JPEG, PDF, PNG, SVG, SVM, TIFF, and WMF.
To export a chart in an image format:
1) Right-click on the selected chart and select Export as Image in the context menu to
open the Save as Image dialog.
2) In the dialog, type a name for the graphic file, select the location for saving the file, and
select the desired graphic format.
3) Click Save and an image of the chart will be exported to the location specified.

Deleting charts
To delete a chart, click it once to select it. Square selection handles appear on the borders of the
chart. Then press Delete.

Chapter 6 Creating Charts and Graphs | 225


Calc Guide 24.8

Chapter 7
Gallery of Chart Types
Introduction
While data can be presented using a variety of charts, focus on the message of the chart to
determine which type of chart to use. The following sections present examples of the chart types
that Calc provides, with some notes on the uses of each one.

Column charts
A column chart shows vertical bars, with the height of each bar proportional to its value.
The X axis shows categories and the Y axis shows the value for each category.
Column charts are commonly used for data that show trends over time. They are best for a
relatively small number of data points. It is the default chart type provided by Calc, as it is one of
the most useful and easy to understand. For a larger time series, a line chart would be more
appropriate.
The column chart type has three variants, with a preview pane for each variant as shown in
Figure 200.

Figure 200: Chart Type dialog – Column


When a preview is clicked, its borders are highlighted and the name appears below. The 2D
variants are:
Normal
Shows all data values belonging to a category next to each other. The main focus is on
the individual absolute values, compared to every other value.
Stacked
Shows the data values of each category on top of each other. The main focus is the
overall category value and the individual contribution of each value within the category.
Percent stacked
Shows the relative percentage of each data value with regard to the total of its category.
The main focus is the relative contribution of each value to the category total.
Additional options for creating column charts are:
3D Look
When this box is checked, two options become available in the drop-down list:

228 |Calc Guide 24.8


– Realistic – tries to give the best 3D look.
– Simple – tries to mimic the chart view of other products.
When you check the 3D Look box, a fourth chart variant becomes available called Deep.
This shows the data values of each category lined up, one behind the other.
Shape
Gives options for the shape of the columns in 3D charts. The choices are: Bar, Cylinder,
Cone, and Pyramid.

Bar charts
A bar chart is like a column chart that has been shifted 90 degrees. It shows horizontal bars
rather than vertical columns. In contrast to some other chart types, the Y axis is horizontal and
the X axis is vertical. The Chart Type dialog for a bar chart is essentially the same as for a
column chart, which was described above, with the previews modified to show horizontal bars.
Bar charts can have an immediate visual impact when time is not an important factor — for
example, when comparing the popularity of a few products in a marketplace. They may be
preferred to column charts when the category names are long or there are a significant number
of categories.
In the examples in Figure 201 below:
• To make the first chart, after using the Chart Wizard enter the edit mode and go to Insert
> Grids, deselect Y axis, and choose Insert > Mean Value Lines. Right-click each
mean value line and select Format Mean Value Line to increase the width of the lines.
Create rectangles from the Drawing toolbar to cover the mean value line entries in the
legend. Make them white by right-clicking and selecting Line and then Area.
• The second chart is a 3D chart created with a simple border and cylinder shape. The
chart area is rotated (described in Chapter 6 – Creating Charts and Graphs).
• The third chart eliminates the legend by using labels with the names of the companies
on the Y axis. Whereas the first two charts treat the data as separate data series, this
chart treats the data as one data series in order to have category labels for the X axis.
Rather than colors, a colored hatch pattern is used for the bars.

Figure 201: Bar chart examples

Pie charts
A pie chart shows values as circular sections of a circle. The area of each section is proportional
to its value.

Chapter 7 Gallery of Chart Types | 229


Pie charts are excellent for comparing proportions — comparisons of departmental spending, for
example. They work best with smaller numbers of values, up to about half a dozen; more than
this and the visual impact begins to fade.

Figure 202: Chart Type dialog - Pie


Pie variant options, shown in Figure 202, are:
Normal
Shows values as sections of a complete pie, with the option of separating out individual
pieces. Click the outer edge of a section to separate it from the remaining pie or to join it
back.
Exploded Pie
Shows all of the sections separated from each other. Click and drag any section to move
it along radial lines from the pie center.
Donut
Shows multiple data series. Each data series is shown as one donut shape with a hole
inside, where the next data series can be shown. Click and drag an outer section to
move it along radial lines from the donut center.
Exploded Donut
Shows the outer sections already separated from the remaining donut. Click and drag an
outer section to move it along radial lines from the center.
Bar of Pie
Break down a slice of a pie as a bar sub-chart.
Pie of Pie
Break down a slice of a pie as a pie sub-chart.
The Chart Wizard initially guesses how the data should be presented in the chart. Adjust this on
the Data Range and Data Series pages of the Chart Wizard or by using the Data Ranges dialog.
You can do some interesting things with a pie chart, especially if you make it into a 3D chart. It
can be tilted, given shadows, and generally turned into a work of art. Just do not clutter it so
much that the message is lost, and be careful that tilting does not distort the relative sizes of the
segments.
You can choose in the Chart Wizard to use the exploded pie variant, but this option explodes all
of the pieces (contrary to the preview graphic in Figure 202). If the aim is to accentuate just one

230 |Calc Guide 24.8


piece of the pie, separate out a piece by carefully highlighting it and dragging it out of the group.
After this, the chart area may need to be enlarged to regain the original size of the pieces.

Figure 203: Pie chart examples


The effects achieved in Figure 203 are explained below.
2D pie chart with one section of the pie exploded
In the edit mode, go to Insert > Legend and deselect the Display legend box. Go to
Insert > Data Labels. Select Show value as number and also Show category. Click
the edge of the section (the section will have highlight squares to mark it), and drag it out
from the rest of the sections. The sections will decrease in size. If needed, highlight the
chart wall and drag it at a corner to increase the size.
3D pie chart, exploded variant, with realistic schema and various fill effects
In the edit mode, go to Format > Chart Type and select 3D Look. Go to Insert > Data
Labels and select Show value as percentage. Then carefully select each section so
that it has a wire frame highlight. Right-click and select Format Data Point to get the
Data Point dialog. Choose the Area tab. The illustration in Figure 203 shows one section
formatted with bitmap, one with a radial gradient, one with 50% transparency, and one
with a pattern.
Donut and exploded donut variants, shown in Figure 204, are used to display two sets of related
information, such as two years of financial data. This variant can be misleading for comparing
numeric data, since inner circles are necessarily smaller. For more variety, use a 3D look.

Figure 204: Donut chart examples

Chapter 7 Gallery of Chart Types | 231


Area charts
Like a line or column chart, an area chart shows values as points on the Y axis and categories
on the X axis. The Y values of each data series are connected by lines and the areas below the
lines are colored.
Area charts emphasize volumes of change from one category to the next. They have greater
visual impact than line charts, but the data used will make a difference.

Figure 205: Chart Type dialog - 2D and 3D Area


Area chart variants, shown in Figure 205 are:
Normal
When 3D Look is deselected, plots all data as absolute Y values. It first plots the area of
the last data series in the data range, then the next to last, and so on. Finally the first
data series is drawn over the other data. Thus, higher values in the first data series will
hide lower values of later data series.
Deep
When 3D Look is selected, this variant shows the first data series in front, with
subsequent data series behind.
Stacked
Stacks cumulative values on top of each other. This ensures that all values are visible,
and no data set is hidden by others. However, the Y values no longer represent absolute
values, except for the first data series, which is shown at the bottom of the stacked
areas.
Percent Stacked
Stacks cumulative values on each other and also scales the values as percentages of
the category total.

Figure 206: Area chart examples

232 |Calc Guide 24.8


Normal area charts
Area charts are sometimes tricky to create. Using transparency values may be helpful. To create
the charts in Figure 206, first set up the basic chart using the Chart Wizard. The chart on the left
shows the result. Because of the data overlap, some of it is missing behind the first data series.
This is probably not desirable. The other examples are better solutions.
To create the chart in the center:
After deselecting the Y axis grid, right-click on each data series in turn and select Format
Data Series. On the Transparency tab, set Transparency to 50%. The transparency
makes it easy to see the data hidden behind the first data series.
To create the chart on the right:
After doing the steps above, right-click and select Chart Type. Select the 3D Look
option and select Realistic in the drop-down list. Rotate the chart area using the 3D
View dialog. Instead of a legend, use labels on the Z axis.

Stacked area charts


Other ways of visualizing the same data series are the stacked area chart and the percentage
stacked area chart (Figure 207). In the first example, each point in a data series is added to the
other data series to show the total area. The second example shows a percentage stacked
chart, showing each value in the series as a percentage of the whole.

Figure 207: Stacked and percentage stacked area charts

Line charts
A line chart is useful for showing trends or changes over time when you want to emphasize
continuity. Values are shown as points on the Y axis and the X axis shows categories—often
time series data. The Y values of each data series may be connected by a line.

Note
The difference between line charts, described in this section, and XY (scatter) charts,
described in the next section, is this: line charts show categories along the X axis
while XY (scatter) charts show values along the X axis.

Chapter 7 Gallery of Chart Types | 233


As shown in Figure 208, four variants are available:
Points Only
Plots only points.
Points and Lines
Plots points and connects points of the same data series by a line.
Lines Only
Plots only lines.
3D Lines
Connects points of the same data series by a 3D line.
When Stack series is selected, it shows cumulative Y values above each other. The options are:
• On top – places the value of each data series above the others. The Y values no longer
represent absolute values, except for the first data series, which appears at the bottom of
the chart. This is the default setting.
• Percent – scales the Y values as percentages of the category total.

Figure 208: Chart Type dialog – Line


The Line type drop-down list has three options that determine how the data points are
connected:
Straight
Draws straight lines between the points.
Smooth
Connects the points with curves instead of lines. When this option is selected, click
Properties to open the Smooth Lines dialog (Figure 209) and further specify the curves.
For smooth lines, there are two line type options: Cubic spline or B-spline. These are
mathematical models that join together segments of polynomials to display the curves.
For B-spline lines, there is an option to set the degree of the polynomials. Select a higher
resolution for smoother curves.

234 |Calc Guide 24.8


Figure 209: Smooth Lines dialog
Stepped
Connects points with horizontal and vertical lines only. Click Properties to further specify
the formatting of the lines (Figure 210). The options are self-explanatory.

Figure 210: Stepped Lines dialog


Things to do with lines: thicken them, smooth the contours, just use points, or make them 3D.
However, 3D lines can confuse the viewer, so just using a thicker line often works better. Figure
211 shows some examples of line charts.

Figure 211: Line chart examples

Scatter or XY charts
In contrast to line, column, and bar charts, which contain numeric values on the Y axis and
categories on the X axis, scatter or XY charts contain values along both axes. They are quite
useful, especially for understanding relationships among data that are precise and complex. An
XY chart may contain more than one data series and can perform many tasks, such as
generating a parameter curve or drawing the graph of a function.

Chapter 7 Gallery of Chart Types | 235


Tip
When plotting time on the X axis, make sure that it is not text and is written in the
correct format for your locale. For example, instead of January, use a format such as
1/1/2022. Check locale formats at Tools > Options > Languages and Locales >
General > Formats > Date acceptance patterns.
XY charts are most frequently used to explore the statistical associations among quantitative
variables. There is often a constant value against which to compare the data — for example,
weather data, reactions under different acidity levels, or conditions at various altitudes.

Tip
By custom, if one of the variables is either controlled by an experimenter or it
changes consistently (such as time) it is considered an independent variable and
plotted on the X axis.

XY chart variants

Figure 212: Chart Type dialog – XY (Scatter)


As shown in Figure 212, when the XY (Scatter) chart type is selected, the following variants are
available:
Points Only
Shows an icon for each data point. Calc uses default icons with different forms and
colors for each data series. The default colors are set in Tools > Options > Charts >
Default Colors. Changing the colors and icons is discussed in “Chapter 6: Lines, areas,
and data point icons” for further information.
Points and Lines
Shows both points and lines.
Lines Only
Draws straight lines from one data point to the next. The data points are not indicated by
icons. By default, the drawing order is the same as the order in the data series, but note
the option to sort by X values.
3D Lines
Makes the lines look like tapes. The data points are not shown by icons. In the finished
chart, use the 3D View dialog to set properties like illumination and angle of view.

236 |Calc Guide 24.8


The following options are available:
Sort by X values
Draws the lines in order of the X values. This can be helpful if the data series on the
spreadsheet is not in numeric order.
Line type – Straight
Draws straight line segments.
Line type – Smooth
Draws curves instead of straight line segments. Click Properties to set details for the
curves.
– Cubic spline interpolates the data points with polynomials of degree 3. The transitions
between the polynomial pieces are smooth, having the same slope and curvature.
– B-spline uses parametric, interpolating B-spline curves. The curves are built from
polynomials.
– Resolution determines how many line segments are calculated to draw a piece of
polynomial between two data points. A value in the range 1 to 100. Click any data point
to see the intermediate points.
– Degree of polynomials (only for B-spline line type) sets the degree of these
polynomials. A value in the range 1 to 15.
Line type – Stepped
Uses only horizontal and vertical lines. Click Properties to set details for the stepped
lines.
After a scatter chart is created, its default settings can be changed in ways such as the following.
Be sure to first double-click the chart to enter edit mode. Depending on the option, a data point
or data series may also need to be double-clicked.
• Line styles and icons – double-click or right-click on a data series in the chart to open the
Data Series dialog. See “Chapter 6: Lines, areas, and data point icons” for further
information.
• Error bars – For 2D charts, select Insert > Y Error Bars or X Error Bars to enable the
display of error bars. See “Chapter 6: Error bars” for further information.
• Mean Value Lines and Trend Lines – Enable the display of mean value lines and trend
lines with commands on the Insert menu. See “Chapter 6: Trend and mean value lines”
for further information.

Examples of XY or scatter charts


By default, the first column or row of data (depending on whether the data is arranged in
columns or rows) is represented on the X axis. The rest of the rows of data are then compared
against the first row of data.
Scatter charts may surprise those unfamiliar with how they work. This can be seen in examples
using the following data (Figure 213), which is organized with data series in rows.

Figure 213: Sample currency data

Chapter 7 Gallery of Chart Types | 237


The data range for the chart on the left in Figure 214 includes the cells containing the months.
However, the months do not appear on the chart because only values can be used in XY
(scatter) charts and Calc substitutes them for cardinal numbers.
The data range for the chart on the right in Figure 214 does not include the cells containing the
months. Calc assumes that the first row (or column) of data contains values for the X axis. The Y
values of the other data series are paired with each of those X values. This means that there are
no data points for the Japanese yen but each of the other currencies are shown in comparison to
the yen, since it supplies the X values.

Figure 214: XY (Scatter) chart examples

Bubble charts
A bubble chart is a variation of a scatter chart that can show three variables in two dimensions.
The data points are shown with bubbles. Two variables are plotted along the X and Y axes, while
the third variable is represented by the relative size of the bubbles. These charts are often used
to present financial data or social/demographic data.
One or more data series can be included in a single chart. The data series dialog for a bubble
chart has an entry to define the data range that determines the size of the bubbles.
It may be necessary to build a bubble chart manually in the data series page of the Chart
Wizard. Figure 215 shows how the data ranges can be set for a bubble chart.

Figure 215: Data series entries for a bubble chart


The chart in Figure 216 is based on the data in Figure 215. To format the chart, the data series
are 50% transparent with a radial gradient. The data labels are formatted to be numbers in the
center of the data points (bubbles).

238 |Calc Guide 24.8


Note
Remember that bubble charts require numeric data. If the data series for the X axis
contains text (or dates not formatted as numbers) cardinal numbers will be used for
axis labels.

Figure 216: Bubble chart example

Net charts
Net charts are also known as spider, polar, or radar charts. They display data values as points
on radial spokes, with each spoke representing a variable. They compare data that are not time
series, but show different circumstances, such as variables in a scientific experiment. They are
especially useful for displaying clusters and outliers.
Figure 217 shows an example of a simple net chart. The radial spokes of the net chart are
equivalent to the Y-axes of other charts. All data values are shown with the same scale, so all
data values should have about the same magnitude.

Figure 217: Simple net chart example


Generally, between three and eight axes are best; any more and this type of chart becomes
confusing. Before and after values can be plotted on the same chart, or perhaps expected and
real results, so that differences can be compared.
Figure 218 shows the options for creating a net chart. These are similar to those for area and
line charts, described above. However, keep in mind that area increases as the square of the
distance along the linear spokes. Therefore, net charts can distort the areas representing the

Chapter 7 Gallery of Chart Types | 239


data. Be especially careful about choosing to stack data series. In this case, successive data
series show increasingly large areas that are not proportional to their values.

Figure 218: Chart Type dialog - Net


Figure 219 shows examples of two types of net charts.
• The example on the left is a filled net chart. The color of one of the data series is 50%
transparent. Partial transparency is often best for showing all of the series.
• The example on the right is a net chart with lines and points. The data point icons are
taken from the Gallery and have a 3D look.

Figure 219: Filled net chart and net chart with 3D data point icons

Stock charts
A stock chart illustrates the market trends for stock and shares by giving opening price, bottom
price, top price, and closing price. The transaction volume can also be shown and the X axis
usually represents a time series.
When setting up a stock chart in the Chart Wizard, the data should be arranged as shown in
Figure 220. It specifies which columns should be the opening, low, high, and closing prices of
the stock as well as the transaction volume. However, manual adjustments may still be needed
when defining the data series.

240 |Calc Guide 24.8


Figure 220: Example data arrangement for stock charts
A stock chart organizes data series in two basic ways. The first way is not used in other chart
types. In this case, the open, low, high, and closing values of a row create one data unit in the
chart and one data series consists of several rows containing such data units. The columns
containing transaction volumes are the second way used to organize data series. This is the
familiar way used in other chart types.
Figure 220 shows the data for four data series: 1) the price data for Acme, which contains
columns for open, low, high, and closing prices, 2) the price data for Ajax, which contains
columns for open, low, high, and closing prices, 3) the Acme transaction volume, which is one
column, and 4) the Ajax transaction volume, which is one column.

Stock chart variants


The Chart Wizard offers four stock chart variants, as shown in Figure 221. Note that some of
them do not use all of the data columns.

Figure 221: Chart Type dialog - Stock


The data table in Figure 220 is used to illustrate the variants, which are as follows.
Stock Chart 1
When based only on data in the low and high columns, this variant shows the distance
between bottom price (low) and top price (high) with a vertical line. When the closing
column is also included (Figure 222), it shows an additional horizontal mark for the
closing price.
Stock Chart 2
Based on the open, low, high, and close columns, this variant generates the traditional
candlestick chart (Figure 223). It shows a vertical line between the bottom and top prices
and adds a rectangle in front that shows the range between the opening and closing

Chapter 7 Gallery of Chart Types | 241


prices. For rising values (the opening price is lower than the closing price), the fill color is
white. For falling values, the fill color is black.
Stock Chart 3
Using the low, high, and close columns, draws a chart similar to Stock Chart 1 but with
additional columns for transaction volume. As shown in Figure 224, a secondary Y axis
enables both transaction volume and price to be shown on vertical axes.

Note
Variants 3 and 4 automatically align data to the secondary Y axis. For more
information about a secondary Y axis, see “Chapter 6: Aligning data to secondary
Y axis”.
Stock Chart 4
Based on all five data columns (volume, open, low, high, and close), this variant
combines Stock Chart 2 with a column chart for the transaction volume (Figure 225).

Figure 222: Stock chart variant 1

Figure 223: Stock chart variant 2

242 |Calc Guide 24.8


Figure 224: Stock chart variant 3

Figure 225: Stock chart variant 4

Column and line charts


A column and line chart is useful for displaying two or more distinct but related data series, such
as sales over time (columns) and profit margin trends (lines). It could also show constant
minimum and maximum lines, such as used in medical testing or quality control.
Specify in the Chart Type dialog the number of lines. By default, the first column or row of data is
categories and the last columns or rows of data are lines.
Choose between two variants:
Columns and Lines
As seen in Figure 226, the columns are drawn side by side to easily compare their
values.

Chapter 7 Gallery of Chart Types | 243


Figure 226: Column and line chart with secondary Y axis
Stacked Columns and Lines
The columns are stacked above each other, so that the height of a column shows the
sum of the data values.
The charts in Figures 226 and 227 show sales and profit data for two firms over a period of time.
Note that when first created, the lines were different colors than the columns for the same
company. To reflect the company relationships, change the line colors individually by clicking on
a line, right-clicking, selecting Format Data Series, and formatting the line color and size on the
Line page.
For the background, right-click the chart wall, select Format Wall, and select desired options on
the Gradient page of the Area tab. To align the two data series to the secondary Y axis, see
“Chapter 6: Aligning data to secondary Y axis”.

Figure 227: Column and line chart with stacked columns

Pivot charts
Pivot tables are special types of data tables that simplify the manipulation and analysis of data.
They are widely used, especially for processing large amounts of data. Pivot charts are based
on pivot tables and are created by selecting Insert > Chart, or clicking the Insert Chart icon in
the Standard toolbar, after left-clicking a cell inside a pivot table. Pivot charts inherit many
properties of the other chart types described in this chapter but also have other characteristics
that are described in Chapter 10, Using Pivot Tables.

244 |Calc Guide 24.8


Create box plots with whiskers in Calc
Calc does not currently have the option of creating a data series as a box plot. However, it is
possible to convert the minimum, 1st quartile, median, 3rd quartile, and maximum of a stacked
column chart with the data series in rows and without a legend into a box plot with whiskers.
The conversion of this stacked column chart to a box plot with whiskers is done by replacing the
stacks in the chart with:
• Minimum of the data series
• The difference between the first quartile and the minimum of the data series.
• The difference between the median and the first quartile of the data series.
• The difference between the third quartile and the median of the data series.
• The difference between the maximum and the third quartile of the data series.
When calculating the differences of the first and third quartiles, it is important whether the data
series contains an even or an odd amount of data. For an even amount of data, the function
QUARTILE.EXC (range, parameter) should be used and for an odd amount of data use the
function QUARTILE.INC (range, parameter).
The MIN (range), MEDIAN (range), and MAX (range) functions can be used to calculate the
minimum, median, and maximum, respectively.
Figure 228 shows a stacked column chart in rows of minimum, 1st quartile, median, 3rd quartile,
maximum (with no legend), together with a box plot with whiskers constructed from that column
chart.

Figure 228: Stacked column chart and box plot with whiskers
5) Minimum of the data series 8) The median of the data series
6) The first quartile of the data series 9) The third quartile of the data series is also
7) Bottom of the box to be formed the top of the shapes box
10) The maximum of the data series

Converting the column chart to box plot with whiskers


You can convert a column char to box plot with whiskers by following the next steps:
1) Remove or apply the color white to the bottom stack with Format Data Series in the
context menu.

Chapter 7 Gallery of Chart Types | 245


2) While in edit mode, right-click on the chart and select Insert Y Error Bars from the
context menu.
3) Set the style in the Line Properties section of the Line tab in the Data Series Y Error Bars
dialog box to Continuous and the width to 0.03 cm.
4) On the Y Error Bars tab, select Cell Range and in the Error Indicator section choose
Negative. In the now opened Negative (-) box insert the difference between the 1st
quartile and the minimum.
5) Remove or apply the color white to the top stack with Format Data Series in the context
menu.
6) Set the configuration of the top whisker by performing steps similar to the described
above.
The box consists of the middle stack and the stack above it with the median separating the two
stacks. Both stacks should be framed with borders by selecting Format Data Series from the
context menu. On the Borders tab of the dialog, the Style should be set to Continuous and the
thickness to 0.03 cm. If desired, you can remove or whiten the background on the Plane tab.
For more detailed instructions about making a boxplot, see
https://wiki.documentfoundation.org/Documentation/HowTo/Calc/BoxplotWithWhiskers.

Sparklines
Sparklines are small, simple, cell-sized charts that convey the general shape of data variation
within a dataset. Typically, sparklines are used to show variation over time and are usually drawn
without axes or coordinates.

Figure 229: A simple sparkline example

Tip
Calc’s sparklines are compatible with Microsoft Excel’s version of sparklines and can
be both imported from and exported to Excel.

Creating a sparkline
To create a sparkline:
1) Select the row or column of source data.
2) Either right-click on the selected data and choose Sparklines > Sparkline from the
context menu, or go to Insert > Sparkline on the Menu bar.
3) Calc displays the Sparkline Properties dialog, configured for sparkline creation (Figure
230).
4) Select a single cell as the Output range.
5) Complete the remainder of the Sparkline Properties dialog, as required for the new
sparkline. The available options are described below.
6) Click OK to close the Sparkline Properties dialog and create the sparkline.

246 |Calc Guide 24.8


For sparkline creation, the Sparkline Properties dialog provides the following fields:
Data
• Input range – The input data range for the sparkline. This will be auto-populated if you
selected a data range before creating the sparkline.
• Output range – The cell(s) where the sparkline(s) will be drawn.
Properties
• Type – Select the sparkline type: Line, Column, or Stacked. These options are
described further in the “Types of sparkline” section below.
• Line width – Set the line width for line sparklines.
• Display empty cells as – Gap (skips the missing data and shows a gap in the sequence),
Zero (displays the missing data as zero), or Span (skips the missing data and draws a
line to the next value).
• Display hidden – Check to show all data in the selected input range in the sparkline. If
unchecked, hidden data will be ignored.
• Right-to-left – By default, the sparkline will display the data from left to right for rows and
top to bottom for columns. Checking this box will reverse the display order.
Colors
• Set the main color for the Series of values and check and select colors for various value
types to display in the sparkline. Marker will set the default color for the data points in line
sparklines only.
Axes
• Display X axis – Check to show an x-axis in the sparkline.
• Vertical minimum, Vertical maximum – set the minimum and maximum values for the
y-axis with options Individual, Group (see “Creating multiple sparklines” below), and
Custom. The adjacent numeric input fields are available only when the Custom option is
selected in the corresponding menu.

Note
A sparkline is limited to one cell. To increase the size of the sparkline, increase the
size of the cell. If the sparkline cell is merged into other cells, the sparkline will
remain the same size as in the original cell but the option to modify the sparkline’s
formatting will be lost until the cell is unmerged.

Chapter 7 Gallery of Chart Types | 247


Figure 230: Sparkline Properties dialog (sparkline creation)

Types of sparkline
There are three types of sparkline – line, column, and stacked.
Line
Straight lines are drawn connecting data values.

Figure 231: Line sparkline example


Column
Shows a bar for each data value.

Figure 232: Column sparkline example


Stacked
Shows equally sized bars up or down for positive or negative values. This is sometimes
known as a “win-loss sparkline”.

248 |Calc Guide 24.8


Figure 233: Stacked sparkline example

Creating multiple sparklines


To create multiple sparklines at once:
1) Select multiple rows or columns of source data.
2) Either right-click on the selected data and choose Sparklines > Sparkline from the
context menu, or go to Insert > Sparkline on the Menu bar.
3) Calc displays the Sparkline Properties dialog, configured for sparkline creation (Figure
230).
4) Select an equal number of cells for the Output range as there are rows or columns in the
Input range.
5) Complete the remainder of the Sparkline Properties dialog, as required for the new
sparklines. The available options are described in the notes above Figure 230.
6) Click OK to close the Sparkline Properties dialog and create the sparklines.
The new sparklines will appear in the Output range cells in the same order as the rows or
columns selected in the Input range. They will all share the same formatting and the same
sparkline group (see “Sparkline groups” below).
When setting the Vertical minimum or Vertical maximum to Group, each associated sparkline’s
y-axis will enlarge to include the lowest (for minimum) or highest (for maximum) value from all of
the data in the associated sparklines.

Tip
If the OK button in the Sparkline Properties dialog is unavailable, it is because the
number of cells in the Output range does not match the number of rows or columns
selected in the Input range. Update these dimensions to match and the OK button
will become available.

Modifying a sparkline
Updating a sparkline’s data range
To update a sparkline’s data range:
1) Right-click on the sparkline and choose Sparklines > Edit Sparkline from the context
menu.
2) Calc displays the Sparkline Data Range dialog (Figure 234).
3) Update the Data range as required.
4) Click OK to close the Sparkline Data Range dialog.

Chapter 7 Gallery of Chart Types | 249


Figure 234: Sparkline Data Range dialog

Updating a sparkline’s formatting properties


To update a sparkline’s formatting properties (excluding input and output ranges):
1) Either right-click on the selected sparkline and choose Sparklines > Sparkline from the
context menu, or select the sparkline and go to Insert > Sparkline on the Menu bar.
2) Calc displays the Sparkline Properties dialog, configured for sparkline modification
(Figure 235). Note that the controls on this version of the Sparkline Properties dialog are
identical to those for the sparkline creation version shown in Figure 230, except that the
fields in the Data area for entering the Input range and the Output range are omitted.
3) Modify the fields of the Sparkline Properties dialog, as required. The available options
are as described in the notes above Figure 230.
4) Click OK to close the Sparkline Properties dialog and update the formatting properties of
the selected sparkline.

Figure 235: Sparkline Properties dialog (sparkline modification)

Sparkline groups
Sparklines are defined for one cell, but multiple sparklines can be linked together into a group.
The group shares the same formatting properties for rendering the sparkline. The unique data
that is defined for each sparkline is the data range that will be used.

250 |Calc Guide 24.8


Each individually created sparkline is associated to one sparkline group. When multiple
sparklines are created at once, they initially share the same sparkline group. Any change to the
formatting properties of a sparkline group will affect all related sparklines.
When a sparkline is selected, all sparklines in the same group are highlighted.

Modifying the formatting properties of a sparkline group


To update the formatting properties of a sparkline group:
1) Right-click on a sparkline in the group to be modified and choose Sparklines > Edit
Sparkline Group from the context menu, or select a cell containing a sparkline in the
group to be modified and go to Format > Sparklines > Edit Sparkline Group on the
Menu bar.
2) Calc displays the Sparkline Properties dialog, configured for sparkline modification. Note
that the controls on this version of the Sparkline Properties dialog are identical to those
for the sparkline modification version shown in Figure 235.
3) Modify the fields of the Sparkline Properties dialog, as required. The available options
are described in the notes above Figure 230.
4) Click OK to close the Sparkline Properties dialog and update the formatting properties for
all sparklines in the group.

Grouping and ungrouping sparklines


To group sparklines so that they share the same formatting:
1) First select the sparkline with the group formatting that is to be applied to other
sparklines.
2) Next select the other sparkline(s) to add to the group.
3) Then do one of the following to finish the grouping:
– Right-click one of the selected cells and choose Sparklines > Group Sparklines from
the context menu.
– Go to Format > Sparklines > Group Sparklines on the Menu bar.
To ungroup sparklines so that they can be formatted separately, select the sparklines to be
removed from the sparkline group and do one of the following:
• Right-click one of the selected cells and choose Sparklines > Ungroup Sparklines from
the context menu.
• Go to Format > Sparklines > Ungroup Sparklines on the Menu bar.
The sparklines that were ungrouped will now each have their own sparkline group.

Deleting sparklines
To delete a single sparkline, do one of the following:
• Select the sparkline and press Delete.
• Select the sparkline and go to Format > Sparklines > Delete Sparkline on the Menu
bar.
• Right-click the sparkline and choose Sparklines > Delete Sparkline from the context
menu.

Chapter 7 Gallery of Chart Types | 251


To delete all sparklines in a group, do one of the following:
• Select a sparkline in the group and go to Format > Sparklines > Delete Sparkline
Group on the Menu bar.
• Right-click a sparkline in the group and choose Sparklines > Delete Sparkline Group
from the context menu.

252 |Calc Guide 24.8


Calc Guide 24.8

Chapter 8
Printing, Exporting,
Emailing, and Signing
Printing
Quick printing
To quickly print a spreadsheet, click the Print Directly icon (not visible by default) on the
Standard toolbar to send the entire spreadsheet to your default printer.

Note
You can change the action of the Print Directly icon to send a document to the
printer defined for the document instead of the default printer for the computer. Go to
Tools > Options > Load/Save > General and select the Load printer settings with
the document option.

Controlling printing
For more control over printing, select File > Print on the Menu bar, or click the Print icon on the
Standard toolbar, or use the Ctrl+P key combination to open the Print dialog (Figure 236).

Note
The options selected on the Print dialog apply to this printing of this document only.
To specify default printing settings for LibreOffice, go to Tools > Options >
LibreOffice > Print and Tools > Options > LibreOffice Calc > Print. For details,
see Chapter 15, Setting up and Customizing.
The Print dialog has multiple tabs where you can choose a range of options, as described in the
following sections. Depending on your computer’s operating system, the number of tabs and the
layout of each tab may be different from the illustrations shown in this chapter.
The Print dialog includes a Preview checkbox that enables you to turn on/off a preview of how
your data will appear on the printed page. The preview appears on the left hand side of the
dialog. Adjacent controls allow you to navigate through multiple pages.

General tab
On the General tab of the Print dialog (Figure 236), you can choose from the following options:
• Printer
– Select an available printer from the list of installed printers.
– Click the Properties button to change any required settings of the selected printer.
The options available through this interaction will depend on your printer and system.
• Range and Copies
– Select which sheets and pages to print; single or double sided printing; the number of
copies to print; whether to collate multiple copies; and the page order for printing. (See
“Selecting what to print” below.)
• Page Layout
– Select page layout properties such as paper size, portrait, or landscape orientation;
how many pages are printed per sheet of paper; the order in which the pages are
printed on a sheet of paper; and whether a border is drawn around each page.

254 |Calc Guide 24.8


Figure 236: Print dialog – General tab

LibreOffice Calc tab


On the LibreOffice Calc tab of the Print dialog (Figure 237), you can select whether to suppress
the output of empty pages when you print the spreadsheet.

Figure 237: Print dialog – LibreOffice Calc tab

Printing multiple pages on a single piece of paper


To print multiple pages of a spreadsheet on one piece of paper:
1) Use File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or use
the Ctrl+P key combination to open the Print dialog.

Chapter 8 Printing, Exporting, Emailing, and Signing | 255


2) In the Page Layout section of the General tab, select the number of spreadsheet pages
to print per sheet of paper in the Pages per sheet drop-down list. The preview panel on
the right shows how the pages will look in the printed document.
3) When printing more than one page per sheet, select the order in which the pages are
printed on a sheet in the Order drop-down list (Figure 238).
4) To distinguish each page on a sheet, select the Draw a border around each page
option.
5) Click Print.

Figure 238: Printing more than one spreadsheet page per sheet of paper

Tip
To access some of the options on the General tab of the Print dialog, you may need
to click one of the More buttons. For simplicity, these clicks are deliberately omitted
from the descriptions in this chapter.

Selecting what to print


In the Range and Copies area of the General tab of the Print dialog, choose Print All Sheets in
the From which drop-down to print all sheets in the document. In addition to printing a full
spreadsheet document, you can choose single sheets, multiple sheets, and selections of cells
for printing.
To print an individual sheet:
1) In the spreadsheet, click on the sheet tab to select the sheet you want to print.
2) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or
use the Ctrl+P key combination to open the Print dialog.
3) In the Range and Copies area of the General tab of the Print dialog, choose Print
Selected Sheets in the From which drop-down.
4) Click Print.
To print a range of sheets:
1) In the spreadsheet, select the sheets to print. For details on how to select multiple
sheets, see Chapter 1, Introduction.
2) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or
use the Ctrl+P key combination to open the Print dialog.

256 |Calc Guide 24.8


3) In the Range and Copies area of the General tab of the Print dialog, choose Print
Selected Sheets in the From which drop-down.
4) Click Print.
To print a selection of cells:
1) In the spreadsheet, select the cells to print.
2) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or
use the Ctrl+P key combination to open the Print dialog.
3) In the Range and Copies area of the General tab of the Print dialog, choose Print
Selected Cells in the From which drop-down.
4) Click Print.

Printing in grayscale on a color printer


You may wish to print a spreadsheet in grayscale on a color printer. You can do this in two ways.

Note
Some color printers may print in color regardless of the settings you choose.
For an individual file, you can change the printer settings to print in black and white or grayscale:
1) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or
use the Ctrl+P key combination to open the Print dialog.
2) Click the Properties button to open the Properties dialog for the printer. The available
choices vary from one printer to another, but you should find options for the color
settings. See your printer’s help or user manual for more information.
3) The choices for color might include black and white, or grayscale. Choose grayscale.
4) Click OK to confirm your choice and return to the Print dialog.
5) Click Print to print the document.
You can change the LibreOffice settings to print all color text and graphics as grayscale:
1) Choose Tools > Options > LibreOffice > Print.
2) In the Defaults section, select Convert colors to grayscale. Click OK to save the
change.

Caution
This changes the print settings for all components of LibreOffice, not just Calc.

Previewing pages/sheets before printing


To preview the sheets in Calc before printing:
1) Choose File > Print Preview on the Menu bar, or click the Toggle Print Preview icon on
the Standard toolbar, or press Ctrl+Shift+O.
2) The Calc window now displays the Print Preview toolbar instead of the Formatting
toolbar.

Figure 239: Print Preview toolbar

Chapter 8 Printing, Exporting, Emailing, and Signing | 257


3) To print the document from this view, select File > Print on the Menu bar, or click the
Print icon on the Standard toolbar, or use the Ctrl+P key combination to open the Print
dialog.
4) Choose the print options and click the Print button.
5) Click the Toggle Print Preview icon again, or click the Close Preview icon on the right-
hand side of the Print Preview toolbar, to return to the normal spreadsheet view.

Using print ranges


You can define which range of cells on a spreadsheet are to be printed or exported to a PDF.
The cells on the sheet that are not part of the defined print range are not printed or exported.
Also, any sheets without a defined print range are not printed or exported. Creating a user-
defined print range will replace any existing defined print range.

Defining and printing a print range


To set a user-defined print range:
1) Select the range of cells to be used in the print range.
2) Go to Format > Print Ranges > Define on the Menu bar. If Tools > Options >
LibreOffice Calc > View > Page breaks is enabled, then automatic page break lines are
displayed on the screen, defining the cells included in the print range.
3) Click on the Print Directly icon on the Standard toolbar to print the defined print range,
or open the Print dialog and click Print to print the defined print range.

Tip
You can check the print range by using Toggle Print Preview or the Preview pane in
the Print dialog. Calc will display only the cells in the print range. See “Viewing print
ranges” below.

Editing a print range


At any time, you can edit the print range, For example to add or remove cells, or define rows and
columns to repeat (such as column or row headings). For more details on how to define
repeated rows and/or columns, see “Repeat printing of rows or columns” below.
1) Go to Format > Print Ranges > Edit on the Menu bar to open the Edit Print Ranges
dialog (Figure 240).

Figure 240: Edit Print Ranges dialog

258 |Calc Guide 24.8


2) If only a single range is defined, then clicking anywhere in the Print Range text box
displays the defined print range bounded in blue, as shown in Figure 241.

Figure 241: Single print range marked by a bounding box


3) Multiple cell ranges can also be defined by separating each range with a single comma.
This can be done with the keyboard by typing in a comma and the cell references, using
the same format as the print ranges already defined in the Print Range text box.
Remember to separate the cell references with a colon. New cell ranges can also be
added by holding Ctrl as you select the cell range using the cursor.
4) To remove a print range, select the print range in the Print Range text box and delete it.
Make sure the remaining print ranges are separated by a single comma and there is not
a comma at the end of the sequence.
5) Click OK to save your changes and close the dialog.

Viewing print ranges


After print ranges have been defined, they are formatted with automatic page breaks. To view
the page breaks, go to View > Page Break on the Menu bar to open the preview (Figure 242).
The print ranges are outlined by default with a blue border and contain a pale gray page number
in the center of each page. The non-printing area of the spreadsheet normally has a gray
background.
To exit the page break preview, go to View > Normal on the Menu bar.

Figure 242: Page break preview

Chapter 8 Printing, Exporting, Emailing, and Signing | 259


Named print ranges
In addition to defining a print range for each print job, you can also define a range of cells to be
used repeatedly, without having to select a range of cells every time. This is useful if different
areas of a large spreadsheet have to be printed for different reports; several named print ranges
can be defined to meet this need.

Figure 243: Define Name dialog

Defining and naming


1) Select the cells you want to define and name as a print range, then go to Sheet >
Named Ranges and Expressions > Define on the Menu bar to open the Define Name
dialog (Figure 243). The selected cells are displayed in the Range or formula expression
box.
2) Alternatively, open the Define Name dialog, then select the cells you want to define and
name. The selected cells are then displayed in the Range or formula expression box.
3) Type a name for the range in the Name box. Use only letters, numbers, and underscores
in the name; no spaces, hyphens, or other characters are allowed.
4) If necessary, you can edit or set the range of selected cells for the print range in the
Range or formula expression box. See “Editing a print range” above for more
information.
5) Make sure Document (Global) is selected in the Scope drop-down list.
6) Select Print range from Range Options to define the settings as a print range.
7) Click Add to accept the data and close the dialog.

Printing a named range


To select a named range for printing:
1) Go to Format > Print Ranges > Edit on the Menu bar to open the Edit Print Ranges
dialog (Figure 244).
2) Select the defined and named print range in the Print Range drop-down list.
3) Click OK to close the dialog.
4) Open the Print dialog, which will show only the named range in the preview area. Click
Print.

260 |Calc Guide 24.8


Figure 244: Choosing a named range for printing

Deleting a named print range


To delete a named print range if it is no longer required:
1) Go to Sheet > Named Ranges and Expressions > Manage on the Menu bar, or press
Ctrl+F3, to open the Manage Names dialog (Figure 245).

Figure 245: Manage Names dialog


2) Select the named print range you want to delete and confirm it is a print range by
checking the options from the Range Options.
3) Click Delete and then click OK to close the dialog.

Chapter 8 Printing, Exporting, Emailing, and Signing | 261


Removing print ranges
It may become necessary to remove a defined print range, for example if the whole sheet needs
to be printed later, or you no longer want to print some of the added ranges.
Go to Format > Print Ranges > Clear on the Menu bar to remove all of the defined print ranges
in the spreadsheet, except for named print ranges. After the print range is removed, the default
page break lines for the selected paper size will appear on the screen (assuming that Tools >
Options > LibreOffice Calc > View > Page breaks is enabled).
To remove named print ranges, see “Deleting a named print range” above.

Repeat printing of rows or columns


If a spreadsheet is printed on multiple pages, you can define specific rows or columns (for
example, headings) to repeat print on each printed page.

Using print ranges

. Figure 246: Repeat printing of rows and columns


1) Go to Format > Print Ranges > Edit to open the Edit Print Ranges dialog (Figure 246).
2) In the Rows to Repeat box, type the references for the rows to be repeat printed. For
example, to repeat rows 1, 2 and 3, type $1:$3. This automatically changes the Rows to
Repeat drop-down from - none - to - user defined -.
3) You can also place the cursor in the Rows to Repeat box and then, using the mouse,
select a cell in each row you want to be repeat printed. It is not necessary to select the
whole row.
4) In the Columns to Repeat box, type the references for the columns to be repeat printed.
For example, to repeat column A, type $A. This automatically changes the Columns to
Repeat drop-down from - none - to - user defined -.
5) You can also place the cursor in the Columns to Repeat box and then, using the mouse,
select a cell in each column you want to be repeat printed.
6) Click OK to save your changes and close the dialog.

Using named print ranges


You can also define named print ranges to use for repeat printing of rows or columns as follows:
1) Define and name the rows and/or columns you want to repeat print. See “Named print
ranges” above for more information. Similar to user defined print ranges, it is sufficient to
select one cell from the row or column you want to be repeat printed.

262 |Calc Guide 24.8


2) Select Repeat column and / or Repeat row from Range Options to define the columns
and/or rows for repeat printing in the Define Name dialog (Figure 243 on page 260).
3) Click Add to accept the data and close the dialog.
4) Go to Format > Print Ranges > Edit to open the Edit Print Ranges dialog (Figure 246).
5) Select the defined and named print ranges from the Rows to Repeat and/or Columns to
Repeat drop-down lists.
6) Click OK to save your changes and close the dialog.

Page breaks
While defining a print range can be a powerful tool, you may sometimes need to manually adjust
the page breaks to make sure the spreadsheet prints the way you want it to look. You can insert
two types of page breaks into a spreadsheet:
• Row break – inserts a horizontal page break above a selected cell in a row. For
example, if the selected cell is H15, then a row break is created between rows 14 and
15.
• Column break – inserts a vertical page break to the left of the selected cell in a column.
For example, if the selected cell is H15, then a column break is created between
columns G and H.
When a manual break is inserted, it appears as a blue line or as a bold line between the rows or
columns on the display. The actual appearance depends on your computer setup. To see
manual break lines more easily on your display, you can change their appearance. Go to Tools
> Options > LibreOffice > Application Colors and scroll down to the Spreadsheet section
where you can change how page breaks appear.

Inserting page breaks


1) Select the cell where you want to insert a manual break in the spreadsheet.
2) Go to Sheet > Insert Page Break on the Menu bar.
3) Select Row Break to insert a row break above the cell or Column Break to insert a
column break to the left of the cell.
Alternatively, go to View > Page Break on the Menu bar. Select the cell where you want to insert
a manual break, right-click in the spreadsheet and select Row Break or Column Break in the
context menu. Remember to go to View > Normal on the Menu bar and return to the standard
spreadsheet view.

Deleting page breaks


1) Select the cell where you want to delete a manual break from the spreadsheet.
2) Go to Sheet > Delete Page Break on the Menu bar.
3) Select Row Break to delete a row break from above the cell or Column Break to delete
a column break from the left of the cell.

Note
If an appropriate cell (right of a column break or below a row break) has not been
selected, then the Column Break or Row Break options are grayed out.

Chapter 8 Printing, Exporting, Emailing, and Signing | 263


Deleting multiple page breaks
Multiple manual row and column breaks can exist in the same spreadsheet. If you want to
remove all breaks from the spreadsheet:
1) Go to View > Page Break on the Menu bar.
2) Right-click in the spreadsheet and select Delete Page Breaks in the context menu to
remove all manual breaks from your spreadsheet.
3) Go to View > Normal on the Menu bar to return to the standard spreadsheet view.

Printing options for page styles


When using page styles for your spreadsheets, you can include printing options within the page
style. For example, page order, details, scale to be printed, and so on. Using page styles allows
you to quickly set up and change the printing options of different sheets within your spreadsheet.
See Chapter 5, Using Styles and Templates, for more information about page styles.

. Figure 247: Page Style dialog – Sheet tab


Make sure you have selected the correct sheet within the spreadsheet before setting the print
options. Go to Format > Page Style on the Menu bar to open the Page Style dialog, then click
on the Sheet tab (Figure 247) to set the printing options for a page style. The dialog title
indicates the name of the page style you are about to change.

Tip
You can also open the Page Style dialog by going to the Styles deck of the Sidebar,
right-clicking the relevant page style, and selecting Modify in the context menu.
Another alternative is to double-click the name of the page style on the Status Bar.

264 |Calc Guide 24.8


• Page Order – defines the order in which data in a sheet is numbered and printed when it
does not fit on one printed page. A preview of the page order is shown in the graphic on
the top right of the dialog in Figure 247.
– Top to bottom, then right – prints vertically from the left column to the bottom of the
sheet.
– Left to right, then down – prints horizontally from the top row of the sheet to the right
column.
– First page number – select this option if you want the first page to start with a number
other than 1. Enter the number of the first page in the box.
• Print – defines which elements of the spreadsheet are to be printed.
– Column and row headers – prints the column and row headers.
– Grid – prints the borders of the individual cells as a grid. For the view on screen, make
your selection under Tools > Options > LibreOffice Calc > View > Grid lines.
– Comments – prints the comments defined in the spreadsheet. Comments will be
printed on a separate page, along with the corresponding cell reference.
– Objects/Images – includes all inserted objects (if printable) and graphics with the
printed spreadsheet.
– Charts – prints the charts that have been inserted into your spreadsheet.
– Drawing objects – includes all drawing objects in the printed spreadsheet.
– Formulas – prints the formulas contained in the cells, instead of the results of any
formulas used in the spreadsheet.
– Zero values – specifies that cells with a zero value are printed with a zero (0) in the
cell.
• Scale – defines a page scale for the printed spreadsheet.
– Scaling mode – select a scaling mode in the drop-down list. Appropriate controls for
the scaling mode selected will be shown below the drop-down list box.

Reduce/enlarge printout – specifies a scaling factor to scale all printed pages. Enter
the scaling factor as a percentage in the box, in the range 10% to 400%. Factors less
than 100% reduce the pages, while higher factors enlarge the pages.

Shrink print range(s) to width/height – specifies the maximum number of pages


horizontally (width) and vertically (height) on which every sheet with the current page
style is to be printed. The print ranges are always scaled proportionally, so the
resulting number of pages may be less than specified. You may clear one of the
boxes; then the unspecified dimension will use as many pages as necessary. If you
clear both boxes, the scaling factor will be 100%.

Shrink print range(s) on number of pages – specifies the maximum number of


pages to be printed for each sheet that uses the same page style. The scale will be
reduced as necessary to fit the defined number of pages

Headers and footers


Headers and footers are predefined pieces of text that are printed at the top or bottom of a sheet
outside of the sheet area. Headers and footers are set the same way and you can have different
content on left and right pages that use the same page style.

Chapter 8 Printing, Exporting, Emailing, and Signing | 265


Setting headers and footers
To turn the headers or footers on in your spreadsheet:
1) Select the sheet where you want to turn on the header or footer.
2) Open the Page Style dialog using one of the following methods:
– Select Format > Page Style on the Menu bar.
– Go to the Styles deck of the Sidebar, right-click the relevant page style, and select
Modify in the context menu.
– Double-click the name of the page style on the Status Bar.
3) Select the Header (or Footer) tab (Figure 248). The Header and Footer tabs on the Page
Style dialog are identical.
4) Select the Header on or Footer on option.
5) Enter the values for the other options according to your requirements. These options are
described below.
6) Click OK to save your changes and close the dialog.

Figure 248: Page Style dialog – Header tab


• Header on or Footer on – adds a header or footer to the current page style.
• Same content on left and right pages – causes left and right pages to share the same
header or footer content. To assign a different header or footer to left and right pages,
deselect this option and then click Edit. See “Header or footer contents” below for more
information.
• Same contents on first page – causes the first page to have a different header or
footer than the remaining pages. To assign a different header or footer to the first page,
deselect this option and then click Edit. See “Header or footer contents” below for more
information.

266 |Calc Guide 24.8


• Left margin – enter the amount of space to leave between the left page margin and the
left edge of the header or footer.
• Right margin – enter the amount of space to leave between the right page margin and
the right edge of the header or footer.
• Spacing – enter the amount of space to maintain between the bottom edge of the
header and the top edge of the spreadsheet, or the top edge of the footer and the bottom
edge of the spreadsheet.
• Height – enter the height for the header or footer.
• AutoFit height – automatically adjusts the height of the header or footer to fit the
content.
• Preview box – shown on the right side of Figure 248, this area displays a preview of the
current selection.
• More – opens the Border/Background dialog, where you can define the appearance of
borders and background colors or images for headers or footers. See Chapter 5, Using
Styles and Templates, for more information.
• Edit – opens the Header or Footer dialog where you can add, edit, or format text that is
placed in the header or footer. See “Header or footer contents” below for more
information.

Header or footer contents


The headers and footers in a Calc spreadsheet have three columns for text. Each column can
either be empty or have different contents than the other columns.
1) Select the sheet where you want to turn on the header or footer.
2) Open the Page Style dialog (Figure 248), then select Header on or Footer on and the
options for the header or footer. See “Setting headers and footers” above.
3) Click Edit to open the Header or Footer dialog (Figure 249). If Same content on left
and right pages and / or Same contents on first page is deselected in the Page Style
dialog, the Header or Footer dialog will have tabbed pages where you can set the header
or footer contents for the first page as well as right and left pages
4) To enter standard contents into the header or footer, select an option from the Header or
Footer drop-down list.
5) To enter customized contents into the header or footer, click in one of the area boxes and
type your text, or click in one of the area boxes and click one of the Custom header or
Custom footer icons. These icons are explained below.
6) To change the appearance of the text in the header or footer, click the Text Attributes
icon to open the Text Attributes dialog, where you can set the font, font effects and font
position.
7) Click OK to save the changes to text attributes and close the Text Attributes dialog.
8) Click OK to save the changes to the contents of the header or footer and close the
Header or Footer dialog.
9) Click OK to save the changes to your header or footer and close the Page Style dialog.

Chapter 8 Printing, Exporting, Emailing, and Signing | 267


Figure 249: Header dialog
The options available for a Custom header or Custom footer are as follows:
• Text Attributes – opens a Text Attributes dialog where you can assign formats to new or
selected text. The Text Attributes dialog contains tabs for Font, Font Effects, and
Position.
• Title – inserts a file name placeholder in the selected area. Click and select either Title,
File Name, or Path/File Name in the drop-down menu that opens. If a title has not be
assigned to the spreadsheet, the file name for the spreadsheet will be inserted instead.
• Sheet Name – inserts a placeholder in the selected area for the sheet name of the
selected sheet in the spreadsheet.
• Page – inserts a placeholder in the selected area for the page number. This allows
continuous page numbering in a spreadsheet.
• Pages – inserts a placeholder in the selected area for the total number of pages in the
spreadsheet.
• Date – inserts a placeholder in the selected area for the current date, which will be
repeated in the header/footer on each page of the spreadsheet.
• Time – inserts a placeholder in the selected area for the current time, which will be
repeated in the header/footer on each page of the spreadsheet.

Exporting to PDF
Calc can export documents to PDF (Portable Document Format). This industry-standard file
format is ideal for sending a file to someone else, for viewing using Adobe Acrobat Reader or
any other PDF viewer.

Caution
By default, a document in PDF format is not protected against contents tampering or
editing. The PDF document contents can be edited by specialized software tools,
including LibreOffice Draw.

268 |Calc Guide 24.8


Tip
Unlike Save As, the Export command writes a copy of the current document in a
new file with the chosen format, but keeps the current document and format open in
your session.

Quick export to PDF


Click the Export Directly as PDF icon on the Standard toolbar to export the entire spreadsheet
using the PDF settings most recently selected on the PDF Options dialog (see below). When
doing so, you may only specify the file name and location for the PDF. Other options such as
page range and image compression are not available.

Controlling PDF content and quality


For more control over the content and quality of the resulting PDF, use File > Export as PDF.
The PDF Options dialog opens. This dialog has six tabs (General, Initial View, User Interface,
Links, Security, and Digital Signatures). Select the appropriate settings, and then click Export.
Then enter the location and file name of the PDF to be created, and click Save to export the file.

Tip
You can also access the PDF Options dialog by going to File > Export on the Menu
bar and then then selecting the PDF – Portable Document Format entry in the
Save as type drop-down menu.

General tab of PDF Options dialog


On the General tab (Figure 246), you can choose which pages to include in the PDF, the type of
compression to use for images (which affects the quality of images in the PDF), and other
options. For more information, see the Getting Started Guide or the Help.

Figure 250: PDF Options dialog – General tab

Chapter 8 Printing, Exporting, Emailing, and Signing | 269


Range section
• All: Exports the entire document to PDF.
• Pages: To export a range of pages within a selected sheet, use the format 3-6 (pages 3
to 6). To export single pages, use the format 7;9;11 (pages 7, 9, and 11), or a
combination of the two formats.
• Selection/Selected sheet(s): Exports the selected sheets only. You must first select the
sheets to export. See Selecting Sheets in Chapter 1, Introduction.
• View PDF after export: If selected, your default PDF viewer will open and display the
newly exported PDF.
Images section
• Lossless compression: Images are stored without any loss of quality. This option can
lead to large files when used with photographs. Recommended for other kinds of images
or graphics.
• JPEG compression: Allows for varying degrees of quality, in the range 1 to 100%. A
setting of 90% works well with photographs (small file size, little perceptible loss of
quality).
• Reduce image resolution: Select the required value from the options in the drop-down
menu. Lower DPI (dots per inch) images have lower quality. Higher DPI settings can
greatly increase the size of the exported file.
Watermark section
• Sign with watermark: When this option is selected, a transparent overlay of the text you
enter into the text box will appear on each page of the PDF.
General section
• Hybrid PDF (embed ODF file): Use this setting to export the document as a PDF file
containing two file formats: PDF and ODF. In PDF viewers it behaves like a normal PDF
file, and it remains fully editable in LibreOffice.
• Archive (PDF/A, ISO 19005): PDF/A is an ISO standard for long-term preservation of
documents, by embedding all the information necessary for faithful reproduction (such as
fonts) while forbidding other elements (including forms, security, and encryption). PDF
tags are written. Also select which version of the standard to use, PDF/A-1b, PDF/A-2b,
or PDF/ A-3b.
• Universal Accessibility (PDF/UA): Use this setting to create a universal accessibility-
compliant PDF file that follows the requirements of the PDF/UA standard (formerly ISO
14289).
• Tagged PDF: Tagged PDF contains information about the structure of the document’s
contents. This can help to display the document on devices with different screens, and
when using screen reader software. Some tags that are exported are table of contents,
hyperlinks, and controls. This option can increase file sizes significantly.
• Create PDF form – Submit format: Use the drop-down menu to choose the format of
submitting forms from within the PDF file (FDF, PDF, HTML, or XML).
• Allow duplicate field names – If enabled, the same field name can be used for multiple
fields in the generated PDF file. If disabled, field names will be exported using generated
unique names.
Structure section
• Export outlines: Generally not used in Calc.

270 |Calc Guide 24.8


• Comments as PDF annotations: Exports comments as PDF notes. You may not want
this!
• Comments in margin: Not available in Calc.
• Whole Sheet Export: The setting allows you to export your Calc spreadsheet to PDF,
with the content of a sheet exported as one page in the PDF. This facility is not intended
for printing but allows you to easily see and review the full content of a spreadsheet
document in a PDF form, without the usual slicing of the sheets into printable pages.
Preview pages will have different sizes, as do the source sheets.

Note:
Selecting the Whole Sheet Export option overrides many of the other settings on
the PDF Options dialog.
• Export automatically inserted blank pages: Not available in Calc.
• Use reference XObjects: Reference XObjects enable one PDF file to import content
from another. More information can be found in the ISO 32000 standard that defines the
core specifications of PDF files. If you are not familiar with reference XObjects, leave this
box unchecked.

Initial View tab of PDF Options dialog


On the Initial View tab (Figure 251), you can select how the PDF file opens by default in a PDF
viewer. The options should be self-explanatory.

Figure 251: PDF Options dialog – Initial View tab

Chapter 8 Printing, Exporting, Emailing, and Signing | 271


User Interface tab of PDF Options dialog
On the User Interface tab (Figure 252), you can select options to control how a PDF viewer
displays the file. Some of these options are useful when you are creating a PDF to be used as a
presentation or a kiosk-type display.
Window Options
• Resize window to initial page: the PDF reader window displays the whole first page.
• Center window on screen: the PDF is shown in a reader window centered on screen.
• Open in full screen mode: the PDF reader window is in front of all other windows.
• Display document title: the PDF is shown with the document title in the reader title bar.
Transitions
Not used in Calc.
User Interface Options
• Hide menubar: hides the reader menu bar when the document is active.
• Hide toolbar: hides the reader toolbar when the document is active.
• Hide window controls: hides the reader controls when the document is active.
Collapse Outlines
• Show All: shows all outline levels when the reader opens the PDF.
• Visible levels: shows outline levels down to the selected level (in the range 1 to 10)
when the reader opens the PDF.

Figure 252: PDF Options dialog – User Interface tab

Note
Outlines are generally not used in Calc.

272 |Calc Guide 24.8


Links tab of PDF Options dialog
On the Links tab (Figure 253) you can select how bookmarks and hyperlinks are exported to
PDF.
General
– Export outlines as named destinations: If you have defined Calc sheet names, this
option exports them as “named destinations” to which Web pages and PDF documents
can link. Generally not used in Calc.
– Convert document references to PDF targets: If you have defined links to other
documents with OpenDocument extensions (such as .odt, .ods, and .odp), this option
converts the file extensions to .pdf in the exported PDF document.
– Export URLs relative to file system: If you have defined relative links in a document,
this option exports those links to the PDF. See Relative hyperlinks in the Calc Help for
more information.
Cross-document links
Defines the behavior of links clicked in PDF files. Select one among the following
alternatives:
– Default mode: The PDF links will be handled as specified in your operating system.
– Open with PDF reader application: Use the same application used to display the
PDF document to open linked PDF documents.
– Open with Internet browser: Use the default Internet browser to display linked PDF
documents.

Figure 253: PDF options dialog - Links tab

Security tab of PDF Options dialog


Use the Security tab (Figure 254) to encrypt and set passwords when you export your
spreadsheet and create the PDF file. Setting encryption and passwords also allows you to apply
restrictions on printing and if changes or copying can be carried out on the PDF file.

Chapter 8 Printing, Exporting, Emailing, and Signing | 273


Click the Set Passwords button to open the Set Passwords dialog (Figure 255), where you
enter the passwords. You can enter a password (Set open password) to open the file and an
optional password (Set permission password) to restrict what readers can do with the PDF file.
• With an open password set, the PDF can only be opened with the password. Once
opened, there are no restrictions on what the user can do with the document (for
example, print, copy, or change it).
• With a permission password set, the PDF can be opened by anyone, but its permissions
can be restricted. See Figure 254. After you set a password for permissions, the other
choices on the right half of the Security tab become available.
• With both the open password and permission password set, the PDF can only be
opened with the correct password, and its permissions can be restricted.
The options on the Security tab become available only when passwords have been set.

Note
Permissions settings are effective only if the user’s PDF viewer respects the settings.

Figure 254: PDF Options dialog – Security tab

Figure 255: Set Passwords dialog

274 |Calc Guide 24.8


Digital Signatures tab of PDF Options dialog
The Digital Signatures tab contains the options related to exporting a digitally signed PDF.
Digital signatures are used to ensure that the PDF was really created by the original author (that
is, you), and that the document has not been modified since it was signed.
The signed PDF export uses the keys and X.509 certificates already stored in your default key
store location or on a smartcard. The key store to be used can be selected under Tools >
Options > LibreOffice > Security > Certificate Path. (Not available on Microsoft Windows
systems, where LibreOffice will access the system certificate storage.) When using a smartcard,
it must already be configured for use by your key store. This is usually done during installation of
the smartcard software. Details about using these features is outside the scope of this chapter.

Figure 256: PDF Options dialog – Digital Signatures tab


• Use this certificate to digitally sign PDF documents: Click Select to open the Select
X.509 Certificate dialog, where all certificates found in your selected key store are
displayed. If the key store is protected by a password, you are prompted for it. When
using a smartcard that is protected by a PIN, you are also prompted for that.
Select the certificate to use for digitally signing the exported PDF, then click Select.
All other fields on the Digital Signatures tab are accessible only after a certificate has
been selected.
• Certificate password: Enter the password used for protecting the private key
associated with the selected certificate. Usually this is the key store password. If the key
store password has already been entered in the Select X.509 Certificate dialog, the key
store may already be unlocked and not require the password again.
When using a smartcard, enter the PIN here. Some smartcard software will prompt you
for the PIN again before signing.
• Location, Contact information, Reason: Optionally enter additional information about
the digital signature that will be applied to the PDF. This information will be embedded in
the appropriate PDF fields and will be visible to anyone viewing the PDF. Each or all of
the three fields may be left blank.
• Time Stamp Authority: Optionally select a Time Stamping Authority (TSA) URL. During
the PDF signing process, the TSA will be used to obtain a digitally signed timestamp that
is then embedded in the signature. Anyone viewing the PDF can use this timestamp to
verify when the document was signed.

Chapter 8 Printing, Exporting, Emailing, and Signing | 275


The list of TSA URLs that can be selected is maintained under Tools > Options >
LibreOffice > Security > TSAs. If no TSA URL is selected (the default), the signature
will not be timestamped, but will use the current time from your local computer.

Exporting to other formats


LibreOffice uses the term “export” for some file operations involving a change of file type. If you
want to use another spreadsheet file format (for example, Microsoft Excel), use File > Save As.
If you want to create web pages from your spreadsheet, use File > Export.

Emailing spreadsheets
LibreOffice provides several ways to quickly and easily send a document as an email attachment
in OpenDocument format (LibreOffice default format), other spreadsheet formats, or as a PDF
file. You can also email a document to several recipients. For more information, see the Getting
Started Guide.
To send the spreadsheet as an email attachment:
1) Go to File > Send on the Menu bar and select from the following options. LibreOffice
opens your default email program (if set) with the spreadsheet attached in the selected
format.
– Email Document: the spreadsheet is sent in its current format.
– Email as OpenDocument Spreadsheet: the spreadsheet is sent in the ODF format
(.ods).
– Email as Microsoft Excel: the spreadsheet is sent in the Excel format (.xlsx).
– Email as PDF: The PDF Options dialog opens. Select the parameters to be used for
the PDF file. See “Controlling PDF content and quality” above.
2) In your email program, enter the recipient, subject, and any text you want to add, then
send the email.

Note
Avoid the Send via Bluetooth option, which is non-operational in this software build.

Digital signing of documents


To sign a document digitally, you need a personal key, also known as a certificate. A personal
key is stored on your computer as a combination of a private key, which must be kept secret,
and a public key, which you add to your documents when you sign them. You can get a
certificate from a certification authority, which may be a private company or a governmental
institution.
When you apply a digital signature to a document, a checksum is computed from the document’s
content plus your personal key. The checksum and your public key are stored together with the
document.
When someone later opens the document on any computer with a recent version of LibreOffice,
the program will compute the checksum again and compare it with the stored checksum. If both
are the same, the program will signal that you see the original, unchanged document. In
addition, the program can show you the public key information from the certificate. You can
compare the public key with the public key that is published on the web site of the certificate
authority.

276 |Calc Guide 24.8


Whenever someone changes something in the document, the change breaks the digital
signature.
On Windows operating systems, the Windows features for validating a signature are used. On
Linux systems, files that are supplied by Mozilla Thunderbird or Firefox are used to validate the
signature. For a more detailed description of how to get and manage a certificate, and signature
validation, see About Digital Signatures in the LibreOffice Help.

Applying a digital signature


The following procedure is only an example of how to digitally sign a document. The actual
procedure depends on how your computer is set up and the computer’s operating system.
1) Open the file that you want to digitally sign.
2) Go to File > Digital Signatures > Digital Signatures on the Menu bar.
– If you have set LibreOffice to warn you when the document contains certain types of
information (see “Removing personal data” below), you may see a message box
asking whether you want to continue signing the document. Click Yes to continue, or
click No to exit and take appropriate action to remove the private information and
restart this procedure.
– If you have not saved the document since the last change, a message box appears.
Click Yes to save the file. When you have saved the file, the Digital Signatures dialog
opens (Figure 257). It lists existing signatures and their descriptions (if they have any).
3) On the Digital Signatures dialog, click Sign Document to open the Select X.509
Certificate dialog (Figure 258).
4) Select the certificate you want to use and click Sign to close the Select X.509 Certificate
dialog.
5) The certificate used is displayed in the Digital Signatures dialog with an icon next to its
name. This icon indicates the status of the digital signature.
– An icon with a red seal indicates that the document was signed and the certificate was
validated.
– An icon with a yellow caution triangle overlaying the red seal indicates that the
document is signed but that the certificate could not be validated.
– An icon with a yellow caution triangle by itself indicates an invalid digital signature.
7) Click Close to close the Digital Signatures dialog and digitally sign your file.
A signed document shows an icon in the status bar. You can double-click the icon to view the
certificate. More than one signature can be added to a document.

Note
If you make any changes to the document after digitally signing, the digital signature
is removed automatically and you have to repeat the above procedure to digitally
sign it again.

Chapter 8 Printing, Exporting, Emailing, and Signing | 277


Figure 257: Digital Signatures dialog

Figure 258: Select X.509 Certificate dialog

Signing multiple times with the same signature


In the past, LibreOffice prohibited creating multiple signatures by the same author on a
document, because there was no semantic meaning of signing the same document multiple
times. LibreOffice now provides a signature description, so multiple signatures from the same
author are allowed, because each signature can have a different meaning.
When you select File > Digital Signatures > Digital Signatures, the dialog (Figure 257) lists
existing signatures together with their description (if they have any).
When you click the Sign Document button, the dialog (Figure 258) for certificate selection now
also asks for an optional description.
Changing the value of an existing description invalidates the signature.

278 |Calc Guide 24.8


Digitally signing macros
If you sign a document that contains macros, the macros inside the document are signed
automatically. If you want to sign only the macros, but not the document, go to Tools > Macros
> Digital Signature on the Menu bar and apply the signature as described above.

Removing personal data


You may wish to ensure that personal data, versions, notes, hidden information, or recorded
changes are removed from files before you send them to other people or create PDFs from
them.
• In Tools > Options > LibreOffice > Security > Options, you can set Calc to remind you
when files contain certain information and to remove personal information automatically
on saving.
• To remove personal and some other data from a file, go to File > Properties. On the
General tab, deselect Apply user data and then click Reset Properties. This removes
any names in the created and modified fields, deletes the modification and printing dates,
and resets the Total editing time to zero, the creation date to the current date and time,
and the Revision number to 1.
• To remove version information, either go to File > Versions on the Menu bar, select the
versions from the list and click Delete, or go to File > Save As and save the file with a
different name.

Chapter 8 Printing, Exporting, Emailing, and Signing | 279


Calc Guide 24.8

Chapter 9
Using Formulas and
Functions
Introduction
In earlier chapters, we focused on entering two basic types of data into spreadsheet cells:
numbers and text. However, there are times when the content of a cell isn't straightforward and
depends on the values in other cells. To address this, we use a third type of data: formulas.
Formulas are equations that combine numbers and variables to calculate a result. In
spreadsheets, the variables are cell references containing the data needed for the calculation.
In addition to formulas, spreadsheets also offer functions, which are predefined calculations
designed to help analyze or manipulate data efficiently. By providing the required inputs, called
arguments, the function performs the calculation automatically. Functions simplify the process of
creating complex formulas, making it easier to achieve the results you need.

Setting up a spreadsheet
If you are setting up more than a simple one-sheet system in Calc, it is worth planning ahead a
little. Make sure to:
• Choose the right kind of input.
• Include documentation.
• Incorporate a system of error-checking.
The points above are explained further below.

Formula inputs
Many users create lengthy and complex formulas by directly typing fixed values into them. For
example, when converting one currency to another, the formula requires the current exchange
rate. Suppose you enter a formula in cell C1 as =0.75*B1 to calculate the value in euros for the
dollar amount in cell B1. If the exchange rate changes from 0.75 to another value, you’ll need to
manually update the formula.
A better approach is to use an input cell for the exchange rate and reference that cell in your
formulas. This makes it easy to adjust calculations when the exchange rate changes. For
example, you can test different scenarios—such as an exchange rate of 0.70 or 0.80—without
editing the formula, and it becomes clear which rate is being used.
Additionally, breaking complex formulas into smaller, more manageable parts (as explained
below) reduces errors and makes troubleshooting much easier.

Comments, labels, and headings


A common reason spreadsheets fail is the lack of proper documentation. Many users start with a
simple sheet that gradually evolves into something far more complex. Without documentation,
the original purpose and methods used in the spreadsheet often become unclear and difficult to
interpret. In such cases, it’s often easier to start over from scratch, wasting the effort already
invested.
By adding comments to cells and using clear labels and headings, you can make your
spreadsheet much easier to understand and modify—either by yourself or others—saving
significant time and effort in the future.

282 |Calc Guide 24.8


Error-checking formulas
Errors often occur when adding columns of data or cell ranges due to missed cells, incorrect
range specifications, or double-counting. To minimize these issues, it's helpful to include checks
in your spreadsheets.
For instance, when calculating the total of a column, use the SUM function to find the column's
total. Then, as a verification step, calculate row totals in a separate (non-printing) column and
add these together. The sum of the row totals should match the sum of the column totals. If the
two values don’t match, there’s an error in your data.
To streamline this process, you can create a formula to calculate the difference between the two
totals. If the result is non-zero, it can automatically flag an error (see Figure 259).

Figure 259: Error checking of formulas


To help locate problems with the formulas in your spreadsheet, Calc provides a display option to
visually highlight any cells in a sheet that contain formulas. This option is disabled by default. To
enable the option, go to Tools > Options > LibreOffice Calc > View and tick the Formula
indicator and hint option in the Display area of the dialog. Calc subsequently draws a blue
triangle in the bottom-left corner of each cell that contains a formula. When hovering the pointer
over the triangle, the formula in the cell is displayed in a tool tip (even if a different cell is
selected).

Figure 260: Formula indicator and hint

Creating formulas
You can enter formulas in two ways:
1) Using the Function Wizard or the Functions section in the Sidebar.
2) Typing directly into the cell or the Input line.

Chapter 9 Using Formulas and Functions | 283


Every formula must begin with an = symbol. When typing directly, you typically start a formula
with =. However, if the formula starts with a + or – (for example, -2*A1), Calc will automatically
prepend the = symbol.
Keep in mind:
• If you enter only a number (for example, -2 or +3), it will not be treated as a formula.
• If your entry starts with anything other than =, +, or -, Calc interprets it as text rather than
a formula.

Operators in formulas
Each cell in the sheet can be used as a data holder or a place for data calculations. To enter
data, simply type in the cell and move to the next cell or press Enter. With formulas, the equals
sign indicates that the cell will be used for a calculation. An example of a mathematical
calculation like 15 + 46 is shown in Figure 261.
While the calculation on the left used only one cell, the real power is shown on the right where
the data is placed in cells and the calculation is performed using references to the cells. In this
case, cells B3 and B4 were the data holders, with B5 the cell where the calculation was
performed. Notice that the formula was shown as =B3+B4. The plus sign indicates that the
contents of cells B3 and B4 are to be added together and then have the result in the cell holding
the formula. All formulas build upon this concept. Other ways of using formulas are shown in
Table 9.
These cell references allow formulas to use data from anywhere in the sheet being worked on,
or from any other sheet in the document that is opened. If the data needed was in different
sheets, they would be referenced by referring to the name of the sheet, for example
=$Sheet2.B12+$Sheet3.A11.

Note
To enter the = symbol for a purpose other than creating a formula as described in
this chapter, type an apostrophe or single quotation mark before the =. For example,
in the entry '= means different things to different people, Calc treats everything after
the single quotation mark—including the = sign—as text.

284 |Calc Guide 24.8


Figure 261: A simple calculation

Table 9: Common ways to use formulas


Formula Description
=A1+10 Displays the contents of cell A1 plus 10.
=A1*16% Displays 16% of the contents of A1.
=A1*A2 Displays the result of multiplying the contents of A1 and
A2.
=ROUND(A1,1) Displays the contents of cell A1 rounded to one decimal
place.
=EFFECT(5%,12) Calculates the effective interest for 5% annual nominal
interest with 12 payments a year.
=B8-SUM(B10:B14) Calculates B8 minus the sum of the cells B10 to B14.
=SUM(B8,SUM(B10:B14)) Calculates the sum of cells B10 to B14 and adds the
value to B8.
=SUM(B1:B1048576) Sums all numbers in column B.
=AVERAGE(BloodSugar) Displays the average of a named range defined under
the name BloodSugar. It is possible to establish ranges
for inclusion by naming them using Sheet > Named
Ranges and Expressions > Define, for example
BloodSugar representing a range such as B3:B10.

Chapter 9 Using Formulas and Functions | 285


Formula Description
=IF(C31>140, “HIGH”, “OK”) Logical functions can also be performed as represented
by the IF statement which results in a conditional
response based upon the data in the identified cell. In
this example, if the contents of C31 is greater than 140,
then HIGH is displayed, otherwise OK is displayed.

Operator types
The following operator types may be used:
arithmetic
comparative
text
reference
Each of these types are described in the sections that follow.

Arithmetic operators
The addition, subtraction, multiplication, and division operators return numerical results. The
negation and percent operators identify a characteristic of the number found in the cell, for
example -37. The example for exponentiation illustrates how to enter a number that is being
multiplied by itself a certain number of times, for example 2^3 = 2*2*2.
Table 10: Arithmetic operators
Operator Name Example
+ (Plus) Addition =1+1
– (Minus) Subtraction =2–1
– (Minus) Negation –5
* (Asterisk) Multiplication =2*2
/ (Slash) Division =10/5
% (Percent) Percent 15%
^ (Caret) Exponentiation =2^3

Comparative operators
Comparative operators are found in formulas that use the IF function and return either a true or
false answer; for example, =IF(B6>G12, 127, 0) which, loosely translated, means if the
contents of cell B6 are greater than the contents of cell G12, then return the number 127,
otherwise return the number 0.
A direct answer of TRUE or FALSE can be obtained by entering a formula such as =B6>B12. If
the numbers found in the referenced cells are accurately represented, the answer TRUE is
returned, otherwise FALSE is returned.
Table 11: Comparative operators
Operator Name Example Result (A=4, B=5)
= Equal A1=B1 FALSE
> Greater than A1>B1 FALSE
< Less than A1<B1 TRUE
>= Greater than or equal to A1>=B1 FALSE
<= Less than or equal to A1<=B1 TRUE
<> Inequality A1<>B1 TRUE

286 |Calc Guide 24.8


If cell A1 contains the numerical value 4 and cell B1 contains the numerical value 5, the above
examples would yield results of FALSE, FALSE, TRUE, FALSE, TRUE, and TRUE.

Text operators
Spreadsheets often include text data. To allow flexibility in how this data is displayed, text from
different cells or sources can be combined into a single string. This process is known as
concatenation. For example, you can join pieces of text from various cells to create a single
message or label. Figure 262 illustrates this concept.

Figure 262: Text concatenation


In this example, specific pieces of the text were found in three different cells. To join these
segments together, the formula also adds required spaces and punctuation enclosed within
quotation marks, resulting in a formula of =B2 & “ ” & C2 & “, ” & D2. The result is the
concatenation into a date formatted in a particular sequence.
Note that the CONCATENATE function can be used to perform the same operation as the
formula.

Reference operators
A single cell in a spreadsheet is identified by its column letter (found at the top of the columns)
and its row number (found along the left side of the rows). For spreadsheets read from left to
right, the upper-left cell is referenced as A1.
While a reference typically points to one cell, it can also refer to a range of cells in a rectangle
(e.g., A1:B5) or even a cuboid range in 3D references across sheets. References can also
include lists of non-contiguous cells or ranges. To create these more complex references, you
use reference operators.
Reference range operator
The range operator is written as a colon. An expression using the range operator has the
following syntax:
reference upper left : reference lower right
The range operator builds a reference to the smallest range including both the cells referenced
with the left reference and the cells referenced with the right reference.
In the upper left corner of Figure 263 the reference A1:D12 is shown, corresponding to the cells
included in the drag operation with the mouse to highlight the range.

Chapter 9 Using Formulas and Functions | 287


Figure 263: Reference operator for a range
Table 12: Reference range operator examples
Example Description
A2:B4 Reference to a rectangle range with 6 cells, 2 column width × 3
row height. When you click on the reference in the formula in the
input line, a border indicates the rectangle.
(A2:B4):C9 Reference to a rectangle range with cell A2 top left and cell C9
bottom right. So the range contains 24 cells, 3 column width × 8
row height. This method of addressing extends the initial range
from A2:B4 to A2:C9.
Sheet1.A3:Sheet3.D4 Reference to a cuboid range with 24 cells, 4 column width × 2
row height × 3 sheets depth. (Assumes that sheets Sheet1,
Sheet2, and Sheet3 appear in that order on the Sheet tabs area.)
B:B Reference to all cells of column B.
A:D Reference to all cells of columns A to D.
20:20 Reference to all cells of row 20.
1:20 Reference to all cell of rows 1 to 20.

When you enter B4:A2, B2:A4, or A4:B2 directly, Calc will turn it to A2:B4. So the left top cell of
the range is left of the colon and the bottom right cell is right of the colon. But if you name the
cell B4 for example with _start and A2 with _end, you can use _start:_end without any error. For
more information on naming cells, see “Named ranges” below.
Reference concatenation operator
The concatenation operator is written as a tilde. An expression using the concatenation operator
has the following syntax:
reference left ~ reference right
The result of such an expression is a reference list, which is an ordered list of references. Some
functions can take a reference list as an argument, SUM, MAX, or INDEX for example.
The reference concatenation is sometimes called 'union'. But it is not the union of the two sets
'reference left' and 'reference right' as normally understood in set theory. COUNT(A1:C3~B2:D2)
returns 12 (=9+3), but it has only 10 cells when considered as the union of the two sets of cells.
Notice that SUM(A1:C3,B2:D2) is different from SUM(A1:C3~B2:D2) although they give the
same result. The first is a function call with 2 parameters, each of them is reference to a range.
The second is a function call with 1 parameter, which is a reference list.
The reference concatenation also applies to whole rows and whole columns. For example
SUM(A:B~D:D) is the sum of all cells in columns A and B and the column D.

288 |Calc Guide 24.8


Reference intersection operator
The intersection operator is written as an exclamation mark. An expression using the intersection
operator has the following syntax:
reference left ! reference right
If the references refer to single ranges, the result is a reference to a single range, containing all
cells, which are both in the left reference and in the right reference.
If the references are reference lists, then each list item from the left is intersected with each one
from the right and these results are concatenated to a reference list. The order is to first intersect
the first item from the left with all items from the right, then intersect the second item from the left
with all items from the right, and so on.
Examples
A2:B4 ! B3:D6
This results in a reference to the range B3:B4, because these cells are inside A2:B4 and inside
B3:D6. This is illustrated in Figure 264, in which the cells in the range A2:B4 have orange
backgrounds and the cells in the range B3:D6 have thick black borders. The cells that have both
an orange background and a thick black border (B3:B4) form the intersection of the two ranges.

Figure 264: Simple example of reference intersection operator


(A2:B4~B1:C2) ! (B2:C6~C1:D3)
First the intersections A2:B4!B2:C6, A2:B4!C1:D3, B1:C2!B2:C6, and B1:C2!C1:D3 are
calculated. This results in B2:B4, empty, B2:C2, and C1:C2. Then these results are
concatenated, dropping empty parts. So the final result is the reference list B2:B4 ~ B2:C2 ~
C1:C2.
A:B ! 10:10
This calculates the intersection of columns A and B with row 10, thus selecting A10 and B10.
You can use the intersection operator to refer to a cell in a cross tabulation in an understandable
way. If you have columns labeled 'Temperature' and 'Precipitation' and the rows labeled
'January', 'February', 'March', and so on, then the following expression
'February' ! 'Temperature'
will reference the cell containing the temperature in February. The correct operation of this
expression assumes that the Automatically find column and row labels option on the Tools >
Options > LibreOffice Calc > Calculate dialog is enabled. The expression is equivalent to 3:3
! B:B, assuming that the data for February is in row 3 while the temperature data is in
column B.
The intersection operator (!) has a higher precedence than the concatenation operator (~), but
do not rely on precedence.

Tip
Always put the part that is to be calculated first in parentheses.

Chapter 9 Using Formulas and Functions | 289


Relative and absolute references
References are the way that we refer to the location of a particular cell in Calc and can be either
relative (to the current cell) or absolute (a fixed amount).

Relative referencing
An example of a relative reference will illustrate the difference between a relative reference and
absolute reference using the spreadsheet from Figure 265.
1) Type the numbers 4 and 11 into cells C3 and C4 respectively of that spreadsheet.
2) Copy the formula in cell B5 (=B3+B4) to cell C5. You can do this by using a simple copy
and paste or click and drag B5 to C5 as shown below. The formula in B5 calculates the
sum of values in the two cells B3 and B4.
3) Click in cell C5. The formula bar shows =C3+C4 rather than =B3+B4 and the value in C5
is 15, the sum of 4 and 11 which are the values in C3 and C4.
In cell B5 the references to cells B3 and B4 are relative references. This means that Calc
interprets the formula in B5, applies it to the cells in the B column, and puts the result in the cell
holding the formula. When you copied the formula to another cell, the same procedure was used
to calculate the value to put in that cell. This time the formula in cell C5 referred to cells C3 and
C4.

Figure 265: Relative references


You can think of a relative address as a pair of offsets to the current cell. Cell B1 is 1 column to
the left of cell C5 and 4 rows above. The address could be written as R[-4]C[-1].
Whenever you copy this formula from cell B5 to another cell, the result will always be the sum of
the two numbers taken from the two cells one and two rows above the cell containing the
formula.
Relative addressing is the default method of referring to addresses in Calc.

Absolute referencing
You may want to multiply a column of numbers by a fixed amount. A column of figures might
show amounts in US Dollars. To convert these amounts to Euros it is necessary to multiply each
dollar amount by the exchange rate. $US10.00 would be multiplied by 0.75 to convert to Euros,
in this case Eur7.50. The following example shows how to input an exchange rate and use that
rate to convert amounts in a column from USD to Euros.
1) Input the exchange rate Eur:USD (0.75) in cell D1. Enter amounts (in USD) into cells D2,
D3 and D4, for example 10, 20, and 30.
2) In cell E2 type the formula =D2*D1. The result is 7.5, correctly shown.

290 |Calc Guide 24.8


3) Copy the formula in cell E2 to cell E3. The result is 200, clearly wrong! Calc has copied
the formula using relative addressing: the formula in E3 is =D3*D2 and not what we want,
which is =D3*D1.
4) In cell E2 edit the formula to be =D2*$D$1. Copy it to cells E3 and E4. The results are
now 15 and 22.5 which are correct.
The $ signs before the D and the 1 convert the reference to cell D1 from relative to absolute or
fixed. If the formula is copied to another cell the second part will always show $D$1. The
interpretation of this formula is “take the value in the cell one column to the left in the same row
and multiply it by the value in cell D1”.

Figure 266: Absolute references


Cell references can be shown in four ways, listed in Table 13.
Table 13: Cell reference types
Reference Explanation
D1 Relative, from cell E3 it is the cell one column to the left and two rows above
$D$1 Absolute, it is the cell D1
$D1 Partially absolute, from cell E3 it is the cell in column D and two rows above
D$1 Partially absolute, from cell E3 it is the cell one column to the left and in row 1

Tip
To change references in formulas, highlight the cell and press F4 to cycle through the
four types of references. To cycle only part of the formula select the cells in the
formula bar and cycle with F4. Selecting the menu option Sheet > Cycle Cell
Reference Types is equivalent to pressing the F4 shortcut.

Chapter 9 Using Formulas and Functions | 291


Knowledge of the use of relative and absolute references is essential if you want to copy and
paste formulas and to link spreadsheets.

Named ranges
You can assign names to individual cells or ranges of cells to improve formula readability and
simplify spreadsheet management. For example, instead of using the formula =SUM(B1:B10) to
sum weights in the range B1:B10, you can name the range "Weight" and write the formula as
=SUM(Weight). This makes your formulas more intuitive and easier to understand.
An additional benefit of named ranges is that they dynamically update in all associated formulas
when the range’s location or size changes. For instance, if the "Weight" range moves to
P10:P30, you only need to update the named range definition. The formulas referencing
"Weight" will automatically adjust without further changes.
To define a named cell or range:
1) Select the cell or range.
2) Navigate to Sheet > Named Ranges and Expressions > Define in the menu.
3) In the dialog (as shown in Figure 9), specify the name and scope for the named range.

Figure 267: Define Name dialog


You can also define a named range directly in the sheet by selecting the range and typing its
name in the Name Box at the left of the Formula Bar (Figure 268).

292 |Calc Guide 24.8


Figure 268: Inserting name in the range box to define a named range
To quickly access a named range, select the named range in the Name Box drop-down above.
The named range is shown on the screen and selected.

Figure 269: Manage Names dialog


To modify a named range, use the Manage Names dialog (Figure 269). This dialog is accessed
by selecting Sheet > Named Ranges and Expressions > Manage on the Menu bar or pressing
Ctrl+F3.
Named expressions
You also can give a long or complex formula a name. To name a formula, open the Define Name
dialog (Figure 267) and enter the formula expression in the Range or formula expression box.
Name the expression and click Add.

Chapter 9 Using Formulas and Functions | 293


As an example, suppose you need to compute in cells C1 to C10 the circumference of a set of
circles and you are given their radius in B1 to B10. Define a named expression
CIRCUMFERENCE, with expression =2*PI()*B1 and click Add to close the dialog. In cell C1,
type =CIRCUMFERENCE and press Enter. The formula is applied to cell C1. Copy cell C1 and
paste in the remaining cells from C2 to C10 and you have the circumferences of all the circles.
All cells in the range C1:C10 have the expression =CIRCUMFERENCE.
Note that the named expression uses the same rules for cell addressing, that is, absolute and
relative references.

Order of calculation
The order of calculation refers to the sequence in which operations are performed in a formula.
For an overview of these rules, see the Wikipedia article on orders of operations at
https://en.wikipedia.org/wiki/Order_of_operations .
In spreadsheets, division and multiplication are performed before addition and subtraction. A
common misconception is that calculations occur strictly from left to right, as one might read an
equation in English. However, Calc evaluates the entire formula based on established
precedence rules, prioritizing multiplication and division over addition and subtraction.
To ensure your formula produces the expected result, it's a good practice to test it thoroughly. If
necessary, use parentheses to clarify the order of operations and make your intent explicit. The
following example demonstrates how the order of calculation is applied in practice.
Table 14: Order of calculation
Left To Right Calculation Ordered Calculation
1+3*2+3 = 11 =1+3*2+3 result 10
1+3 = 4, then 4x2 = 8, then 8+3 = 11 3*2 = 6, then 1+6+3 = 10
Another possible intention could be: The program resolves the multiplication of 3 x
1+3*2+3 = 20 2 before dealing with the numbers being
added.
1+3 = 4, then 2+3 = 5, then 4x5=20

If you intend for the result to be either of the two possible solutions on the left, order the formula
as:
((1+3) * 2)+3 = 11 (1+3) * (2+3) = 20

Note
Use parentheses to group operations in the order you intend; for example,
=B4+G12*C4/M12 might become =((B4+G12)*C4)/M12.

Calculations linking sheets


Calc allows you to link data across multiple sheets within a spreadsheet, making it a powerful
tool for organizing and referencing information. To make your spreadsheet easier to navigate,
assign meaningful names to sheets, such as "Payroll" or "Boise Sales," instead of using default
names like "Sheet1."
The SHEET() function can be used to return the current sheet's position in the order of sheets.
For example, if you have multiple sheets named Sheet1, Sheet2, etc., numbered from left to
right, dragging a sheet to a new location updates its position, and SHEET() reflects the new
order.
By default, a new Calc instance includes only one sheet, but you can add, rename, and
rearrange sheets as needed to organize your data effectively.

294 |Calc Guide 24.8


For example, if the formula =SHEET() is put into A1 on Sheet 1 it returns the value 1. If you drag
Sheet 1 to be positioned between sheets 2 and 3 then the value changes to 2; it is now the
second sheet in the order.
An example of calculations obtaining data from other work can be seen in a business setting
where a business combines revenues and costs of each of its branch operations into a single
combined sheet. See Figures 270 to 273.

Figure 270: Sheet containing data for Branch 1

Figure 271: Sheet containing data for Branch 2

Chapter 9 Using Formulas and Functions | 295


Figure 272: Sheet containing data for Branch 3

Figure 273: Sheet containing combined data for all branches


The sheets have been set up with identical structures. The easiest way to do this is to open a
new spreadsheet, set up the first branch sheet, input data, format cells, and prepare the
formulas for the various sums of rows and columns. After that, create copies from the first sheet
as follows:
1) On the sheet tab, right-click and select Rename Sheet. Type Branch1. Right-click on the
tab again and select Move or Copy Sheet.
2) In the Move/Copy Sheet dialog (Figure 274), select the Copy option (automatically
selected if there is only one sheet in the spreadsheet) and select -move to end
position- in the Insert before area. Change the entry in New name to Branch2. Click
Copy. Repeat to produce the Branch3 and Combined sheets.

296 |Calc Guide 24.8


Figure 274: Copying a sheet
3) Enter the data for Branch 2 and Branch 3 into the respective sheets. Each sheet stands
alone and reports the results for the individual branches.
4) In the Combined sheet, click on cell K7. Type =, click on the tab Branch1, click on cell
K7, press +, repeat for sheets Branch2 and Branch3, and press Enter. You now have a
formula in cell K7 which adds the revenue from greenery sales for the three branches.

Figure 275: Combined sheet showing linking between branch sheets


5) Copy the formula, highlight the range K7:N17, click Edit > Paste Special > Paste
Special on the Menu bar, or right-click and select Paste Special > Paste Special in the
context menu, or press Ctrl+Shift+V. Uncheck the All and Formats options in the
Paste area of the dialog, check all other options in that area, and click OK. You will see
the following message:

Chapter 9 Using Formulas and Functions | 297


Figure 276: Linking sheets: pasting a formula to a cell range
6) Click Yes. You have now copied the formulas into each cell while maintaining the format
set up in the original sheet. Of course, in this example you would have to tidy up the
sheet by removing the zeros in the non-formatted rows.

Figure 277: Linking sheets: Copy / Paste Special from K7:N17


The Function Wizard can also be used to accomplish the linking. Use of this wizard is described
in detail in “Using the Function Wizard” on page 301.

Understanding functions
Calc includes over 500 functions to help you analyze and reference data. Many of these
functions are for use with numbers, but others are used with dates and times or even text. A
function may be as simple as adding two numbers together or finding the average of a list of
numbers, or it may be as complex as calculating the standard deviation of a sample or a
hyperbolic tangent of a number.
Typically, the name of a function is an abbreviated description of what the function does. For
instance, the FV function gives the future value of an investment, while BIN2HEX converts a
binary number to a hexadecimal number. In Calc, functions can be entered either in upper, lower
or mixed cases.
A few basic functions are somewhat similar to operators. Examples:
+ (plus) This operator adds two numbers together for a result. SUM() on the other hand
adds groups of contiguous ranges of numbers together.
* (star) This operator multiplies two numbers together for a result. PRODUCT() does the
same for multiplying that SUM() does for adding.

Each function has a number of arguments used in the calculations. These arguments may or
may not have their own name. Your task is to enter the arguments needed to run the function. In
some cases, the arguments have predefined choices, and you may need to refer to the text on
the Function Wizard and the Functions deck, or the Help, to understand them. More often,

298 |Calc Guide 24.8


however, an argument is a value that you enter manually, or one already entered in a cell or
range of cells in the spreadsheet. In Calc, you can enter values from other cells by typing in their
name or range, or—unlike the case in some spreadsheets—by selecting cells with the mouse. If
the values in the cells change, then the result of the function is automatically updated.

Tip
You can find more details about each of the available functions in the Calc Functions
area of The Document Foundation Wiki at
https://wiki.documentfoundation.org/Documentation/Calc_Functions. These wiki
pages are a recent addition to the available documentation and are continuously
undergoing improvement.

Compatibility with other spreadsheet applications


For many functions, Calc follows the OpenFormula standard defined in Part 2 (Recalculated
Formula (OpenFormula) Format) of the Open Document Format for Office Applications
(OpenDocument) Version 1.2. This standard can be accessed at the OASIS website
(https://www.oasis-open.org/) or the ISO website (https://www.iso.org/standard/66375.html).
Calc’s general support for OpenFormula leads to a level of inherent compatibility with the
function set of any other spreadsheet application that follows the same standard. (There are
some functions within Calc that are not in accordance with OpenFormula but many of these are
included specifically to improve the exchange of files between Calc and Microsoft Excel.)
Calc can open spreadsheets created using many different applications and can save
spreadsheets in many different formats despite differences in the applications.
For example, calls to Excel’s CEILING function are converted to reference the CEILING.XCL
function when the Excel file is opened in Calc. Similarly, calls to Calc’s FLOOR function are
automatically converted to reference Excel’s FLOOR.MATH function when the file is saved in
Calc.
The Document Foundation’s wiki offers a comparison of the features of LibreOffice and Microsoft
Office, which you can view here. According to this comparison, Calc currently provides 508
discrete functions. Of these, only 30 are unique to Calc, while the rest have counterparts in
Microsoft Excel. This indicates a high level of commonality between the function sets of Calc and
Excel, allowing many functions to be used interchangeably, thus enhancing interoperability.
In some instances, a Calc function may produce a result that aligns with international standards
but differs from the result produced by the equivalent Excel function. In such cases, Calc often
includes a similarly named function with a modifier (such as “_ADD” or “_EXCEL2003”) to
provide the same result as the Excel function.

Structure of functions
All spreadsheet functions share a similar structure. While using tools like a Function Wizard can
simplify function entry, understanding the structure is valuable for troubleshooting.
Here’s an example of a function to count cells matching specific criteria:
=DCOUNT(Database, Database field, Search criteria)
Key points about function structure:
• Functions are part of formulas: A function cannot stand alone. It must always be
included in a formula, which begins with an = sign. Even if the function is the entire
formula, the = is required.
• Function name: The function starts with its name, such as DCOUNT in the example
above.

Chapter 9 Using Formulas and Functions | 299


• Arguments: After the function name, the required inputs (arguments) are placed inside
parentheses, separated by commas.
About Arguments:
• Functions can accept up to 255 arguments.
• Arguments can be:
– Numbers
– Single cells
– Named ranges, ranges or arrays (containing multiple or even hundreds of cells).
The type and format of arguments depend on the specific function. Refer to Table 15 for details
on how arguments are entered based on the function's requirements.
Table 15: Entering function arguments

Argument Description
"text data" The quotes indicate text or string data is being entered.
9 The number nine is being entered as a number.
"9" The number nine is being entered as text.
A1 The address for whatever is in cell A1 is being entered.
B2:D9 The range of cells is being entered.
EMEA_Sales A named range, previously defined.

Nested functions
Functions can also be used as arguments within other functions. These are called nested
functions.
=SUM(2,PRODUCT(5,7))
To get an idea of what nested functions can do, imagine that you are designing a self-directed
learning module. During the module, students do three quizzes, and enter the results in cells A1,
A2, and A3. In A4, you can create a nested formula that begins by averaging the results of the
quizzes with the formula =AVERAGE(A1:A3). The formula then uses the IF function to give the
student feedback that depends upon the average grade on the quizzes. The entire formula
would read:
=IF(AVERAGE(A1:A3)>85, “Congratulations! You are ready to advance to the next
module”, “Failed. Please review the material again. If necessary, contact your
instructor for help”)
Depending on the average, the student would receive the message for either congratulations or
failure.
Notice that the nested formula for the average does not require its own equal sign. The one at
the start of the equation is enough for both formulas.
If you are new to spreadsheets, the best way to think of functions is as a scripting language. We
have used simple examples to explain the concept more clearly, but, through nesting of
functions, a Calc formula can quickly become complex.

Note
Calc keeps the syntax of a formula displayed in a tool tip next to the cell as a handy
memory aid as you type.

300 |Calc Guide 24.8


Using the Functions deck
A more reliable method is to use the Functions deck on the Sidebar (Figure 278), accessed by
selecting View > Function List or, if the Sidebar is already displayed, clicking the Functions
icon on the tab panel at the right of the Sidebar.
Calc provides many functions and the Functions deck provides a search facility. When you type
in the search box located at the top of the deck, the list of functions narrows on each character
inserted.

Figure 278: Functions deck in Sidebar


The Functions deck includes a brief description of each function and its arguments. Highlight the
function and look at the bottom of the pane to see the description. If necessary, hover the mouse
pointer over the division between the list and the description; when the pointer becomes a two-
headed arrow, drag it upwards to increase the space for the description. Double-click on a
function’s name to add it to the current cell, together with placeholders for each of the function’s
arguments.
Using the Functions deck is almost as fast as manual entry, and has the advantage of not
requiring that you memorize a formula that you want to use. In theory, it should also be less
error-prone. In practice, though, some users may fumble when replacing the placeholders with
values. Another feature is the ability to display the last formulas used.

Using the Function Wizard


The most commonly used input method is the Function Wizard (Figure 279). To open it, choose
Insert > Function, or click the Function Wizard icon on the Formula Bar, or press Ctrl+F2.
The Function Wizard provides the same help features as the Functions deck, but adds fields in
which you can see the result of a completed function, as well as the result of any larger formula
of which it is part.

Chapter 9 Using Formulas and Functions | 301


Figure 279: Functions tab of Function Wizard
Select a category of functions to shorten the list, then scroll down through the named functions
and select the required one by double-clicking on it. The available categories within the Function
Wizard, and the number of functions available in each category, are given in Table 16. When you
select a function, its description appears on the right-hand side of the dialog. Optionally, you can
type the function name in the Search box and the search narrows on each character inserted
(Figure 279).
Table 16: Function categories in the Function Wizard

Category Number of functions in category


Add-in 48
Array 15
Database 12
Date&Time 36
Financial 63
Information 21
Logical 11
Mathematical 82
Spreadsheet 22
Statistical 151
Text 47

The Function Wizard now displays an area to the right where you can enter data manually in text
boxes or click the Shrink button to shrink the Function Wizard so you can select cells from the
sheet.

302 |Calc Guide 24.8


Figure 280: Function Wizard after shrinking
To select cells, either click directly on the cell or hold down the left mouse button and drag to
select the required area.
When the area has been selected, click the Expand button to return to the wizard again.
If multiple arguments are needed click in the next text box and repeat the selection process for
the next cell or range of cells. Repeat this process as often as required. The wizard will accept
up to 255 ranges or arguments in the SUM function.
Click OK to accept the function, add it to the cell, and get the result.

Note
If you select a function by double-clicking it in the list, and then change your mind
and select a different one by double-clicking again, then the second choice formula is
added into the first choice formula in the Formula text box. You must clear the
Formula text box and then double-click the function to add it to the box.
This additive facility allows you to create complex formulas by building them up in the
Formula box.
You can also select the Structure tab to see a tree view of the parts of the formula. The main
advantage over the Functions deck is that each argument is entered in its own field, making it
easier to manage. The price of this reliability is slower input, but precision is generally more
important than speed when creating a spreadsheet.
The structure view of the Function Wizard is important for debugging and fixing very long,
nested, and complex formulas. In this view, the formula is parsed, and each formula component
is calculated by a simpler function call or arithmetic operation and then combined following the
rules of calculation. It is possible to visualize each parsed element of the formula and check if
the intermediate results are correct, until the mistake is found.
Functions can be entered into the Input line. After you enter a function on the Input line, press
the Enter key or click the Accept button on the Formula Bar to add the function to the cell and
get its result.

1 Name Box showing list of common functions


2 Function Wizard 4 Accept
3 Cancel 5 Input line

Figure 281: The Formula Bar


If you see the formula in the cell instead of the result, then Formulas is selected in the Display
section of the Tools > Options > LibreOffice Calc > View dialog. Deselect Formulas, and the
result will display. However, you can still see the formula in the Input line.

Chapter 9 Using Formulas and Functions | 303


Tip
The menu option View > Show Formula and the Windows / Linux shortcut Ctrl+`
(grave accent) also toggle formulas on / off.

Array formulas
What is an array formula?
A formula in which the individual values in a cell range are evaluated is referred to as an array
formula. The difference between an array formula and other formulas is that the array formula
deals with several values simultaneously instead of just one.
Not only can an array formula process several values, but it can also return several values. The
results of an array formula is also an array.
When Calc updates the formulas, each affected cell is read and its formula is recalculated. If you
have a thousand cells in a column with the same formula (the formula expression only changes
the data to compute), you end with one thousand identical formulas to interpret and execute.
Array formulas will evaluate the formula once and execute calculations as many time as the size
of the array, thus saving the time used to interpret each cell formula. And because Calc stores
only one formula for the entire array of data cells, it also save space in the spreadsheet file.

Figure 282: Source array (yellow), resulting array (green), with array formula in Formula Bar
To multiply the values in the individual cells by 10 in the above array (Figure 282), you do not
need to apply a formula to each individual cell or value. Instead you just need to use a single
array formula. Select a range of 3 x 5 cells on another part of the spreadsheet, enter the formula
=10*A1:C5 and confirm this entry using the key combination Ctrl+Shift+Enter. The result is
a 3 x 5 array in which the individual values in the cell range (A1:C5) are multiplied by a factor of
10.
In addition to multiplication, you can also use other operators on the reference range (an array).
With Calc, you can add (+), subtract (-), multiply (*), divide (/), use exponents (^), concatenation
(&) and comparisons (=, <>, <, >, <=, >=). The operators can be used on each individual value in
the cell range and return the result as an array if the array formula was entered.
Comparison operators in an array formula treat empty cells in the same way as in a normal
formula, that is, either as zero or as an empty string. For example, if cells A1 and A2 are empty
the array formulas {=A1:A2=""} and {=A1:A2=0} will both return a 1 column 2 row array of
cells containing TRUE.

When do you use array formulas?


Use array formulas if you have to repeat calculations using different values. If you decide to
change the calculation method later, you only have to update the array formula. To add an array
formula, select the entire array range and then make the required change to the array formula.

304 |Calc Guide 24.8


Arrays are an essential tool for carrying out complex calculations, because you can have several
cell ranges included in your calculations. Calc has different math functions for arrays, such as
the MMULT function for multiplying two arrays.

Creating array formulas


If you create an array formula using the Function Wizard, you must mark the Array check box
each time so that the results are returned in an array (Figure 279). Otherwise, only the value in
the upper-left cell of the array being calculated is returned.
An array formula can also be entered directly into a cell. The result will automatically create an
array of cells.

Note
Array formulas appear in braces (curly brackets) in Calc. You cannot create array
formulas by manually entering the braces.

Note
The cells in a results array are automatically protected against changes. However,
you can edit or copy the array formula by selecting the entire array cell range.

Implicit intersection of array formulas


You can also create a "normal" formula in which the reference range, such as parameters,
indicate an array formula. This formula is also known as "implicit intersection" of array formula.
The result is obtained from the intersection of the reference range and the rows or columns in
which the formula is found. If there is no intersection or if the range at the intersection covers
several rows or columns, a #VALUE! error message appears. The following example illustrates
this concept.

Figure 283: Implicit intersection of array formulas


The following steps utilize the values in cells A1:C3 of Figure 283.
1) Insert the array formula {=A1:A3 + 100} in cell D1. Verify that cells D1, D2, and D3
contain the values 107, 195, and 105 respectively.
2) Insert the non-array formula =A1:A3 + 100 in cell D2. Verify that cells D1 and D3 remain
empty, while cell D2 contains the value 195. This demonstrates the implicit intersection of
array formulas. Although the formula entered returns three values internally, only the
second of those is displayed.
3) Insert the non-array formula =A1:A3 + 100 in cell D4. Note that cell D4 displays a
#VALUE! error and this is because row 4 is out of the range A1:A3 of the formula.

Chapter 9 Using Formulas and Functions | 305


Strategies for creating formulas and functions
Formulas that do more than a simple calculation or summation of rows or columns of values
usually take a number of arguments. For example, consider the following equation:
1
x=x i +v i t + at 2
2

This equation models the position of an object undergoing linear, translational motion, with
constant acceleration. The position (x) depends on time (t), and the equation also contains
constant values for initial position (xi), initial velocity (vi), and acceleration (a).
For ease of presentation, it is good practice to set up a spreadsheet in a manner similar to that
shown in Figure 284. In this example, the individual variables are input into cells on the sheet
and no editing of the formula is required.
You can take several broad approaches when creating a formula. In deciding which approach to
take, consider how many other people will need to use the sheets, the life of the sheets, and the
variations that could be encountered in use of the formula.
If people other than yourself will use the spreadsheet, make sure that it is easy to see what input
is required and where. Explanation of the purpose of the spreadsheet, basis of calculation, input
required and output generated are often placed on the first sheet.

Figure 284: Setting up a formula with arguments


A spreadsheet that you build today, with many complicated formulas, may not be quite so
obvious in its function and operation in 6 or 12 months. Use comments and notes liberally to
document your work. It is also a good idea to trap errors, as other users of the spreadsheet may
be unaware of input limitations for a particular argument, for example. By using some form of
logic statements or conditional formatting to trap errors, other users won’t be subjected to vague
standard error messages.

Place a unique formula in each cell


The most basic strategy is to view whatever formulas are needed as simple and with a limited
useful life. The strategy is then to place a unique formula in each appropriate cell. This is
recommended only for very simple or “throw away” (single use) spreadsheets.

Break formulas into parts and combine the parts


The second strategy is similar to the first, except that you break down longer formulas into
smaller parts and then combine the parts into the whole. Many examples of this type exist in
complex scientific and engineering calculations where interim results are used in a number of
places in the sheet. For example, the calculated flow velocity of water in a pipe may be used to

306 |Calc Guide 24.8


estimate losses due to friction, volume of water in the pipe, and optimal pipe diameter for the
given flow regime.
In all cases you should adopt the basic principles of formula creation described previously.

Optimizing calculations
Spreadsheets are often used to process raw data, generate meaningful summaries, consolidate
information, and present it in a format that aids decision-making or serves as the basis for
reports. Raw data may come from various sources, such as physical measurements or business
transactions.
Large spreadsheets with thousands or even hundreds of thousands of rows and multiple
columns are common in fields like finance and research. Performing computations on such
datasets can be time-consuming, taking minutes, hours, or even days.
One common mistake is inserting formulas into every cell, resulting in thousands of formula
interpretations and calculations. This significantly slows down processing. To improve
performance, consider the recommendations below for speeding up calculations.

Use array formulas on massive data


Array formulas have one formula applied to the mass of data. Computation saving can be
significant for large data sets.

Use consolidation functions


Consolidation functions perform calculations on data sets. SUM, SUMIF, SUMIFS,
SUMPRODUCT are examples of consolidation functions. For example if you have a very long
bill of materials (BOM), where quantity must be multiplied by unit price and then totaled to
produce a cost figure, then instead of applying a formula on each entry of the BOM and then
summing, you can use the formula SUMPRODUCT(quantity, unitprice), where quantity and
unitprice are named ranges representing the BOM. SUMPRODUCT multiplies each cell of the
quantity data set by its corresponding cell of unitprice and sums all the products.
Similar situations happen when you must sum a subset of the original data set, where you must
apply a test on each entry to allow it to be part of the sum. For example, when the value is
strictly positive. Use SUMIF(data_to_test;”>0”;data_to_sum), where data_to_test is the
data set where you test the positive values, data_to_sum is the column where the values are to
sum depending on the test, and “>0” is the test itself.
Other consolidation functions are AVERAGEIF, COUNTIF, MINIFS, MAXIFS, and more.

Using Custom Functions and Macros


Creating custom functions and macros can be a powerful strategy for streamlining spreadsheet
use and simplifying formulas. This approach is especially useful when it makes the spreadsheet
easier for end users and reduces the likelihood of errors. Additionally, maintaining such a setup
becomes more efficient, as updates or corrections can be managed in one central location.
However, overreliance on macros and custom functions has its drawbacks. The underlying logic
and principles of the spreadsheet can become harder to understand, especially for someone
other than the original creator—or even for the creator after some time.
Macros are a specialized topic, and their use is covered in detail in Chapter 14.

Multi-threading
Multi-threading is enabled by default to take advantage of the parallel processing power of
modern computers. While disabling multi-threading is not recommended, the setting can be
found in the CPU Threading Settings section of the Tools > Options > LibreOffice Calc >

Chapter 9 Using Formulas and Functions | 307


Calculate dialog. When enabled, Calc automatically identifies where your spreadsheet could
benefit from multi-threading and processes it accordingly. Threads are generally used for formula
groups, where enough adjacent cells in a column use the same formula but get different results
because of relative cell addressing. One implication of this approach is that the optimization is
column-based and so a row-based layout could be less efficient. Other methods of controlling
Calc’s multi-threading capability, such as adjusting the MAX_CONCURRENCY environment
variable, are beyond the scope of this document.

Investigating and Resolving Formula Errors


Errors in formulas are a common occurrence in spreadsheets, even with the many tools Calc
provides to assist with formula entry. Mistakes can happen when inputting numbers or using
incorrect types of arguments for a function. In addition to correcting these errors, you may need
to identify the cells used in a formula to adjust their values or verify the results.
Calc offers three key tools to help investigate formulas and the cells they reference:
1) Error messages: These provide information about issues in formulas.
2) Color coding: Highlights referenced cells for easier identification.
3) The Detective tool: Helps trace relationships between cells and identify errors.

Error messages
The most basic tool is error messages. Error messages display in a formula’s cell, on the Status
Bar, or in the Function Wizard instead of the result.
An error message for a formula is usually a three-digit number from 501 to 540, or sometimes
vague text such as #NAME?, #REF!, or #VALUE!. The error message appears in the cell, and a
brief explanation of the error is shown on the right side of the Status bar.
Most error messages indicate a problem with how the formula was input, although several
indicate that you have run up against a limitation of either Calc or its current settings.
While error messages are not intuitive, they do provide clues that can help the user to correct
mistakes. You can find detailed explanations of them in Appendix B, Error Codes, and in the
Help, by searching for “error codes” in Calc. A few of the most common are shown in Table 17.
Table 17: Common error messages
Code Meaning
#NAME? Instead of displaying Err:525. No valid reference exists for the argument.
Instead of displaying Err:524. The column, row, or sheet for the referenced cell
#REF!
is missing.
Instead of displaying Err:519. The value for one of the arguments is not the type
that the argument requires. The value may be entered incorrectly; for example,
#VALUE!
double-quotation marks may be missing around the value. At other times, a cell
or range used may have the wrong format, such as text instead of numbers.
#DIV/0! Instead of displaying Err:532. Division by zero.
Instead of displaying Err:503. A calculation results in an overflow of the defined
#NUM!
value range.
509 An operator such as an equals sign is missing from the formula.
510 A variable is missing from the formula.

308 |Calc Guide 24.8


Examples of common errors
#DIV/0! division by zero
This error occurs when dividing a number by either zero (0) or a blank cell. To avoid this issue,
you can use a conditional function to handle cases where a zero or blank cell appears. For
example, Figure 285 illustrates a division of values in column B by values in column C, resulting
in two errors caused by a zero and a blank cell in column C.
Errors like these are common when data is missing or incorrectly reported. To address this, an
**IF function** can ensure proper handling of such cases. For instance, you can use the formula:
=IF(C3>0, B3/C3, "No Report")
This formula means: "If the value in C3 is greater than 0, divide B3 by C3; otherwise, display 'No
Report'". After entering the formula in the first row of column D, copy it down the remainder of
the column. An example is shown in Figure 286.
Alternatively, the formula can be adjusted to return a blank cell (using double quotes `""`) or to
substitute a specific standardized number for the missing or invalid value.

Figure 285: Examples of #DIV/0!, division by zero error

Figure 286: Division by zero solution

#VALUE! no result and #REF! incorrect references


The #VALUE! error is also very common.
A common occurrence of this error arises when a cell contains an incorrect value type. In the
example of Figure 287, text “None” has been entered in C8, where our formula in column D is
expecting a number.

Chapter 9 Using Formulas and Functions | 309


Figure 287: Incorrect entry causing #VALUE! error
The #REF! error is caused by a missing reference. In the example shown in Figure 288, the
formula references a sheet that has been deleted.

Figure 288: Deleted sheet causing #REF! error

Color coding for input


Another useful tool when reviewing a formula is the color coding for input. When you select a
formula that has already been entered, the cells or ranges used for each argument in the
formula are outlined in color.

Figure 289: Color coding for input


Calc uses eight colors for outlining referenced cells, starting with blue for the first cell, and
continuing with red, magenta, green, dark blue, brown, purple, and yellow before cycling through
the sequence again.

Value highlighting
There are situations where the display of cell contents is the same when the data type is
different. For example, text contents and numeric contents can look the same but can produce a
mistake if both are used in some calculations. To illustrate, the string “10.35” right-aligned in a
cell can be confused with the value 10.35. When the cell is used in a formula the string may take
the value of zero and an error may be produced.
If you enable value highlighting (View > Value Highlighting or Ctrl+F8), Calc distinguishes the
text and numeric data types by assigning different colors to the content’s characters. By default,
the text contents are in black characters and the numeric contents are in blue. See Chapter 2,
Entering and Editing Data, for more information on value highlighting.

The Detective
In a long or complicated spreadsheet, color coding becomes less useful. In these cases,
consider using the submenu under Tools > Detective. The Detective is a tool for checking which

310 |Calc Guide 24.8


cells are used as arguments by a formula (precedents) and which other formulas it is nested in
(dependents), and tracking errors. It can also be used for tracing errors, marking invalid data
(that is, information in cells that is not in the proper format for a function’s argument), or even for
removing precedents and dependents.
To use the Detective, select a cell with a formula, then select the required option in the Tools >
Detective menu. On the spreadsheet, you will see lines ending in dots to indicate precedents,
and lines ending in arrows for dependents. The lines show the flow of information.
Use the Detective to assist in following the precedents referred to in a formula in a cell. By
tracing these precedents, you frequently can find the source of the errors. Place the cursor in the
cell in question and then choose Tools > Detective > Trace Precedents on the Menu bar or
press Shift+F9. Figure 290 shows a simple example of tracing precedents for cell B4.
This allows us to check the source cells (which may be a range) for any errors which have
caused us to query the calculation result. If a source is a range, then that range is highlighted in
blue.

Figure 290: Tracing precedents using the Detective


In other instances we may have to trace an error. For this we use the Trace Error function, found
under Tools > Detective > Trace Error, to find the cells that caused the error.
For more information search for “Detective” in the Help system’s index.

Examples of functions
For beginners, functions can be one of the most intimidating aspects of LibreOffice Calc. While
new users quickly recognize that functions are a key feature of spreadsheets, the sheer number
of available functions—many requiring specialized knowledge or specific inputs—can feel
overwhelming. Thankfully, Calc offers a wide range of functions that are simple and accessible,
even for novice users.

Basic arithmetic and statistics


The most basic functions create formulas for basic arithmetic or for evaluating numbers in a
range of cells.

Basic arithmetic
The simple arithmetic functions are addition, subtraction, multiplication, and division. Except for
subtraction, each of these operations has its own function:
• SUM for addition
• PRODUCT for multiplication
• QUOTIENT for division
SUM, PRODUCT, and QUOTIENT are useful for entering ranges of cells in the same way as any
other function, with arguments in brackets after the function name.
However, for basic equations, many users prefer the time-honored computer symbols for these
operations, using the plus sign (+) for addition, the hyphen (–) for subtraction, the asterisk (*) for

Chapter 9 Using Formulas and Functions | 311


multiplication and the forward slash (/) for division. These symbols are quick to enter without
requiring your hands to stray from the keyboard.
A similar choice is also available if you want to raise a number by the power of another. Instead
of entering =POWER(A1,2), you can enter =A1^2.
Moreover, they have the advantage that you enter formulas with them in an order that more
closely approximates human readable format than the spreadsheet-readable format used by the
equivalent function. For instance, instead of entering =SUM(A1:A2), or possibly =SUM(A1,A2),
you enter =A1+A2. This almost-human readable format is especially useful for compound
operations, where writing =A1*(A2+A3) is briefer and easier to read than
=PRODUCT(A1,SUM(A2:A3)).
The main disadvantage of using arithmetical operators is that you cannot directly use a range of
cells. In other words, to enter the equivalent of =SUM(A1:A3), you would need to type
=A1+A2+A3.
Otherwise, whether you use a function or an operator is largely up to you—except, of course,
when you are subtracting. However, if you use spreadsheets regularly in a group setting such as
a class or an office, you might want to standardize on an entry format so that everyone who
handles a spreadsheet becomes accustomed to a standard input.

Simple statistics
Another common use for spreadsheet functions is to pull useful information out of a list, such as
a series of test scores in a class, or a summary of earnings per quarter for a company.
You can, of course, scan a list of figures if you want basic information such as the highest or
lowest entry or the average. The only trouble is, the longer the list, the more time you waste and
the more likely you are to miss what you are looking for. Instead, it is usually quicker and more
efficient to enter a function. Such reasons explain the existence of a function like COUNT, which
does no more than give the total number of entries in the designated cell range.
Similarly, to find the highest or lowest entry, you can use MIN or MAX. For each of these
formulas, all arguments are either a range of cells, or a series of cells entered individually.
Each also has a related function, MINA or MAXA, which performs the same function, but also
treats a cell formatted for text as having a value of 0. (The same treatment of text occurs in any
variation of another function that adds an "A" to the end.) Either function gives the same result,
and could be useful if you used a text notation to indicate, for example, if any students were
absent when a test was written, and you wanted to check whether to schedule a makeup exam.
For more flexibility in similar operations, you could use LARGE or SMALL, both of which add a
specialized argument of rank. If the rank is 1 used with LARGE, you get the same result as you
would with MAX. However, if the rank is 2, then the result is the second largest result. Similarly, a
rank of 2 used with SMALL gives you the second smallest number. Both LARGE and SMALL are
handy as a permanent control, since, by changing the rank argument, you can quickly scan
multiple results.
You would need to be an expert to want to find the Poisson distribution of a sample, or to find the
skew or negative binomial of a distribution (and, if you are, you will find functions in Calc for such
things). However, for the rest of us, there are simpler statistical functions that you can quickly
learn to use.
In particular, if you need an average, you have a number of functions to choose from. You can
find the arithmetical mean—that is, the result when you add all entries in a list then divide by the
number of entries, by entering a range of numbers when using AVERAGE, or AVERAGEA to
include text entries and to give them a value of zero.

312 |Calc Guide 24.8


In addition, you can get other information about the data set:
• MEDIAN: Logically ranks the numbers (lowest to highest) to evaluate the median value.
In a set containing an uneven number of values, the median will be the number in the
middle of the ranked list. In a set containing an even number of values, the median will
be the mean of the two values in the middle of the ranked list.
• MODE: The most common entry in a list of numbers.
• QUARTILE: The entry at a set position in the array of numbers. Besides the cell range,
you enter the type of quartile: 0 for the lowest entry, 1 for the value of 25%, 2 for the
value of 50%, 3 for 75%, and 4 for the highest entry. Note that the result for types 1
through 3 may not represent an actual item entered.
• RANK: The position of a given entry in the entire list, measured either from top to bottom
or bottom to top. You need to enter the cell address for the entry, the range of entries,
and the type of rank (0 for the rank from the highest, or any other value for the rank from
the bottom).
Some of these functions overlap; for example, MIN and MAX are both covered by QUARTILE. In
other cases, a custom sort or filter might give much the same result. Some users prefer to use
MIN and MAX because they are easy to remember, while others prefer QUARTILE because it is
more versatile.

Using these functions


In some cases, you can achieve similar results to certain functions by using filters or custom
sorting. However, functions are generally more flexible and easier to adjust, offering a broader
range of possibilities.
Sometimes, you might want to temporarily enter one or more formulas in a blank cell for quick
calculations and delete them afterward. However, if you frequently use the same functions,
consider creating a template with designated spaces for those functions. Add labels to the cells
to the left of each formula for clarity. Once your template is set up, you can easily update
formulas as data changes—either automatically or by pressing F9 to refresh all selected cells.
No matter how you use functions, you’ll likely find them simple and adaptable for many tasks.
Once you’re comfortable with these basic functions, you’ll be ready to explore more advanced
options.

Rounding off numbers


For statistical and mathematical purposes, Calc includes a variety of ways to round off numbers.
If you are a programmer, you may also be familiar with some of these methods. However, you do
not need to be a specialist to find some of these methods useful. You may want to round off for
billing purposes, or because decimal places do not translate well into the physical world. For
instance, if the parts you need come in packages of 100, then the fact you only need 66 is
irrelevant to you; you need to round up for ordering. By learning the options for rounding up or
down, you can make your spreadsheets more immediately useful.
When you use a rounding function, you have two choices about how to set up your formulas. If
you choose, you can nest a calculation within one of the rounding functions. For instance, the
formula =ROUND((SUM(A1,A2)) adds the figures in cells A1 and A2, then rounds them off to the
nearest whole number. However, even though you do not need to work with exact figures every
day, you may still want to refer to them occasionally. If that is the case, then you are probably
better off separating the two functions, placing =SUM(A1,A2) in cell A3, and =ROUND(A3) in A4,
and clearly labeling each function.
For details on rounding methods, see the Help.

Chapter 9 Using Formulas and Functions | 313


Volatile / non-volatile functions
The Open Document Format for Office Applications (OpenDocument) Version 1.2 includes the
following definition: “Functions that are always recalculated whenever a recalculation occurs are
termed volatile functions.”
To understand some of the behaviors of a volatile function within Calc, consider a simple
example in which you have created an empty spreadsheet and entered the formula =RAND()
into cell A1 (RAND is one of Calc’s volatile functions). Calc displays a random number between
0 and 1 in cell A1. If you then enter any value into a different cell (say cell B2 for the purpose of
this discussion) and press Enter, you will notice that the value displayed in A1 is updated to
show a different random number. Calc recalculates the random number in A1, despite the user
not changing the formula in A1 and despite the updated B2 having no link to A1. In summary, the
RAND function will generate a new value when any cell is updated by selecting Data >
Calculate > Recalculate or pressing F9, or on any input event.
An understanding of volatile functions is important especially if you create a large spreadsheet,
where frequent recalculations may adversely affect performance. Make sure that you design
your spreadsheet to use volatile functions appropriately.
The following Calc functions are volatile:
• FORMULA
• INDIRECT
• INFO
• NOW
• OFFSET
• RAND
• RANDBETWEEN
• TODAY
For the RAND and RANDBETWEEN functions, Calc provides non-volatile equivalents –
RAND.NV and RANDBETWEEN.NV. These may be useful when you do not require the function
values to update so frequently. A non-volatile function is not recalculated at new input events and
does not recalculate when selecting Data > Calculate > Recalculate or pressing F9, except
when the cell containing the function is selected. Non-volatile functions are recalculated when
opening the file.

Using wildcards and regular expressions in functions


Calc supports the use of regular expressions or wildcards in the arguments of many of its
functions.
Regular expressions offer the most powerful method of searching for text strings. For more
information about regular expressions, including examples, see the “Searching and filtering with
regular expressions” section in Chapter 2, Entering and Editing data.
If maintaining compatibility with Microsoft Excel is important for your spreadsheet, you may need
to limit your use of Calc’s regular expression features, as Excel does not support equivalent
functionality. When you export a Calc spreadsheet to Excel format, any data relying on regular
expressions will not work in Excel.
To ensure compatibility, you can use Calc’s less powerful wildcard feature instead. Wildcards are
special characters that represent one or more unspecified characters, making text searches

314 |Calc Guide 24.8


more flexible but often less precise. Spreadsheets using wildcards can be exported to Excel
format without losing functionality.
The available wildcards are:
• ? (question mark) to represent a single character.
• * (asterisk) to represent any number of characters.
• ~ (tilde) to escape wildcard characters if they are part of the actual text.
The usage of these wildcards is the same as described in the Find and Replace dialog covered
in Chapter 2, Entering, Editing, and Formatting Data.
The following Calc functions allow the use of wildcards or regular expressions:
• Database functions (DAVERAGE, DCOUNT, DCOUNTA, DGET, DMAX, DMIN,
DPRODUCT, DSTDEV, DSTDEVP, DSUM, DVAR, DVARP)
• AVERAGEIF, AVERAGEIFS, COUNTIF, COUNTIFS, MAXIFS, MINIFS, SUMIF, SUMIFS
• HLOOKUP, LOOKUP, VLOOKUP
• MATCH
• REGEX (not applicable for wildcards)
• SEARCH
Configuration options are available in the Formulas wildcards section on the Tools > Options >
LibreOffice Calc > Calculate dialog (Figure 291) to control the use of wildcards and regular
expressions with Calc’s functions. The three mutually exclusive, self-explanatory options are:
• Enable wildcards in formulas. This is the initial default when Calc is installed.
• Enable regular expressions in formulas.
• No wildcards or regular expressions in formulas.
A further related option in the General Calculations area of the same dialog, Search criteria =
and <> must apply to whole cells, controls whether search criteria must match the whole cell
exactly.

Tip
When both the Search criteria = and <> must apply to whole cells and Enable
wildcards in formulas options are selected, Calc behaves exactly as Microsoft
Excel when searching cells in the database functions.
By default, regular expression searches within Calc functions are case insensitive,
irrespective of the setting of the Case sensitive checkbox. However, for some
functions regular expressions can include a flag option “(?-i)” to switch to a case
sensitive match. Functions that support this facility are: AVERAGEIF, AVERAGEIFS,
COUNTIF, COUNTIFS, HLOOKUP, LOOKUP, MATCH, SEARCH, SUMIF, SUMIFS,
and VLOOKUP.

Chapter 9 Using Formulas and Functions | 315


Figure 291: Tools > Options > LibreOffice Calc > Calculate dialog
To illustrate some of the features of regular expressions, consider the simple spreadsheet shown
in Figure 292 and assume that Enable regular expressions in formulas is selected.

Figure 292: Using the COUNTIF function


1) With the formula =COUNTIF(A1:A6,”r.d”) entered in cell A7 and Search criteria = and
<> must apply to whole cells deselected, the value 5 is displayed in cell A7, as shown
in Figure 292. The formula counts cells in the range A1:A6 which contain “Fred”, “red”,
“ROD”, “bride”, and “Ridge”.
2) With the formula =COUNTIF(A1:A6,”(?-i)r.d”) entered in cell A7 and Search criteria
= and <> must apply to whole cells deselected, the value 3 is displayed in cell A7. The
formula counts cells in the range A1:A6 which contain “Fred”, “red”, and “bride”. This
regular expression utilizes the “(?-i)” flag option to perform a case sensitive search.
3) With the formula =COUNTIF(A1:A6,”r.d”) entered in cell A7 and Search criteria = and
<> must apply to whole cells selected, the value 2 is shown in cell A7. The formula
counts cells in the range A1:A6 which contain “red” and “ROD”.
4) With the formula =COUNTIF(A1:A6,”(?-i)r.d”) entered in cell A7 and Search criteria
= and <> must apply to whole cells selected, the value 1 is shown in cell A7. The
formula counts cells in the range A1:A6 which contain “red”. This regular expression
utilizes the “(?-i)” flag option to perform a case sensitive search.

316 |Calc Guide 24.8


5) With the formula =COUNTIF(A1:A6,".*r.d.*") entered in cell A7 and Search criteria
= and <> must apply to whole cells selected, the value 5 is again shown in cell A7.
Contrast this with example 3) above – the regular expression in the current example
allows for 0 or more characters both before the “r” and after the “d”.
Regular expressions cannot be used directly in simple comparisons. For instance, the formula
A1="r.d" will always return FALSE if cell A1 contains "red," even if regular expressions are
enabled. It will only return TRUE if A1 contains "r.d" (with "r," a dot, and "d").
To test for regular expressions, use the COUNTIF function instead. For example:
COUNTIF(A1, "r.d")
This will return 1 if a match is found and 0 if not, which can be interpreted as TRUE or FALSE in
formulas. For instance:
=IF(COUNTIF(A1, "r.d"), "hooray", "boo")`
When the Enable regular expressions in formulas option is activated, all functions will require
regular expression special characters (such as parentheses) within strings to be preceded by a
backslash (`\`), even if they are not part of a regular expression. If this setting is later
deactivated, the backslashes will need to be removed to avoid errors.

Advanced functions
As is common with other spreadsheet programs, Calc can be enhanced by user-defined
functions or add-ins. Setting up user-defined functions can be done either by using macros or by
writing separate add-ins or extensions.
The basics of writing and running macros is covered in Chapter 13, Macros. Macros can be
linked to menus or toolbars for ease of operation or stored in template modules to make the
functions available in other documents. Calc macros can be written in Basic, BeanShell,
JavaScript, or Python.

Chapter 9 Using Formulas and Functions | 317


Calc Guide 24.8

Chapter 10
Using Pivot Tables
Introduction
Many spreadsheet support requests stem from using overly complex formulas to address
simple, everyday tasks. For a more efficient and effective approach, consider using pivot tables.
These tools simplify the process of combining, comparing, analyzing, and summarizing large
datasets.
With pivot tables, you can:
• Generate different summaries of your source data.
• Drill down into specific details of interest.
• Create detailed reports, regardless of your skill level—beginner, intermediate, or
advanced.
Additionally, pivot charts can be created from pivot tables to provide a clear graphical
representation of the data.

Database preconditions
To use a pivot table, you need a list of raw data structured like a database table, with rows
representing data sets and columns representing data fields. The field names should be in the
first row above the data.
The data source can come from an external file or database. If the data is already within a Calc
spreadsheet, simpler sorting functions may suffice without the need for a pivot table.

Calc’s automatic recognition of data


To process data in lists, Calc needs to identify where the list is located within the spreadsheet.
Lists can appear anywhere on the sheet and multiple unrelated lists can coexist.
Calc automatically detects your lists using the following logic:
1) Starting from the currently selected cell (which must be within the list), Calc scans in all
four directions—left, right, up, and down.
2) It identifies the list boundaries when it encounters an empty row or column or reaches
the spreadsheet's edges (Figure 293).
For these functions to work correctly:
• Ensure there are no empty rows or columns within the list.
• Avoid using empty rows for formatting purposes. Instead, apply formatting directly to the
cells within the list.

Tip
To make sure that Calc automatically recognizes a list correctly, check that there are
no empty rows or empty columns within the list.

320 |Calc Guide 24.8


Figure 293: Automatic list selection with cursor in cell B7
If you select more than one cell before creating a pivot table, then Calc’s automatic list
recognition logic is not applied. Instead, Calc assumes that the pivot table is to be created using
exactly the cells that you selected.

Tip
Always select only one cell before initiating creation of a pivot table. This allows Calc
to automatically determine the full scope of your data list.
A common source of errors occurs when a list is unintentionally defined and then sorted. For
example, selecting multiple cells—such as an entire column—can result in sorting that misaligns
data that should remain together within rows.
Beyond these technical considerations, maintaining the logical structure of the list is equally
crucial.

Note
Calc lists must have the normal form; that is, they must have a simple linear
structure.
When entering data, avoid adding outlines, groups, or summaries. Here are common mistakes
often made by inexperienced spreadsheet users:
• Creating unnecessary sheets: For example, using separate sheets for each group of
items. This limits analyses to individual groups and makes cross-group analysis difficult.
• Using multiple columns for similar data: For instance, in a sales list, creating separate
columns for each employee's sales instead of a single column for all amounts. This
structure complicates data grouping and prevents effective analysis with pivot tables. To
enable proper analysis, all related data should be in the same column.
• Including summary rows in chronological data: For example, adding a total row at
the end of each month. This prevents the list from being sortable by different criteria
since pivot tables treat summary rows as regular data. Instead, use the pivot table's built-
in features to quickly generate monthly summaries.

Chapter 10 Using Pivot Tables | 321


Data sources
The possible data sources for the pivot table are a Calc spreadsheet or an external data source
that is registered in LibreOffice.

Calc spreadsheet
Analyzing a list in a Calc spreadsheet is the simplest and most often used case. Lists might be
updated regularly or the data might be imported from a different application.
The list data might be entered directly into the spreadsheet or copied from another file or
application. You can also use a Web Page Query input filter to insert data from an HTML file, a
CSV file, a Calc spreadsheet, or a Microsoft Excel spreadsheet. See Chapter 12, Linking Data,
for more information.
The behavior of Calc while inserting data from a different application depends on the format of
the data. If the data is in a common spreadsheet format, it is copied directly into Calc. However,
if the data is in plain text format, the Text Import dialog appears after you select the file
containing the data. See Chapter 1, Introduction, for more information about this dialog.

Registered data source


A registered data source is a connection to data held in a database outside of LibreOffice. When
using a registered data source, the data to be analyzed will not be saved in the spreadsheet;
Calc will always use the data from the original source. Calc can use many different data sources
in addition to databases that are created and maintained with LibreOffice Base. For more
information, see Chapter 12, Linking Data.

Using shortcuts
If you frequently use pivot tables in Calc, navigating through the built-in menu paths might feel
inconvenient.
To streamline your workflow, consider the following options:
• Built-in keyboard shortcuts: Some shortcuts are predefined, such as the F12 key,
which groups a selected data range. Refer to Appendix A, Keyboard Shortcuts, for a full
list.
• Toolbar icons: The standard toolbar includes icons for tasks like inserting or editing
pivot tables, making these actions more accessible.
Additionally, you can create custom keyboard shortcuts and toolbar icons to suit your needs. For
instructions, see Chapter 16, Setting up and Customizing.

Creating a pivot table


If you want Calc to automatically determine the full extent of the raw data list, then select a
single cell within this list. If you want to explicitly define the extent of the raw data list, then select
only the relevant cells.
After making a selection, create the pivot table in one of three ways:
• Use Insert > Pivot Table on the Menu bar.
• Use Data > Pivot Table > Insert or Edit on the Menu bar.
• Click the Insert or Edit Pivot Table icon on the Standard toolbar.
Calc displays the Select Source dialog (Figure 294), where you can choose between using the
selected data cells, a range of cells that has already been named, or a data source that has
already been registered with LibreOffice.

322 |Calc Guide 24.8


Note
See Chapter 14, Calc as a Database, for more information about named ranges. See
Chapter 12, Linking Data, for more information about linking to registered data
sources.

Figure 294: Select Source dialog


Click OK on the Select Source dialog to display the Pivot Table Layout dialog, which is described
in the next section.

The Pivot Table Layout dialog


The pivot table's functionality is controlled in two main areas: the Pivot Table Layout dialog and
direct manipulations of the resulting table within the spreadsheet. This section provides a
detailed explanation of the Pivot Table Layout dialog.

Tip
To access the Pivot Table Layout dialog again after initial creation of a pivot table,
left-click in any cell of the pivot table. Then select Insert > Pivot Table on the Menu
bar, or select Data > Pivot Table > Insert or Edit on the Menu bar, or click the
Insert or Edit Pivot Table icon on the Standard toolbar, or right-click in any cell of
the pivot table and select the Properties option in the context menu.

Basic layout
The Pivot Table Layout dialog (Figure 295) organizes the resulting pivot table into four key areas:
• Filters
• Column Fields
• Row Fields
• Data Fields
Additionally, there is an Available Fields area that lists the fields from the source data. To design
the layout, simply drag fields from the Available Fields area and drop them into the desired
section.
The Data Fields area must include at least one field, though advanced users can add multiple
fields. Fields in this area use an aggregate function by default. For example, dragging the Sales
Value field into the Data Fields area will initially display it as Sum – Sales Value.

Chapter 10 Using Pivot Tables | 323


Figure 295: Pivot Table Layout dialog
Row and column fields indicate from which groups the result will be sorted. Often more than one
field is used at a time to get partial sums for rows or columns. The order of the fields gives the
order of the sums from overall to specific.
For example, if you drag Region and Employee into the Row Fields area, the sum will be
divided into the regions. Within the regions will be the listing for the different employees (Figure
296).
Fields that are placed into the Filters area appear at the top of the resulting pivot table as a drop-
down list. The summary in the result takes into account only that part of the base data that you
have selected. For example, if you include Employee in the Filters area, you can filter the result
shown for each employee.
To move a field from an area, just drag it to a new area. To remove a field from the Filters,
Column Fields, Row Fields, or Data Fields areas, drag it to the Available Fields area.

Tip
To rapidly move a selected field from one area of the Pivot Table Layout dialog to
another, press the Alt+letter on the keyboard that corresponds to the underlined
letter in the target area’s label.

324 |Calc Guide 24.8


Figure 296: Field order for analysis and resulting layout of pivot table

Note
By default, Calc inserts a Data field into the Column Fields area. The Data field can
be moved between the Column Fields and Row Fields areas as required. Depending
on its position within the list of fields in its area, the Data field may lead to a button
labeled Data appearing in the results of the pivot table, affecting the layout of the
results. If you do not wish to use this facility, simply place the Data field at the bottom
of the list of fields in its area.

More options
Expanding the options section of the Pivot Table Layout dialog reveals the following options for
working with pivot table layouts:
• Ignore empty rows
• Identify categories
• Total columns
• Total rows
• Add filter
• Enable drill to details
• Show expand/collapse buttons
Each of these options is shown in Figure 297 and described in the sections that follow.
Ignore empty rows
If the source data is not in the recommended form, this option tells the pivot table to
ignore empty rows.
Identify categories
With this option selected, if the source data has missing entries in a list and does not
meet the recommended data structure (as in Figure 298 for example), the pivot table
adds it to the listed category above it. If this option is not chosen, then the pivot table
inserts (empty).

Chapter 10 Using Pivot Tables | 325


Figure 297: Expanded area of the Pivot Table Layout dialog

Figure 298: Example of data with missing entries in Column A


The option Identify categories ensures that in this example rows 3 and 4 are included
for Apples and that row 6 is included for Pears (Figure 299).

Figure 299: Pivot table result with Identify categories selected


Without category recognition, the pivot table shows an (empty) category (Figure 300).

Figure 300: Pivot table result without Identify categories selected


Logically, the behavior with category recognition is better. A list showing missing entries
is also less useful because you cannot use functions such as sorting or filtering.
Total columns, Total rows
With these options, you can decide if the pivot table shows an extra row with the sums of
each column, or if it adds on the very right a column with the sums of each row. In some

326 |Calc Guide 24.8


cases, an added total sum is meaningless, for example, if the entries are accumulated or
the result of comparisons.
Add filter
Use this option to add or hide the cell labeled Filter above the pivot table results. This
conveniently provides additional filtering options within the pivot table. For more
information, see “Filtering” below.

Note
The filtering provided through the Add filter option is independent of the filtering
provided by including fields in the Filters area of the Pivot Table Layout dialog.
Enable drill to details
With this option enabled, if you double-click on a single data cell in the pivot table result,
including a cell produced from Total columns or Total rows, a new sheet opens giving a
detailed listing of the individual entry. If you double-click on a cell in either a row or
column field area, the Show Detail dialog opens (Figure 334). If this function is disabled,
the double-click will keep its usual edit function within a spreadsheet. For more
information, see “Drilling” below.
Show Expand / Collapse buttons
Inserts toggle buttons to field labels to make pivot tables with compact layout more
usable. Such buttons are also available if other layouts are used.

Source and Destination


Expanding the Source and Destination section of the Pivot Table Layout dialog reveals fields for
changing the source and destination.
Source
The Selection field in this area shows the sheet name and the range of cells containing
the raw data for the pivot table. If the source spreadsheet contains any named ranges,
these can be selected through the Named range option.
Destination
The controls in this area define where the result will be shown.
Selecting New sheet adds a new sheet to the spreadsheet file and places the results
there. The new sheet is named using the format Pivot Table_sheetname_X; where X is
the number of the table created, 1 for first, 2 for the second, and so on. For a sheet
named Sales List, the new sheet for the first pivot table produced would be named Pivot
Table_Sales List_1. Each new sheet is inserted next to the source sheet.
If the target spreadsheet contains any named ranges, these can be selected with the
Named range option.
The Selection field in this area shows the sheet name and the range of cells for the pivot
table’s results.

Tip
To display the pivot table on the same sheet as the raw data, check the Selection
option in the Destination area, click the Shrink button to the right of the Selection
field, click at an appropriate cell in an empty area of the sheet, click the Expand
button, and click OK on the Pivot Table Layout dialog.

Chapter 10 Using Pivot Tables | 327


Field Settings
Settings can be changed for any field that is currently included in the pivot table layout. To
change the settings, simply double click the field within the Pivot Table Layout dialog.

Options for data fields


The options available for fields in the Data Fields area (Figure 301) differ from those for fields in
the other three areas. In the Data Field dialog, you can select the function to be used to
accumulate the values from the data source. The frequently used Sum function and other lesser
used functions like standard deviation and counting function are available in the dialog.
Select the Show items without data option to include empty columns and rows in the results
table.
Click the expansion symbol (plus sign or triangle) to expand the Displayed value section of the
dialog.

Figure 301: Expanded dialog for a data field


In the Displayed value section, you can choose other possibilities for analysis using the
aggregate function. Depending on the setting for Type, you may have to choose definitions for
the Base field and Base item.

Figure 302: Example choices for Base field and Base item
Table 18 lists the possible types of displayed value and associated base field and base item,
together with notes on usage.

328 |Calc Guide 24.8


Table 18: Description of Displayed value options on the Data Field dialog
Type Base field Base item Analysis
Simple use of the chosen aggregate
Normal — —
function (for example, Sum).
The result is the difference between the
result of the base field and the base
Selection of a Selection of an item (for example, sales volume of the
field from the element from other employees against the sales
data source of the selected volume of Brigitte; see Figure 303).
Difference from
the pivot table base field (for If previous item or next item is
(for example, example, specified as the Base item, the
Employee). Brigitte) reference value is the result for the next
visible member of the base field, in the
base field’s sort order.
The result is a percentage ratio of the
value of the base field to the base item
Selection of a Selection of an (for example, sales result of the other
field from the element from employees relative to the sales result of
data source of the selected Brigitte; see Figure 304).
% of
the pivot table base field (for If previous item or next item is
(for example, example, specified as the Base item, the
Employee) Brigitte) reference value is the result for the next
visible member of the base field, in the
base field’s sort order.
From each result, its reference value is
subtracted, and the difference is
divided by the reference value (for
Selection of a Selection of an example, sales of the other employees
field from the element from as a relative difference from the sales
% difference data source of the selected of Brigitte; see Figure 305).
from the pivot table base field (for
(for example, example, If previous item or next item is
Employee) Brigitte) specified as the Base item, the
reference value is the result for the next
visible member of the base field, in the
base field’s sort order.
Each result is added to the sum of the
Selection of a results for preceding items in the base
field from the field, in the base field’s sort order, and
Running total data source of the total sum is shown.

in the pivot table
(for example, Results are always summed, even if a
Date) different summary function was used to
get each result.
The result is a percentage of the value
% of row — — of the whole row (for example, the row
sum).
The result is a percentage of the total
% of column — — column value (for example, the column
sum).
The result is a percentage of the overall
% of total — —
result (for example, the total sum).
(Default result x total result) / (row total
Index — —
x column total)

Chapter 10 Using Pivot Tables | 329


Figure 303: Original pivot table (top) and a Difference from example (bottom)

Figure 304: Example of a % of analysis

Figure 305: Example of % difference from analysis

Options for row and column fields

Figure 306: Data Field dialog for a row or column field


Double-click a field in the Row or Column Fields areas of the Pivot Table Layout dialog to access
the Data Field dialog shown in Figure 306.

330 |Calc Guide 24.8


In the Data Field dialog for a row or column field, you can choose to show subtotals for each
category. Subtotals are deactivated by default. Subtotals are useful only if the values in one row
or column field can be divided into subtotals for another (sub)field.
Some examples are shown in Figures 307, 308, and 309.

Figure 307: No subdivision with only one row or column field

Figure 308: Division of the regions for employees (two row fields) without subtotals

Chapter 10 Using Pivot Tables | 331


Figure 309: Division of the regions for employees with subtotals (by region)
To calculate subtotals that can also be used for the data fields (see above), select the
Automatic option in the Subtotals section of the Data Field dialog.
You can choose the type of subtotal to use by selecting User-defined and then clicking the type
of subtotal you want to calculate from the list. Functions in this list are only available when User-
defined is selected.
Normally, as shown in Figure 310, the pivot table excludes any rows or columns for categories
that have no entries in the underlying database. However, by choosing the Show items without
data option, you can force these to be displayed as shown in Figure 311

Figure 310: Default setting

332 |Calc Guide 24.8


Figure 311: Setting Show items without data
To do so, click the Options button on the Data Field dialog to access the Data Field Options
dialog (Figure 312). Use this dialog to specify additional options for fields in the Column and
Row Fields areas of the Pivot Table Layout dialog.

Figure 312: Data Field Options dialog


The following options are available:
Sort by: Choose the data field to sort columns or rows.
• Ascending: Sorts values from lowest to highest. If the selected field is the one for which
the dialog was opened, items are sorted by name. If a data field is selected, items are
sorted by the resultant values of that field.
• Descending: Sorts values from highest to lowest.
• Manual: Sorts items alphabetically.

Chapter 10 Using Pivot Tables | 333


Display Options: Customize display settings for all row fields, except the last (innermost) row
field.
• Use the Layout drop-down list to select the layout mode for the field in the list box. The
Layout menu provides four layout mode options that are shown in Figures 313 and 314
below:
– Tabular layout
– Outline layout with subtotals at the top
– Outline layout with subtotals at the bottom
– Compact layout
• Enable Empty line after each item to insert a blank row after each item’s data in the pivot
table.
• Use Repeat item labels to toggle whether item labels are repeated or not.

Figure 313: Pivot table layout modes – Tabular and Compact

334 |Calc Guide 24.8


Figure 314: Pivot table layout modes – Outline with subtotals top and bottom
• Show Automatically. This feature displays the top or bottom nn items when you sort by
a specified field. Click the Show option to turn on the automatic show feature and enter
the maximum number of items that you want to show automatically. The From drop-down
list selects the top or bottom items in the specified sort order. The Using field drop-down
list selects the data field by which to sort the data.
• Hide Items. Use these options to select the items to hide from the calculations.
• Hierarchy. For the majority of users, this field will be disabled because Calc does not
provide multiple hierarchies for a single field. However, if using a pivot table data source
extension, that extension could define multiple hierarchies for some fields. In that case,
this setting can be used to select the hierarchy to use.

Options for filter fields


It is possible to set options for a field appearing in the filters section (Figure 295) the same way
options are set for row fields and column fields. However, the options settings have no effect
until that field is moved from the filters section to either the rows section or the columns section.

Working with the results of the pivot table


A pivot table can be easily restructured using the Pivot Table Layout dialog (Figure 295).

Changing the layout


When the Pivot Table Layout dialog is open, fields can be dragged from Row Fields, Column
Fields, Filters, and Data Fields areas and then dropped in a different position. Unused fields can
also be added, and fields removed in error can be replaced by dragging and dropping them into
the positions required.

Chapter 10 Using Pivot Tables | 335


Some manipulation can also be carried out in the results view of the pivot table. Within the
results of the pivot table, drag one of the filters, column, or row fields to a different position. The
mouse pointer will change shape from its starting shape (horizontal or vertical block on the arrow
head) to the opposite if moving to a different field, such as from row to column, where it can be
dropped.

Figure 315: Drag a column field - note the pointer shape

Figure 316: Result of dragging column field (see Figure 315)

Figure 317: Drag a row field - note the pointer shape


You can remove a column, row, or filter field from the pivot table by clicking on it and dragging it
out of the table. The mouse pointer changes to that shown in Figure 318. A field removed cannot
be recovered, without returning to the Pivot Table Layout dialog to replace it.

336 |Calc Guide 24.8


Figure 318: Field dragged out of the pivot table

Grouping rows or columns of a pivot table


For many analyses, categories must be grouped into classes. Grouping can only be done on an
ungrouped pivot table. To group data, select the relevant cell range and choose Data > Group
and Outline > Group from the menu, or press F12 on your keyboard. The type of values you
want to group (such as numbers or text) will determine how the grouping works.

Note
Before you can group, you have to produce a pivot table with ungrouped data. The
time needed for creating a pivot table depends mostly on the number of columns and
rows and not on the size of the basic data. Through grouping, you can produce the
pivot table with a small number of rows and columns. The pivot table can contain a
lot of categories, depending on your data source.
To remove grouping again, click inside the group, then choose Data > Group and Outline >
Ungroup, or press Ctrl+F12.

Grouping of categories with scalar values


For grouping scalar values, select a single cell in the row or column of the category to be
grouped. Choose Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard; Calc displays the Grouping dialog shown in Figure 319.
You can define in which value range (Start / End) the grouping should take place. The default
setting is the whole range, from the smallest to the largest value. In the field Group by, you can
enter the class size, also known as the interval size.

Figure 319: Grouping dialog with scalar categories


Figure 320 shows part of a pivot table created from a list containing speed measurements as a
function of time. This pivot table shows the count of km/h speed measurements in the raw data.

Chapter 10 Using Pivot Tables | 337


Figure 320: Pivot table without grouping Figure 321: Pivot table with grouping
The pivot table in Figure 321 is based on the same raw data but the speed measurements have
been grouped into intervals of 10 km/h.

Grouping of categories with date / time values


For grouping date / time values, select a single cell in the row or column of the category to be
grouped. Choose Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard; Calc displays the Grouping dialog shown in Figure 322.
You can specify the value range for grouping by setting the Start and End points. By default,
grouping covers the entire range, from the smallest to the largest value.
In the Group by field, you can define the class size (interval size). For time-based data, you can
choose from predefined intervals like Seconds, Minutes, Hours, Days, Months, Quarters, or
Years instead of manually entering the interval in days.

Figure 322: Grouping dialog for date/time categories


Figure 323 illustrates this, showing monthly sales for the North region.

338 |Calc Guide 24.8


Figure 323: Pivot table with grouping
Figure 324 shows a pivot table configured to show the daily sales in the North region.

Figure 324: Pivot table without grouping

Grouping without automatic creation of intervals


To group categories that have no intervals, such as those containing text fields, the values to
group must first be defined. To do so, in the pivot table results, select the individual field values
to be grouped and then use Data > Group and Outline > Group on the Menu bar, or press F12
on the keyboard, to group the selected cells.

Chapter 10 Using Pivot Tables | 339


Tip
You can select several non-contiguous cells by pressing and holding the Control
key while clicking with the mouse.
Given the input data shown in Figure 325, create a pivot table with Department in the Row
Fields area and Sum – Sick days in the Data Fields area. The result should be as shown in
Figure 326.

Figure 325: Database with text categories

Figure 326: Pivot table with text categories


In the results of the pivot table select Accounting, Purchasing, and Sales in the Department
column. Select Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard. The pivot table result updates to reflect the new group, as shown in Figure 327.

Figure 327: Summary of single categories in one group


In the updated pivot table result, select Assembly, Production, and Warehouse in the Department
column. Select Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard. The pivot table updates again to reflect the new group, as shown in Figure 328.
You can change the default names for the groups and the newly created group field by editing
the name in the input field (for example changing Group2 to Technical). The pivot table will
remember these settings, even if you change the layout later on.

340 |Calc Guide 24.8


Figure 328: Grouping finished
To add partial sums for the groups, right-click the results of the pivot table and select the
Properties option. Double-click the Department2 entry in the Row Fields area and select the
Automatic option on the Data Field dialog (Figure 306). Click the two OK buttons and the pivot
table is updated to include the partial sums for the groups, as shown in Figure 329.

Figure 329: Renamed group and partial results


If it is not enabled already, select the Enable drill to details option on the Pivot Table Layout
dialog. Double-click the Group 1 and Technical entries in the Department2 column to
collapse/expand the group entries (for example, Figure 330 shows both groups collapsed).

Figure 330: Reduced to the new groups

Note
A well-structured database makes manual sorting within the pivot table obsolete. In
the example shown, you could add another column with the name Department, that
has the correct entry for each person based on whether the employee’s department
belongs to the group Office or Technical. The mapping for this (1:n relationship) can
be done easily with the VLOOKUP() function.

Sorting the result


The results of a pivot table are by default sorted so that categories in columns and rows are
presented in ascending order. There are three ways to change the sorting order:
• Select a sort order in the drop-down menu on a column’s heading.
• Sort manually by using drag and drop.
• Select a sort order through the Data Field Options dialog for the appropriate row or
column field (Figure 312).

Chapter 10 Using Pivot Tables | 341


• Each of these methods are described in the sections that follow.

Select sort order from drop-down menus on each column heading


The simplest way to sort entries is to click the arrow on the right side of the column heading for a
row or column field, and select one of the three sorting options (Figure 331):
• Sort Ascending
• Sort Descending
• Custom Sort

Figure 331: Column sorting and filtering dialog


Selecting the Custom Sort option sorts according to one of the predefined custom sorts defined
in Tools > Options > LibreOffice Calc > Sort Lists. See Chapter 2, Entering and Editing Data
for more information about creating and using sort lists.
This dialog also provides facilities for simple filtering of the data in the pivot table. Check the
required individual boxes to select the data displayed in the results of the pivot table. Options are
provided to show all, show only the current item, or hide only the current item. Click OK to
activate the selected filtering. Once filtering has been carried out, the color of the arrow changes
to white on a blue background, and a small white square is added to the bottom right of the
arrow button (Figure 332).

Figure 332: Arrow color change and indicator square on column heading

342 |Calc Guide 24.8


Manually sorting by drag and drop
You can reorder categories in a pivot table by dragging and dropping the cells with category
values. The dragged cell will be inserted before the cell where you drop it.

Note
In Calc, a cell must be fully selected (highlighted) to be moved, not just have the
cursor in it. The background of a selected cell is visibly highlighted.
To select a single cell:
Click the cell, then hold Shift and click it again.
Alternatively, click and drag across two cells, then drag back to the first cell before releasing the
mouse.
To select multiple cells:
Click one cell to select it.
Hold Shift or Ctrl and click additional cells to add them to the selection.

Sort automatically
To sort automatically, right-click within the pivot table and choose Properties. This will open the
Pivot Table Layout dialog (Figure 295). Double-click the row or column field you want to sort. In
the Data Field dialog which opens (Figure 306), click Options to display the Data Field Options
dialog (Figure 312).
For Sort by, choose either Ascending, Descending, or Manual. If the selected field is the field
for which the dialog was opened, the items are sorted by name. If a data field was selected, the
items are sorted by the resultant value of the selected data field. Ascending sorts the values
from the lowest value to the highest value. Similarly Descending sorts the values descending
from the highest value to the lowest value. Manual sorts values alphabetically.

Drilling
Use drilling to show the related detailed data for a single, compressed value in the pivot table
result. This facility is available only if you selected the Enable drill to details option on the Pivot
Table Layout dialog.
To activate a drill, double-click on the cell or choose Data > Group and Outline > Show
Details. There are two possibilities:
1) The active cell is a row or column field. In this case, drill means an additional breakdown
into the categories of another field. For example, double-click on the cell with the value
Golf. In this instance, the values that are aggregated within Golf can be subdivided using
another field.

Figure 333: Before the drill down for Golf


The Show Detail dialog appears allowing you to select the field to use for further
subdivision. In this example, Employee.

Chapter 10 Using Pivot Tables | 343


Figure 334: Selecting the field for the subdivision

Figure 335: After the drill down


To hide the details again, double-click on the cell Golf or choose Data > Group and
Outline > Hide Details.
The pivot table remembers your selection (in our example the field Employee) by adding
and hiding the selected field so that for the next drill-down for a field in the Category
column the dialog does not appear. To remove the selection Employee, open the Pivot
Table Layout dialog and delete the unwanted selection in the Row or Column Fields
area.
2) The active cell is a data field. In this case, drill-down results in a listing of all data entries
of the data source that aggregate to this value.
In our example, if we double-click on the cell with the value $18,741 from Figure 333,
we would have a new list of all data sets that are included in this value. This list is
displayed in a new sheet.

Figure 336: New sheet after the drill down for a value in a data field

Filtering
To limit the pivot table analysis to a subset of the information that is contained in the data basis,
you can filter the pivot table results.

344 |Calc Guide 24.8


Note
An AutoFilter or Standard Filter used on the sheet containing the raw data has no
effect on the pivot table analysis process. The pivot table always uses the complete
list that was selected when it was started.
To do this, click the Filter button at the top left above the results, or right-click in the results and
select Filter in the context menu.

Note
The Filter button is available only if the Add filter option on the Pivot Table Layout
dialog is selected.

Figure 337: Filter button in the upper left area of the pivot table
In the Filter dialog (Figure 338), you can define up to three filter options that are used in the
same way as Calc’s Standard Filter. The controls in the Options section of this dialog are similar
to the equivalent controls on Calc’s Standard Filter dialog – see Chapter 2, Entering and Editing
Data for more information.

Figure 338: Dialog for defining the filter


The data presented in a pivot table can also be filtered using the drop-downs on the right hand
side of column headings or by using filter fields. Filtering through column headings is described
in “Select sort order from drop-down menus on each column heading” above.
Filter fields (that is, fields that you placed in the Filters area of the Pivot Table Layout dialog) are
another practical way to filter the results of the pivot table. The advantage is that the filtering
criteria used are clearly visible. Click the arrow on the right side of the filter field button to access
the associated filtering dialog (Figure 339).

Chapter 10 Using Pivot Tables | 345


Figure 339: Filter field filtering dialog
The text adjacent to a filter field button indicates the filtering status, that is “- all -” when nothing
is filtered, “- multiple -” when multiple but not all items are filtered, or the value when only that
value is not filtered.

Updating (refreshing) changed values


After you have created the pivot table, changes in the source data do not cause an automatic
update in the resulting table. You must update (refresh) the pivot table manually after changing
any of the underlying data values.
Changes in the source data could appear in two ways:
• The content of existing data sets has been changed.
For example, you might have changed a sales value. To update the pivot table, left-click
in the results area and choose Data > Pivot Table > Refresh on the Menu bar, or right-
click in the results area and choose Refresh in the context menu.
• You have added or deleted data sets in the original list.
In this case, the change means that the pivot table has to use a different area of the
spreadsheet for its analysis. If a simple addition to the list was made (for example, a new
sale from a different employee was inserted), it is possible to update the pivot table by
changing the range in the Selection field in the Source area of the Pivot Table Layout
dialog. In the case of more complex changes to the data set collection, you must redo
the pivot table from the beginning.

Cell formatting
The cells in the results area of the pivot table are automatically formatted by Calc. You can
change this formatting using all the tools in Calc. However, if you make any change in the design
of the pivot table using direct formatting, the formatting will return to that applied automatically by
Calc when the table is refreshed.
On creating a pivot table, six standard cell styles are added to the list of styles in the document if
they are not included already. Each of these styles is applied to part of the pivot table. The
customizable pivot table styles include:
• Pivot Table Category
• Pivot Table Corner

346 |Calc Guide 24.8


• Pivot Table Field
• Pivot Table Result
• Pivot Table Title
• Pivot Table Value

Tip
Use the pivot table styles to make sure that the format of your pivot table is not
unexpectedly changed during updates and that all pivot tables in your document
have the same appearance.
Calc applies the number format from the source list to the data field in the pivot table. For
example, if the source values are in currency format, the corresponding cells in the pivot table
will also use the currency format.
However, this can cause issues if the result is a fraction or percentage, as the pivot table doesn’t
automatically adjust the format. Such results should either have no unit or be displayed as
percentages. While you can manually fix the number format, the changes will reset after the
pivot table is updated.

Deleting a pivot table


To delete a pivot table, left-click in any cell of the pivot table and select Data > Pivot Table >
Delete on the Menu bar, or right-click in any cell of the pivot table and select Delete in the
context menu.

Caution
If you delete a pivot table with an associated pivot chart, the pivot chart is also
deleted. Calc opens a dialog box to confirm the pivot chart deletion.

Using pivot table results elsewhere


The problem
Normally, you create a reference to a value by entering the address of the cell that contains the
value. For example, the formula =C6*2 creates a reference to cell C6 and returns the doubled
value. If this cell is located in the results area of the pivot table, it contains the result that was
calculated by referencing specific categories of the row and column fields. In Figure 340, cell C6
contains the sum of the sales values of the employee Hans in the category Sailing. The formula
in cell C12 uses this value.

Chapter 10 Using Pivot Tables | 347


Figure 340: Formula reference to a cell of the pivot table
If the underlying data or the layout of the pivot table changes, then you must take into account
that the sales value for Hans in the Sailing category might appear in a different cell. Your formula
still references the cell C6 and therefore uses a wrong value. The correct value is in a different
location. For example, in Figure 341, the location is now C7.

Figure 341: The value that you really want to use is now in a different location

The solution: Function GETPIVOTDATA()


Use the function GETPIVOTDATA() to have a reference to a value inside the pivot table by using
the specific identifying categories for this value. This function can be used with formulas in Calc
if you want to reuse the results from the pivot table elsewhere in your spreadsheet.

Syntax
The syntax has two variations:
=GETPIVOTDATA(Target Field; Pivot Table[; Field 1; Item 1][; ... [Field 126; Item
126]])
or
=GETPIVOTDATA(Pivot Table; Constraints)
The square brackets in the first variation surround optional arguments.

First syntax variation


The Target Field specifies which data field of the pivot table is used within the function. If your
pivot table has only one data field, this entry is ignored, but you must enter it anyway.

348 |Calc Guide 24.8


If your pivot table has more than one data field, then you have to enter the field name from the
underlying data source (for example “Sales Value”) or the field name of the data field itself (for
example “Sum – Sales Value”).
The argument Pivot Table specifies the pivot table that you want to use. Your document may
contain more than one pivot table. Enter here a cell reference that is inside the area of your pivot
table. It might be a good idea to always use the upper left corner cell of your pivot table so that
you can be sure that the cell will always be within your pivot table, even if the layout changes.
Example: =GETPIVOTDATA("Sales Value",A1)
If you enter only the first two arguments, then the function returns the total result of the pivot
table (“Sum – Sales Value” entered as the field will return a value of 408,765).
You can add more arguments as pairs with Field names and Elements to retrieve specific
partial sums. In the example in Figure 342, where we want to get the partial sum of Hans for
Sailing, the formula in cell C12 would look like this:
=GETPIVOTDATA("Sales Value",A1,"Employee","Hans","Category","Sailing")

Figure 342: First syntax variation

Second syntax variation


The argument Pivot Table has to be given in the same way as for the first syntax variation.
For the Constraints, enter a list separated by spaces to specify the value you want from the
pivot table. This list must contain the name of the data field if there is more than one data field;
otherwise, it is not required. To select a specific partial result, add more entries in the form of
Field name[Element].
In the example in Figure 343, where we want to get the partial sum of Hans for Sailing, the
formula in cell C12 would look like this:
=GETPIVOTDATA(A1,"Sales Value Employee[Hans] Category[Sailing]")

Chapter 10 Using Pivot Tables | 349


Figure 343: Second syntax variation

Pivot charts
A pivot chart provides a visual representation of the information in a pivot table. You can create a
pivot chart from the output of a pivot table and, if the pivot table gets changed, so does the pivot
chart.
Pivot charts are a special case of the more general Calc charts described in Chapter 3, Creating
Charts and Graphs. The main differences between pivot charts and other charts in Calc are as
follows:
• A pivot chart tracks the changes in the data issued from a pivot table and Calc
automatically adjusts the data series and data range of the pivot chart accordingly.
• Pivot charts include special buttons not found on Calc’s standard charts. These buttons
represent the layout and fields of the underlying pivot table:
– Filter field buttons: Displayed at the top of the pivot chart.
– Row field buttons: Shown at the bottom of the pivot chart.
– Column field buttons: Stacked in the legend on the right side of the chart.
These buttons also allow you to filter the data displayed in the pivot chart.

Creating a pivot chart


To create a pivot chart, click inside the pivot table and select Insert > Chart on the Menu bar or
click the Insert Chart icon on the Standard toolbar.
Calc automatically detects the pivot table and opens the Chart Wizard. Through the Chart
Wizard, you can select the chart type and chart elements for the pivot chart. The wizard is similar
to the corresponding wizard for normal charts but for pivot charts, the steps to define data range
and data series are disabled.

350 |Calc Guide 24.8


Figure 344: Sample pivot chart and associated pivot table
The first step in the wizard is to select the chart type and the same options are available as for a
normal chart (Figure 345).

Figure 345: Select the chart type through the Chart Wizard when creating a pivot chart
The second step is to select the chart elements and these are similar to those for normal charts
(Figure 346).

Chapter 10 Using Pivot Tables | 351


Figure 346: Enter chart elements through the Chart Wizard when creating a pivot chart
Click Finish to close the wizard and create the pivot chart.

Editing a pivot chart


Calc provides tools for changing the chart type, chart elements, fonts, colors, and many other
options. The facilities provided for pivot charts are the same as those available for normal charts;
see Chapter 3, Creating Charts and Graphs.

Updating a pivot chart


If the source data of the pivot table changes, refresh the pivot table and the pivot chart is also
updated accordingly. To refresh the pivot table (and thus the pivot chart), click in any cell within
the pivot table and select Data > Pivot Table > Refresh on the Menu bar or select Refresh in
the context menu.

Filtering a pivot chart


Filters can remove unwanted data from a pivot chart, and any filters applied to the linked pivot
table will automatically update the chart since both display the same data.
How to Filter Using Pivot Chart Buttons:
• Filter Indicators: Pivot chart buttons have a down arrow indicating a pop-up action. If a
filter is applied, the arrow turns blue.
• Edit Mode: Double-click the chart to activate edit mode, indicated by a gray frame around
the chart.
Using Filter Buttons on the Chart:
• Top Buttons (Filter Fields): Click the filter button at the top of the chart to open a filtering
dialog (similar to Figure 338). This allows you to adjust filters for both the pivot table and
chart. The button's legend indicates the filter status:
– "- all -": No filters applied.
– "- multiple -": Some, but not all, items filtered.
– A specific value: Only that value is unfiltered.
• Bottom and Right Buttons (Row/Column Fields): Buttons here with a down arrow open a
sorting and filtering dialog (similar to Figure 38). Use this to modify sorting and filtering
for the table and chart.

352 |Calc Guide 24.8


Figure 347: Filtering applied to filter and row fields

Deleting a pivot chart


To delete a pivot chart, select the chart and press Del on the keyboard.

Note
When you delete a pivot chart, the associated pivot table is not affected.

Caution
If you delete a pivot table with an associated pivot chart, the pivot chart is also
deleted. Calc opens a dialog box to confirm the pivot table deletion.

Chapter 10 Using Pivot Tables | 353


Calc Guide 24.8

Chapter 11
Data Analysis
Using Scenarios, Goal Seek, Solver, Statistics, others
Introduction
Once you are familiar with functions and formulas described in the previous chapter, the next
step is to learn how to use Calc’s automated processes to quickly perform useful analysis of your
data.
Besides formulas and functions, Calc offers various tools for data processing. These tools
include features for copying and reusing data, creating subtotals, conducting what-if analysis,
and performing statistical analysis. You can find them under the Tools and Data menus on the
Menu bar. While not essential for using Calc, these tools can save you time and effort when
managing large data sets or preserving your work for future review.

Note
A related tool, the Pivot Table, is not discussed here due to its complexity, which
warrants a dedicated chapter. For more information, refer to Chapter 10, Using Pivot
Tables.

Consolidating data
The Consolidate tool allows you to combine and aggregate data spread across one or more
sheets. This tool is useful if you need to quickly summarize a large, scattered set of data for
review. For example, you could use it to consolidate multiple department budgets from different
sheets into a single company-wide budget contained in a master sheet.
To consolidate data:
1) Open the document containing the cell ranges to be consolidated.
2) Select Data > Consolidate on the Menu bar to open the Consolidate dialog (Figure
348).
3) Click on the Source data ranges field, then type a reference to a source data range, a
named range, or select it with the mouse. Use the associated Shrink / Expand button if
you need to minimize the dialog while you select the range. Alternatively, select a named
range from the drop-down list to the left of the field.
4) Click Add. The selected range is added to the Consolidation ranges list.
5) Repeat steps 3) and 4) to add additional source ranges.
6) To delete an entry in the Consolidation ranges list, select it and click Delete. The deletion
is carried out without further confirmation.
7) Click on the Copy results to field, then type a reference to the first cell of the target range
or select it with your mouse. You can also select a named range in the drop-down list to
the left of the field.
8) Select a function to aggregate your data in the Function drop-down list. The default is
Sum. Other available functions are Count, Average, Max, Min, Product, Count (numbers
only), StdDev (sample), StDevP (population), Var (sample), and VarP (population).
9) Click OK to consolidate the ranges. Calc runs the function from step 8) on your source
data ranges and populates the target range with the results.

Tip
If you are consolidating the same cell ranges repeatedly, consider converting them
into reusable named ranges to make the process easier. For more information about
named ranges, see Chapter 14, Calc as a Database.

356 |Calc Guide 24.8


Figure 348: Consolidate dialog

Consolidation settings
In the Consolidate dialog, expand the Options section to access the settings shown in Figure
349.

Figure 349: Consolidate dialog – Options section


Consolidate by
In this section, choose whether to consolidate your source data ranges by their range
position or by matching labels. Consolidation labels must be contained within each
range, and the text of corresponding row or column labels must match for the rows or
columns to be combined.
– Row labels – Consolidates rows by matching label. If this option is unchecked, the
tool will consolidate rows by position instead.
– Column labels – Works the same as Row labels, but with columns instead.
Options
Select Link to source data to add formulas in the target range that link back to values in
the source ranges. When you select this option, any changes you make in the source
ranges will automatically update values in the target range.

Chapter 11 Data Analysis | 357


Note
If you use the Link to source data option, each source link is inserted into the target
range, then ordered and hidden from view. Only the final results of consolidation are
displayed by default.

Consolidation example
Figures 350, 351, and 352 show a simple example of consolidation using a spreadsheet with the
sheets Year 1, Year 2, and Consolidated Sales. Figure 350 shows the contents of the Year 1
sheet, with sales figures by region for each of the four product colors.

Figure 350: Year 1 sales by region


Figure 351 shows the Year 2 sheet, sales figures by region for each of four product colors. Note
the different ordering of row and column labels between the two figures.

Figure 351: Year 2 sales by region


Figure 352 shows the consolidated sales data, created by using the Consolidate dialog settings
shown in Figure 349. Note that because the Link to source data option was selected, clicking
on the plus sign (+) indicators to the left of the data will reveal formula links back to the source
ranges.
The source ranges and target range are saved as part of the document. If you later open a
document with consolidated ranges, they will still be available in the Consolidation ranges list of
the Consolidate dialog.

358 |Calc Guide 24.8


Figure 352: Consolidated sales by region

Creating subtotals
Calc offers two methods of creating subtotals: the SUBTOTAL function and the Subtotals tool.

Using the SUBTOTAL function


The SUBTOTAL function is listed under the Mathematical category of the Function Wizard, and
the Functions deck of the Sidebar, which are described in Chapter 8, Using Formulas and
Functions. SUBTOTAL is a relatively limited method for generating a subtotal, and works best if
used with only a few categories.

A SUBTOTAL example
To illustrate how to use the SUBTOTAL function, we use the sales data sheet shown in Figure
353. The AutoFilter function is already applied to the sales data, as indicated by the down arrow
buttons at the head of each column. AutoFilters are described in Chapter 2, Entering and Editing
Data.

Figure 353: Sales data with AutoFilter applied (only the first few rows are shown)
To create a summation subtotal for the Sales Value field using the Function Wizard:
1) Select the cell to contain a subtotal. Typically, this cell is at the bottom of the column
being subtotaled, which, for our example, is the Sales Value column.
2) Use one of the following methods to open the Function Wizard dialog (Figure 354):
– Select Insert > Function on the Menu bar
– Click the Function Wizard icon on the Formula bar
– Press Ctrl+F2

Chapter 11 Data Analysis | 359


Figure 354: Function Wizard dialog
3) Select SUBTOTAL in the Function list of the Function Wizard dialog and click Next.
4) Enter the numeric code of a function into the Function field on the right side of the dialog.
This code must be a value in the range 1 to 11, or 101 to 111, with the meaning of each
value shown in Table 19.

Note
Values 1 to 11 include hidden values in the calculated subtotal, while values 101 to
111 do not. Hiding and showing data is described in Chapter 2, Entering and Editing
Data. Filtered-out cells are always excluded by the SUBTOTAL function.
Table 19: SUBTOTAL function numbers
Function index Function index
Function
(includes hidden values) (ignores hidden values)
1 101 AVERAGE
2 102 COUNT
3 103 COUNTA
4 104 MAX
5 105 MIN
6 106 PRODUCT
7 107 STDEV

360 |Calc Guide 24.8


Function index Function index
Function
(includes hidden values) (ignores hidden values)
8 108 STDEVP
9 109 SUM
10 110 VAR
11 111 VARP

5) Click on the Range field, then type a reference to the Sales Value range or select the
cells with your mouse (Figure 354). Use the Shrink / Expand button if you need to
temporarily minimize the dialog while selecting the cells.
6) Click OK to close the Function Wizard dialog. The cell you selected in step 1) now
contains the total sales value.
7) Click on the AutoFilter down arrow button at the top of the Employee column and remove
all marks from the filter area except those next to Brigitte and (empty). The cell that you
selected in step 1) should now reflect the sum of all of Brigitte’s sales (Figure 355).

Note
If the cell range used to calculate a subtotal contains other subtotals, these subtotals
will not be counted in the final one. Similarly, if you use this function with AutoFilters,
only the data satisfying the current filter selections will be displayed. Any filtered-out
data is ignored.

Figure 355: SUBTOTAL result for Brigitte’s sales

The Subtotals tool


Calc offers the Subtotals tool as a more comprehensive alternative to the SUBTOTAL function.
In contrast to SUBTOTAL, which only works on a single array, the Subtotals tool can create
subtotals for up to three arrays arranged in labeled columns. It also groups subtotals by category
and sorts them automatically, thereby eliminating the need to apply AutoFilters and filter
categories by hand.

Using the Subtotals tool


To insert subtotal values into a sheet:
1) Select the cell range for the subtotals that you want to calculate, and remember to
include the column heading labels. Alternatively, click on a single cell within your data to
allow Calc to automatically identify the range.
2) Select Data > Subtotals on the Menu bar to open the Subtotals dialog (Figure 356).

Chapter 11 Data Analysis | 361


3) In the Group by drop-down list on the 1st Group tab, select a column by its label. Entries
in the cell range from step 1) will be grouped and sorted by matching values in this
column.
4) In the Calculate subtotals for box on the 1st Group tab, select a column containing
values to be subtotaled. If you later change values in this column, Calc will automatically
recalculate the subtotals.
5) In the Use function box on the 1st Group tab, select a function to calculate the subtotals
for the column selected in step 4).
6) Repeat steps 4) and 5) to create subtotals for other columns on the 1st Group tab.
7) You can create two more subtotal categories by using the 2nd Group and 3rd Group tabs
and repeating steps 3) to 6). If you do not want to add more groups, then leave the
Group by list for each page set to “- none -”.
8) Click OK. Calc will add subtotal and grand total rows to your cell range.

Figure 356: Subtotals dialog


For our sales data example, a partial view of the results is shown in Figure 357. The group
settings are identified in Table 20.
Table 20: Group settings used on Subtotals dialog for example sales data
Tab Group by Calculate subtotals for Use function
1st Group Employee Sales Value Sum
2nd Group Category Sales Value Sum
3rd Group - none - - -

Subtotal outline
When you use the Subtotals tool, Calc inserts an outline to the left of the row number column.
This outline represents the hierarchical structure of your subtotals, and can hide or show data at
different levels in the hierarchy using the numbered column indicators at the top of the outline or
the group indicators, denoted by plus (+) and minus (-) signs.
This feature is useful if you have many subtotals, as you can simply hide low-level details, such
as individual entries, to produce a high-level summary of your data. For more information on how
to use outlines, see Chapter 2, Entering and Editing Data.

362 |Calc Guide 24.8


To turn off outlines, select Data > Group and Outline > Remove Outline on the Menu bar. To
reinstate them, select Data > Group and Outline > AutoOutline.
Figure 357 shows the outline for our sales data example.

Figure 357: Partial outlined view of sales data example with subtotals
Column 1 represents the highest group level, the grand total over all employees. Outline
columns 2 to 5 show descending group levels as follows:
• Column 2 represents the grand total over all categories.
• Column 3 represents the total for each employee.
• Column 4 represents the total for each category for an individual employee.
• Column 5 shows individual entries.

Subtotals tool options


Click on the Options tab of the Subtotals dialog to access the following settings:
Groups
Defines how subtotal data is organized.
– Page break between groups – inserts page breaks between each subtotal group so
that each group displays on a separate page when you print the data.
– Case sensitive – prevents the tool from grouping entries by data labels that differ by
case. In our sales data example, entries with “Brigitte” and “brigitte” under the
Employee column will not match if this option is selected.

Chapter 11 Data Analysis | 363


– Pre-sort area according to groups – sorts entries by group before calculating
subtotals. Disabling this option prevents the tool from grouping matching entries
together. As a result, distinct subtotals will be created for matching entries if they do
not appear on consecutive rows. For example, two entries under the “Golf” category
will not count towards the same group subtotal if there is an entry for “Tennis” in
between them.

Figure 358: Options tab of the Subtotals dialog


Sort
Defines how subtotal data is sorted. This section is disabled if Pre-sort area according
to groups is unchecked.
– Ascending or Descending – sorts entries by value from lowest to highest and highest
to lowest, respectively. You can modify these sort rules by using Data > Sort on the
Menu bar. For more detail, see Chapter 2, Entering and Editing Data.
– Include formats – carries over formatting, such as the currency format, from the data
to the corresponding subtotals.
– Custom sort order – sorts your data according to one of the predefined custom sorts
defined in Tools > Options > LibreOffice Calc > Sort Lists on the Menu bar. For
more details about custom sort lists, see Chapter 2, Entering and Editing Data.

Reset and Remove


In the Subtotals dialog, use the Reset button to undo any changes made on the current tab. Use
the Remove button to remove any subtotals that have already been created using the Subtotals
tool. Use these features with care, as no confirmation dialog is displayed.

Using scenarios
Scenarios are cell ranges that have been saved and named. They can be used to answer “what-
if” questions about your data. You can create multiple scenarios for the same calculation set,
then quickly swap between them to view the outcomes of each. This feature is useful if you need
to test the effects of different conditions on your calculations, but do not want to deal with
repetitive manual data entry. For example, if you wanted to test different interest rates for an
investment, you could create scenarios for each rate, then switch between them to find out
which rates work the best for you.

364 |Calc Guide 24.8


Creating scenarios
To create a new scenario:
1) Select the cells that contain the values that will change between scenarios. To select
multiple ranges, hold down the Ctrl key as you click. You must select at least two cells.
2) Choose Tools > Scenarios on the Menu bar to open the Create Scenario dialog (Figure
359).

Figure 359: Create Scenario dialog


3) Enter a name for the new scenario in the Name of Scenario field.

Tip
When naming a new scenario, use a unique name that clearly identifies and
distinguishes it from other scenarios. The default name suggested by Calc may not
be the best choice, especially if you have a large set of scenarios.
4) Optionally, add information to the Comment field. The example in Figure 359 shows the
default comment.
5) Click OK to close the dialog. The new scenario is automatically activated upon creation.
6) Repeat steps 1) to 5) to create additional scenarios. Select the same cell range that you
used for the first scenario to have multiple scenarios for the same calculations.

Tip
To keep track of which calculations are dependent on your scenarios, use Tools >
Detective > Trace Dependents on the Menu bar after highlighting your scenario
cells. For more information about the Detective tool, see Chapter 8, Using Formulas
and Functions.

Scenario settings
The Settings section of the Create Scenario dialog (Figure 360) contains the following options:

Chapter 11 Data Analysis | 365


Figure 360: Create Scenario dialog – Settings
Display border
Places a colored border around the cell range that contains your scenario (Figure 361).

Figure 361: Scenario cell range with border


To choose the color of the border, use the drop-down field to the right of this option. The
border has a title bar displaying the name of the active scenario and a down arrow button
that opens a drop-down list of all the scenarios defined for the current cell range. You can
swap to another scenario by selecting it in this list.
Copy back
Copies any changes made to a scenario’s cell values back into the active scenario. If you
uncheck this option, then the scenario’s initial values cannot be overwritten. The actual
behavior of the Copy back setting depends on the current cell and sheet protections and
the Prevent changes setting (see Table 22 on page 367).

Caution
When creating a new scenario from the cells of a scenario with Copy back enabled,
be careful not to overwrite the old scenario. To avoid this situation, create the new
scenario with Copy back enabled first, then change its values only once it is active.
Copy entire sheet
Creates a copy of the sheet with the new active scenario. The sheet is named after this
scenario. Note that changing scenario values in the copy sheet will not affect the active
scenario, even if it has Copy back enabled.
Prevent changes
Prevents changes to a scenario with Copy back enabled when the sheet is protected but
the cells are not. Also prevents changes to the scenario’s settings while the sheet is
protected. This option and its effects are more fully explained in the next section.

366 |Calc Guide 24.8


Changing scenarios
Scenarios have two aspects that can be altered independently:
• Scenario properties (that is, its settings)
• Scenario cell values
The extent to which these aspects can be changed depends on the active scenario's properties
and the current sheet and cell protections. For more detail about sheet and cell protections, see
Chapter 2, Entering and Editing Data.

Changing scenario properties


Table 21 summarizes how sheet protection and the Prevent changes option affect your ability to
change scenario properties.
Table 21: Changing scenario properties
Sheet Prevent
Property changes
protection changes
On On No scenario properties can be changed.
Display border and Copy back can be changed. Prevent
On Off
changes and Copy entire sheet cannot be changed.
All scenario parameters except for Copy entire sheet can be
Off Any setting changed. In this case, the Prevent changes option has no
effect.

Changing scenario cell values


Table 22 summarizes the interaction of various settings in making changes to scenario cell
values.
Table 22: Changing scenario cell values
Scenario
Sheet Prevent
cell Copy back Change allowed
protection changes
protection
Scenario cell values cannot be
On Off On On
changed.
Scenario cell values can be
On Off Off On changed, and the scenario is
updated.
Scenario cell values can be
changed, but the scenario is not
On Off Any setting Off
updated due to the Copy back
setting.
Scenario cell values cannot be
On On Any setting Any setting
changed.
Scenario cell values can be
changed and the scenario is
Off Any setting Any setting Any setting
updated or not, depending on
the Copy back setting.

Working with scenarios using the Navigator


Scenarios that have been added to a spreadsheet may be viewed using the Navigator. To open
a scenario, select View > Navigator from the Menu bar, then click on the Scenarios icon in the

Chapter 11 Data Analysis | 367


Navigator and choose a scenario from the list (Figure 362). All defined scenarios are listed along
with the comments entered when each scenario was created. You can also use the equivalent
features in the Navigator deck of the Sidebar. For more information about the Navigator, refer to
Chapter 1, Introduction.

Figure 362: Scenarios in the Navigator


To apply a scenario to the current sheet, double-click the scenario name in the Navigator.
To delete a scenario, right-click the name in the Navigator and choose Delete, or press the
Delete key after selecting it. A confirmation dialog will be displayed.
To edit a scenario, right-click the name in the Navigator and choose Properties. Calc displays
the Edit Scenario dialog, which is similar to the Create Scenario dialog (Figure 359).

Using the Multiple Operations tool


Similar to scenarios, the Multiple Operations tool conducts what-if analysis on your calculations.
However, unlike scenarios that represent individual sets of values for multiple formula variables,
this tool uses a range of values for just one or two variables. It then applies one or more
formulas to generate a corresponding range of solutions. Because each solution is linked to one
or two variable values, both the variable and solution ranges can be easily organized in a tabular
format. Consequently, the Multiple Operations tool is ideal for producing data that is easy to
read, share, or visualize using graphs.

Tip
Exercising good organization can make using this tool relatively painless. For
example, we recommend keeping your data together on one sheet and using labels
to identify your formulas, variables, and table ranges.

Multiple Operations with one formula and one variable


The simplest way to learn how to use the Multiple Operations tool is by starting with one formula
and one variable. For guidance on using the tool with multiple formulas or with two variables,
refer to the sections "Calculating with several formulas simultaneously" and "Multiple operations
with two variables" below, respectively.

368 |Calc Guide 24.8


To use the Multiple Operations tool with one formula and one variable:
1) In the cells of a worksheet, enter a formula and at least one variable that it uses.
2) In the same worksheet, enter values into a cell range that occupies a single column or
row. These values are used for one of the variables of the formula that you defined in
step 1).
3) With the mouse, select the range containing both the variable range that you defined in
step 2) and the adjacent empty cells that follow it. Depending on how your variable range
is arrayed, these empty cells will either be in the column to the right (if the range is in a
column) or in the row immediately below (if it is in a row).
4) Select Data > Multiple Operations on the Menu bar to open the Multiple Operations
dialog (Figure 363).

Figure 363: Multiple Operations dialog


5) Click on the Formulas field and type a cell reference to the formula you defined in step 1)
or select the cell with the mouse. Use the associated Shrink / Expand button if you need
to minimize the dialog while selecting the cell.
6) If the range from step 2) is arrayed in a column, then click on the Column input cell field
and type a cell reference to the variable that you want to use or select the cell with the
mouse. If the range is in a row, then use the Row input cell field instead.
7) Click OK to run the tool. The Multiple Operations tool will generate its results in the
empty cells that you selected in step 3). Each result value corresponds to the variable
value adjacent to it, and together they form the entries of a results table.

An example with one formula and one variable


Using the Multiple Operations tool is best explained by example. Suppose that you produce toys
that you sell for $10 each (cell B1 of a worksheet). Each toy costs $2 to make (B2), and you
have a fixed annual cost of $10,000 (B3). What is the minimum number of toys that you must
sell to break even? Suppose that our initial estimate of quantity sold is 2,000 (B4).

Chapter 11 Data Analysis | 369


Figure 364: Inputs to Multiple Operations tool for one formula, one variable
To answer this question:
1) Enter the following formula into B5: =B4*(B1-B2)-B3. This formula represents the
equation Profit = Quantity * (Selling price – Direct costs) – Fixed costs. With this
equation, our initial quantity produces a $6,000 profit, which is higher than the break-
even point.
2) In D2:D11, enter a range of alternate quantities from 500 to 5000 in steps of 500.
3) Select the range D2:E11 to define the results table. This range includes the alternate
quantity values (column D) and the empty results cells (column E).
4) Select Data > Multiple Operations on the Menu bar to open the Multiple Operations
dialog.
5) Using the Formulas field, select the cell B5.

Figure 365: Results of Multiple Operations tool for one formula and one variable
6) Using the Column input cell field, select the cell B4 to set the quantity as the variable for
our calculations. Figure 364 shows the worksheet and Multiple Operations dialog at this
point.

370 |Calc Guide 24.8


7) Click OK. The profits for the different quantities are now shown in column E (Figure 365).
We can see that the break-even point is between 1000 and 1500 toys sold – namely,
1250. Figure 365 shows an XY (Scatter) chart showing the profit as a function of
quantity.

Figure 366: XY (Scatter) plot of profit over quantity of toys sold (visualization example)

Calculating with several formulas simultaneously


Using the Multiple Operations tool with multiple formulas follows nearly the same process as
with one formula, but with two important differences:
1) For each formula that you add, you must also add a corresponding column or row to the
results table to contain the output of that formula.
2) How you initially arrange your formulas determines how their results will be displayed in
the results table. For example, if you arrange the formulas A, B, and C in a single row in
that order, then Calc will generate the results of A in the first results table column, the
results of B in the second column, and the results of C in the third.

Note
The Multiple Operations tool only accepts formulas arranged in a single row or
column, depending on how your results table is oriented. If the table is column-
oriented – that is, the way it is in our sales data example – then your formulas must
be arranged in a row. If the table is row-oriented, then your formulas must be in a
column.

Caution
Be careful not to add empty cells between formulas, as they will create gaps in the
results table and may cause some results not to appear if you don't select enough
rows or columns for the table.

An example with two formulas and one variable


Using our sales data example, suppose that we want to calculate the annual profit per item sold
in addition to the annual overall profit. To calculate the results:
1) In the sheet from the previous example, delete the results in column E.
2) Enter the following formula in C5: =B5/B4. You are now calculating the annual profit per
item sold.

Chapter 11 Data Analysis | 371


3) Select the range D2:F11 for the results table. Column F will contain the results of the
annual profit per item formula in C5.
4) Select Data > Multiple Operations on the Menu bar to open the Multiple Operations
dialog.
5) Using the Formulas field, select the range B5:C5.
6) Using the Column input cell field, select the cell B4. Figure 367 shows the worksheet and
the dialog at this point.

Figure 367: Inputs to Multiple Operations tool for one variable and two formulas
7) Click OK. Now the profits are listed in column E and the annual profit per item in column
F.

Figure 368: Results of Multiple Operations tool for one variable and two formulas

Multiple operations with two variables


When using the Multiple Operations tool with two variables, it generates a two-dimensional
results table. Each variable defines one dimension of the table: the alternate values for one
variable form the row headings, while the values for the other variable form the column
headings. Each cell in the table represents a unique combination of row and column values, with
the results calculated based on these paired values.

372 |Calc Guide 24.8


Since two variables are involved, you must specify both the Column input cell and Row input
cell fields. The order of these inputs is critical: the Column input cell field determines the row
heading values, and the Row input cell field determines the column heading values.

Tip
Since column headings are in a row at the top of the table, they correspond to the
Row input cell field. Likewise, row headings are in a column, so they correspond to
the Column input cell field.

Note
If you use two variables, the Multiple Operations tool will not work with multiple
formulas. It will allow you to enter the extra formulas, but will not generate the
expected results for any formula beyond the first.

Calculating with two variables


Using our sales example, suppose that in addition to varying the quantity of toys sold, you also
want to vary the unit sale price as well. To calculate the results:
1) Expand the sales data table by entering $8, $10, $15 and $20 in the range E1:H1.
2) Select the range D1:H11 for the results table.
3) Select Data > Multiple Operations on the Menu bar to open the Multiple Operations
dialog.
4) Using the Formulas field, select cell B5.
5) Using the Row input cell field, select cell B1. The column headings – $8, $10, $15 and
$20 – are now linked to the unit sale price variable defined in cell B1.
6) Using the Column input cell field, select cell B4. The row headings – 500, 1000, ... , 5000
– are now linked to the quantity sold variable defined in cell B4. Figure 369 shows the
worksheet and dialog at this point.
7) Click OK. The profits for the different sale prices and quantities are now shown in the
range E2:H11 (Figure 374).

Chapter 11 Data Analysis | 373


Figure 369: Inputs to Multiple Operations tool for two variables

Figure 370: Results of Multiple Operations tool for two variables

Using Goal Seek


Besides scenarios and the Multiple Operations tool, Calc offers a third "what-if" analysis tool
called Goal Seek. Typically, you use a formula to calculate a result from given values. However,
with Goal Seek, you start with the desired result and work backwards to find the values that
produce it. This feature is useful when you know the outcome you want but need to determine
how to achieve it or how it might change if you adjust certain conditions.

Note
Only one argument can be altered at a time in a single goal seek. If you need to test
multiple arguments, then you must run a separate goal seek on each one.

Goal Seek example


Suppose that we want to calculate the annual interest return for an account. To calculate annual
interest (I), we must create a table with values for the capital (C), the interest period length in
years (n), and the interest rate (i). The formula is I = C*n*i.

374 |Calc Guide 24.8


Suppose that the interest rate i = 7.5% (cell B3 of a worksheet) and the period length n = 1
(B2) remain constant. We want to know how much investment capital C is needed to achieve a
return of I = $15,000. Assume that our initial capital estimate is C = $100,000 (B1).
To calculate the return:
1) Enter the return formula (=B1*B2*B3) into B4 and select the cell with the mouse.
2) Select Tools > Goal Seek on the Menu bar to open the Goal Seek dialog (Figure 371).

Figure 371: Goal Seek dialog


3) B4 should already be entered in the Formula cell field. However, if you want to select a
different cell, use the associated Shrink / Expand button to minimize the dialog while
you select the required cell.
4) Click on the Variable cell field, then type a reference to cell B1 or select it with the mouse
to make the capital the variable in the current Goal Seek.
5) Enter the desired formula result in the Target value field. In this example, the value is
15000. Figure 372 shows the cells and dialog fields at this point.

Figure 372: Example setup for goal seek


6) Click OK. A dialog appears informing you that the goal seek was successful (Figure 373).

Figure 373: Goal seek result dialog


7) Click Yes to enter the goal value into the variable cell. The result is shown in Figure 374,
indicating that a capital requirement of $200,000 is needed to achieve a $15,000 return.

Chapter 11 Data Analysis | 375


Figure 374: Result of goal seek in worksheet

Note
Not every goal seek problem succeeds in returning a good result. It depends on the
formula used, goal value, and initial value. The goal seek algorithm iterates internally
several times converging to the goal.
If the goal seek is unsuccessful, Calc displays an information dialog reporting the
failure. This dialog offers the choice of inserting the closest value into the variable
cell. Press Yes or No as required.

Using the Solver


A more elaborate form of goal seek, the Solver, allows you to solve mathematical programming
or optimization problems. A mathematical programming problem is concerned with minimizing or
maximizing a function subject to a set of constraints. These types of problems occur across
various fields, including science, engineering, business, and more. While a comprehensive
explanation of mathematical programming is beyond the scope of this guide, readers can
explore the topic further on the Mathematical Optimization Wikipedia page. This page offers an
overview and links to more in-depth resources.
Calc offers the following selection of solver engines:
• DEPS (Differential Evolution & Particle Swarm Optimization) Evolutionary Algorithm.
• SCO (Social Cognitive Optimization) Evolutionary Algorithm.
• LibreOffice CoinMP Linear Solver.
• LibreOffice Linear Solver.
• LibreOffice Swarm Non-Linear Solver (experimental).

Caution
As the LibreOffice Swarm Non-Linear Solver is an experimental tool, it may not be
supported in future versions of Calc, and we recommend that you do not use it
unless you are familiar with non-linear programming concepts.
The DEPS and SCO Evolutionary Algorithms are designed for solving non-linear problems. To
use them, you must have a Java runtime environment installed on your computer and enable the
Tools > Options > LibreOffice > Advanced > Use a Java runtime environment setting. If
available, the DEPS Evolutionary Algorithm is the default solver; otherwise, the LibreOffice
CoinMP Linear Solver is used by default.
These options offer flexibility, allowing you to select the algorithm that best fits your specific
problem—whether linear or non-linear—and your performance needs. For more detailed
information on the available algorithms and their configuration, refer to the Help system.

376 |Calc Guide 24.8


To use the Solver to solve a mathematical programming problem, you must formulate the
problem as follows:
• Decision variables – a set of n non-negative variables x1, … , xn,. Decision variables
may be real numbers, but generally tend to be integers in many real world problems.
• Constraints – a set of linear equalities or inequalities involving the decision variables.
• Objective function – a linear expression involving the decision variables.
The goal is usually to find values of the decision variables that satisfy the constraints and
maximize or minimize the result of the objective function.

Note
Calc saves solver settings to the ODS file and each tab can have its own model. To
support interoperability, the mechanism to save/load solver configurations is
compatible with Microsoft Excel.

Solver dialog
After setting up the data for the problem in your Calc spreadsheet, select Tools > Solver on the
Menu bar to open the Solver dialog (Figure 375).

Note
Depending on the configuration of your computer, a message may be displayed the
first time that you select Tools > Solver after starting Calc. The nature of this
message will change dependent on the existence of a Java runtime environment
(JRE) on your system. If no JRE is detected, the message will simply be a warning to
that effect. In the case where a JRE is detected but the Tools > Options >
LibreOffice > Advanced > Use a Java runtime environment option is disabled,
then the message will include a button to enable that option.
Target cell
Type a cell reference to the objective function or select it with the mouse.
Optimize result to
Select Maximum to find the maximum result for the objective function, Minimum to find
the minimum result, or Value of to set it to a specific value. If you select Value of, enter
the required value or a reference to the cell containing that value.
By changing cells
Enter the locations of any cells that define your decision variables.
Limiting Conditions
Enter your constraints in the fields in this area:
– Cell reference – enter a cell reference to a decision variable.
– Operator – defines a parameter for a constraint. Available options include <= (less
than or equal to), = (equal to), => (greater than or equal to), Integer (values without
decimals), and Binary (only 0 or 1).
– Value – enter a value or a cell reference to a constraint formula.
– Remove button – deletes the currently-defined constraint.

Chapter 11 Data Analysis | 377


Figure 375: Solver dialog

Tip
Remember that for some of these options, you can minimize the Solver dialog using
the associated Shrink / Expand buttons if you need to select cells with the mouse.
After setting up the Solver, click the Solve button to begin adjusting values and calculating
results. Depending on the complexity of the problem, this process may take some time. To
restart, click the Reset All button, which clears the data entered in the Solver dialog (Figure
375).
If you are using the DEPS or SCO Evolutionary Algorithm, Calc may occasionally pause the
solver engine to display the Solver Status dialog (Figure 376). This dialog provides diagnostic
information about the engine’s current progress, which can be useful for advanced users. Click
OK to close the dialog and complete the calculations, or click Continue to process one more
step, with updated diagnostic information appearing at the next pause. By default, the Solver
Status dialog is enabled, but you can disable it by unchecking the Show enhanced solver
status option in the Solver Options dialog.

Figure 376: Solver Status dialog

378 |Calc Guide 24.8


On successful completion, Calc presents a Solving Result dialog (Figure 377). This dialog
includes buttons to save (Keep Result) or discard (Restore Previous) your results.

Figure 377: Solving Result dialog


The Options button (Figure 375) opens the Options dialog shown in Figure 378.

Solver options

Figure 378: Solver Options dialog


Solver engine
With the standard LibreOffice download, and an enabled Java runtime environment, the
Solver engine drop-down list provides five options:
– DEPS Evolutionary Algorithm
– SCO Evolutionary Algorithm
– LibreOffice CoinMP Linear Solver
– LibreOffice Linear Solver
– LibreOffice Swarm Non-Linear Solver (experimental)
Settings
This area enables the user to adjust the detailed processing parameters of the selected
solver engine, and the options available vary between engines.

Chapter 11 Data Analysis | 379


Solver example
Suppose that you have $10,000 that you want to invest in two mutual funds for one year. Fund X
is a low risk fund with an 8% interest rate and Fund Y is a higher risk fund with a 12% interest
rate. How much money should be invested in each fund to earn a total interest of $1,000?
To find the answer using the Solver:
1) Enter the following labels and data into a worksheet:
– Row labels: Fund X, Fund Y, and Total in cells A2, A3, and A4.
– Column labels: Interest earned, Amount invested, Interest rate, and Time period in
cells B1 thru E1.
– Interest rates: 8% and 12% in cells D2 and D3.
– Time period: 1 in cells E2 and E3.
– Total amount invested: $10000 in cell C4.
– Enter an arbitrary value ($0 or leave blank) in cell C2 as the amount invested in Fund
X.
2) Enter the following formulas:
– In cell C3, enter the formula =C4–C2 (total amount – amount invested in Fund X) as
the amount invested in Fund Y.
– In cells B2 and B3, enter the formulas =C2*D2*E2 (B2) and =C3*D3*E3 (B3).
– In cell B4, enter the formula =B2+B3 as the total interest earned. Figure 379 shows the
worksheet at this point.
Select Tools > Solver on the Menu bar to open the Solver dialog (Figure 375).

Figure 379: Solver example setup


3) Using the Target cell field, select the cell that contains the target value. In this example, it
is B4, which contains the total interest value.
4) Select Value of and enter 1000 in the field next to it. In this example, the target cell
value is 1000 because your target is a total interest earned of $1,000.
5) Using the By changing cells field, select cell C2 in the sheet. In this example, you need to
find the amount invested in Fund X (cell C2).
6) Enter the following limiting conditions for the variables by using the Cell reference,
Operator, and Value fields:
– C2 <= C4 – the amount invested in Fund X cannot exceed the total amount available.
– C2 => 0 – the amount invested in Fund X cannot be negative.
– C2 is an Integer – specified for convenience.
7) Click Solve. The result is shown in Figure 380.

380 |Calc Guide 24.8


Figure 380: Solver example result

Using Statistics tools


The tools found under Data > Statistics on the Menu bar (Figure 381) are useful for quick and
easy statistical analysis of your data.

Figure 381: Statistics menu


These tools are described in the subsections that follow.

Sampling tool
Selecting Data > Statistics > Sampling on the menu bar opens the Sampling dialog shown in
Figure 34. The Sampling tool creates a target table with data sampled from a source table. It can
pick samples randomly or periodically. Sampling is done by rows, with whole rows of the source
table copied into rows of the target table.

Chapter 11 Data Analysis | 381


Figure 382: Sampling dialog
Input range
Specifies the cell range containing the source table.
Results to
Specifies the top left cell of the target table. When you run the tool, it will fill out the rest
of the target table starting from this cell. Be careful, Calc will replace any data that is in
the range of the table to be created.
Random
Enables random sampling mode when selected.
Sample size
Defines the number of lines to be sampled from the source table during random
sampling. Only available if the Random option is selected. If With replacement is
deselected, the maximum value that can be entered in this field is limited to the number
of rows in the source table.
With replacement
When this option is selected, a sample drawn from the source table can be returned to
the pool, making it eligible for re-sampling. This allows the sample size to exceed the
number of rows in the source table. If the option is not selected, samples cannot be re-
used, and the sample size is limited to the number of rows in the source table. For
periodic sampling, this option is automatically disabled. Note that the With replacement
and Keep order options cannot be selected at the same time.
Keep order
If this option is selected, samples are drawn from the source table in order of the data in
the source table. If deselected, samples are drawn in random order from the source
table. This option is automatically selected for periodic sampling. It is not possible to
have both With replacement and Keep order options selected simultaneously.
Periodic
Enables periodic sampling mode when selected.
Period
Defines the number of lines to skip between samples during periodic sampling. For
example, a value of 2 will cause alternate lines to be sampled from the source table,

382 |Calc Guide 24.8


starting with the second line. Only available if the Periodic option is selected. The
maximum value that can be entered in this field is limited to the number of rows in the
source table.

Tip
The Shrink / Expand buttons in the upper-right corner of the dialog may be used to
shrink the dialog using the mouse.
Figure 383 shows the source table (below the Source Data heading) and the corresponding
target table (under the Target Data heading), sampled using the settings shown in Figure 382.

Figure 383: Example data for the Sampling tool

Descriptive Statistics tool


Selecting Data > Statistics > Descriptive Statistics on the Menu bar opens the Descriptive
Statistics dialog (Figure 384).Given a set of data, this tool creates a tabular report of the data
set’s primary statistical properties, such as information about its central tendency and variability.

Figure 384: Descriptive Statistics dialog


Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will fill out the rest
of the report table starting at this cell. Be careful, Calc will replace any data that is in the
range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Figure 385 shows a small data set comprising student examination results in three subjects.

Chapter 11 Data Analysis | 383


Figure 385: Input data for descriptive statistics analysis
Figure 386 shows the statistics report generated for this input data using the settings shown in
Figure 384.

Figure 386: Results from Descriptive Statistics tool

Tip
For more information on descriptive statistics, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Descriptive_statistics.

Analysis of Variance (ANOVA) tool


Selecting Data > Statistics > Analysis of Variance (ANOVA) on the Menu bar opens the
Analysis of Variance (ANOVA) dialog (Figure 387).TThis tool compares the means of two or
more groups in a sample.
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will fill out the
analysis of variance report table starting at this cell. Be careful, Calc will replace any data
that is in the range of the table to be created.

384 |Calc Guide 24.8


Figure 387: Analysis of Variance (ANOVA) dialog
Single factor / Two factor
Determines whether the analysis is for single factor or two factor ANOVA.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows. Only
available if Single factor is selected.
Alpha
In this field, enter a significance level in the range 0.01 to 0.99. The default is 0.05.
Rows per sample
Defines how many rows a sample has. This option is always set to 1 in this version of
Calc.
To illustrate how to use this tool, we use the input data set from Figure 385. Figure 388 shows
the analysis of variance results generated for this data using the settings shown in Figure 387.

Figure 388: Results from Analysis of Variance (ANOVA) tool

Tip
For more information on analysis of variance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Analysis_of_variance.

Chapter 11 Data Analysis | 385


Correlation tool
The Correlation tool measures the relationship between two sets of numeric data and calculates
the correlation coefficient. This coefficient, ranging from -1 to +1, indicates the strength and
direction of the relationship between the two variables. A coefficient of +1 signifies a perfect
positive correlation (the data sets align perfectly), while a coefficient of -1 represents a perfect
negative correlation (the data sets are completely inverse). To use this tool, go to Data >
Statistics > Correlation in the Menu bar to open the Correlation dialog (Figure 389).

Figure 389: Correlation dialog


Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will fill out the
correlation coefficient table starting at this cell. Be careful, Calc will replace any data that
is in the range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
To illustrate how to use this tool, we again use the data set from Figure 385. Figure 390 shows
the correlation coefficients generated for this input data using the settings shown in Figure 389.

Figure 390: Correlation results

Tip
For more information on statistical correlation, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Correlation_and_dependence.

Covariance tool
Selecting Data > Statistics > Covariance on the Menu bar opens the Covariance dialog (Figure
391).This tool measures how much two sets of numeric data vary together.

386 |Calc Guide 24.8


Figure 391: Covariance dialog
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will fill out the
covariance table starting at this cell. Be careful, Calc will replace any data that is in the
range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
To illustrate how to use this tool, we again use the data set from Figure 385. Figure 392 shows
the six covariance values generated for this input data using the settings shown in Figure 391.

Figure 392: Covariance results

Tip
For more information on statistical covariance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Covariance.

Exponential Smoothing tool


Selecting Data > Statistics > Exponential Smoothing on the Menu bar opens the Exponential
Smoothing dialog (Figure 393).This tool filters a data set to produce smoothed results. It is used
in domains such as stock market analysis and in sampled measurements.

Chapter 11 Data Analysis | 387


Figure 393: Exponential Smoothing dialog
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate
smoothed results starting at this cell. Be careful, Calc will replace any data that is in the
range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Smoothing factor
Enter a value here between 0 and 1 (default is 0.2) that represents the damping factor
alpha in the smoothing equation.
To illustrate how to use this tool, we use the data set shown in Figure 394. The table has two
time series representing impulse functions at times t=0 and t=2.

Figure 394: Input data set for exponential smoothing example


Figure 395 shows the smoothed results for this input data using the settings shown in Figure
393. In the result table, it is possible to change the outcome by varying the Alpha parameter.

Tip
For more information on exponential smoothing, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Exponential_smoothing.

388 |Calc Guide 24.8


Figure 395: Results from Exponential Smoothing tool

Moving Average tool


Selecting Data > Statistics > Moving Average on the Menu bar opens the Moving Average
dialog (Figure 396).This tool calculates the moving average of a time series data set.

Figure 396: Moving Average dialog


Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the
moving average results starting at this cell.
Trim input range to actual data content
Specifies whether to allow trimming of the input range to the actual data content before
computing the moving average. Enabled by default to provide better performance.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Interval
Specifies the number of samples used in the moving average calculation (the default
value is 2).

Chapter 11 Data Analysis | 389


To illustrate how to use this tool, we again use the data set from Figure 394. Figure 397 shows
the moving averages calculated for this input data using the settings shown in Figure 396.

Tip
For more information on the moving average, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Moving_average.

Figure 397: Calculated moving averages

Regression tool
Selecting Data > Statistics > Regression on the Menu bar opens the Regression dialog (Figure
398).This tool performs linear, logarithmic, or power regression analysis of a data set comprising
one dependent variable and multiple independent variables.

Figure 398: Regression dialog

390 |Calc Guide 24.8


Independent variable(s) (X) range
Specifies the cell range containing the independent variables in the source data.
Dependent variable (Y) range
Specifies the cell range containing the dependent variable in the source data.
Both X and Y ranges have labels
Specifies whether the ranges above include data labels.
Results to
Defines the top-left cell of the results area. When the tool is executed, the regression
analysis table will begin at this specified cell. Note that Calc will overwrite any existing
data within the range occupied by the generated table.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Linear Regression
Select this option to use linear regression. Linear regression finds a linear function in the
form of y = b + a1.[x1] + a2.[x2] + a3.[x3] ..., where ai is the i-th slope, [xi] is the i-th
independent variable, and b is the intercept that best fits the data.
Logarithmic Regression
Select this option to use logarithmic regression. Logarithmic regression finds a
logarithmic curve in the form of y = b + a1.ln[x1] + a2.ln[x2] + a3.ln[x3] ..., where ai is the
i-th coefficient, b is the intercept and ln[xi] is the natural logarithm of the i-th independent
variable, that best fits the data.
Power Regression
Select this option to use power regression. Power regression finds a power curve in the
form of y = exp(b + a1.ln[x1] + a2.ln[x2] + a3.ln[x3] ...), where ai is the i-th power, [xi] is
the i-th independent variable, and b is intercept that best fits the data.
Confidence level
Specifies the confidence level, which is a value between 0 and 1. The default value is
0.95. Calc uses this percentage to compute the corresponding confidence intervals for
each of the estimates (namely the slopes and intercept)
Calculate residuals
Select whether to opt in or out of computing the residuals, which may be beneficial in
cases where you are interested only in the slopes and intercept estimates and their
statistics. The residuals give information on how far the actual data points deviate from
the predicted data points, based on the regression model.
Force intercept to be zero
Specifies whether to force the regression intercept to be 0.

Tip
Calc utilizes the small, otherwise blank area above the Help, OK, and Cancel
buttons to provide feedback on erroneous selections on the dialog. For example, the
text “Independent variable(s) range is not valid.” appears if a valid cell range has not
been entered in the Independent variable(s) (X) range field. In this circumstance, the
OK button is disabled until the error is corrected.
To illustrate how to use this tool, we use the data set shown in Figure 399. This table contains
measurements taken at 1 second intervals. Figure 400 shows the regression outputs calculated
for this input data using the settings shown in Figure 398.

Chapter 11 Data Analysis | 391


Tip
For more information on regression analysis, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Regression_analysis.

Figure 399: Input data set for regression analysis

Figure 400: Linear regression outputs

392 |Calc Guide 24.8


Paired t-test tool
Selecting Data > Statistics > Paired t-test on the Menu bar opens the Paired t-test dialog
(Figure 401).This tool compares the population means of two related sample sets and
determines the difference between them.
Variable 1 range
Specifies the cell range containing the first set of input data.
Variable 2 range
Specifies the cell range containing the second set of input data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the
paired t-test table starting at this cell. Be careful, Calc will replace any data that is in the
range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Figure 401: Paired t-test dialog


To provide an example of using this tool, we make use of the input data set shown in Figure 402.
The data sets in columns A and B represent two sets of paired values referred to as Variable 1
and Variable 2.

Figure 402: Input data for paired t-test example


Figure 403 shows the paired t-test results calculated for this input data using the settings shown
in Figure 401.
In the resulting table, it is possible to insert different values for Alpha and Hypothesized Mean
Difference. The t values (Stat, Critical one-tail, and Critical two-tail) will be updated automatically.

Chapter 11 Data Analysis | 393


Tip
For more information on paired t-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/Student's_t-test.

Figure 403: Results from Paired t-test tool

F-test tool
Clicking Data > Statistics > F-test on the Menu bar opens the F-test dialog shown in Figure 404
and define the required inputs to the tool.This tool calculates the F-test of two data samples to
test the hypothesis that the variance of two populations are equal.

Figure 404: F-test dialog


Variable 1 range
Specifies the cell range containing the first set of input data.
Variable 2 range
Specifies the cell range containing the second set of input data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the F-
test table starting at this cell. Be careful, Calc will replace any data that is in the range of
the table to be created.

394 |Calc Guide 24.8


Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
To illustrate how to use this tool, we again use the data set from Figure 402. In this case, the
data in columns A and B represent two independent sample sets, referred to as Variable 1 and
Variable 2. Figure 405 shows the F-test results calculated for this input data using the settings
shown in Figure 404.
In the resulting table, it is possible to insert different values for Alpha. The F Critical values (right-
tail, left-tail, and two-tail) will be updated automatically.

Tip
For more information on F-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/F-test.

Figure 405: Results from F-test tool

Z-test tool
Clicking Data > Statistics > Z-test on the Menu bar opens the Z-test dialog shown in Figure 406
and define the required inputs to the tool.This tool calculates the Z-test of two data samples. It
performs a two sample Z-test to test the null hypothesis that there is no difference between the
means of the two data sets. The Z-test works better than the Paired t-test tool for large samples
(n > 30).
Variable 1 range
Specifies the cell range containing the first set of input data.
Variable 2 range
Specifies the cell range containing the second set of input data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the Z-
test table starting at this cell. Be careful, Calc will replace any data that is in the range of
the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Chapter 11 Data Analysis | 395


Figure 406: z-test dialog
To provide an example of using this tool, we again make use of the input data set shown in
Figure 402. In this case the data in columns A and B represent two data sets, referred to as
Variable 1 and Variable 2. Figure 407 shows the Z-test results calculated for this input data using
the settings shown in Figure 406.

Figure 407: Results from Z-test tool


For the Z-test tool to work properly, a known variance for each sample must be inserted in the
related cell. In the example shown in Figure 407, the variances (125.076923 and 94.435897)
were inserted using the formula =VAR(A1:A13) into cell E5 and the formula =VAR(B1:B13)
into cell F5. The subsequent z and P values will be updated automatically.
It is also possible to insert different values for Alpha (cell E2 in the example) and Hypothesized
Mean Difference (cell E3 in the example) inputs. As with the known variances changes described
above, after changing the Alpha and the Hypothesized Mean Difference, the subsequent z and P
values will be updated automatically.

Tip
When analyzing the Z-test results, compare the selected Alpha level with the
appropriate calculated P value (depending whether a one-tailed or two-tailed test is
required). If the calculated P value is smaller than the Alpha level, the hypothesis
(which, in the example given, is that the means of the two data sets are the same)
should be rejected.

396 |Calc Guide 24.8


Tip
For more information on z-tests, refer to the corresponding Wikipedia article at
https://en.wikipedia.org/wiki/Z-test.

Chi-Square Test tool (Test of Independence)


Selecting Data > Statistics > Chi-square Test on the Menu bar opens the Test of
Independence (Chi-Square) dialog shown below. This tool calculates the chi-square test of a
data sample, which determines how well a set of measured values fit a corresponding set of
expected values.
Input range
Specifies the cell range containing the source data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the
Chi-square table starting at this cell. Be careful, Calc will replace any data that is in the
range of the table to be created.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Figure 408: Test of Independence (Chi-Square) dialog


To provide an example of using this tool, we again make use of the input data set shown in
Figure 402. In this case the data in column A is the observed data while the data in column B are
the corresponding expected values. Figure 409 shows the chi-square results calculated for this
input data using the settings shown in Figure 402.

Figure 409: Results of chi-square test


In the resulting table, it is possible to insert different values for Alpha. The Critical Value will be
updated automatically.

Tip
For more information on chi-square tests, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Chi-squared_test.

Chapter 11 Data Analysis | 397


Fourier Analysis tool
Selecting Data > Statistics > Fourier Analysis on the Menu bar opens the Fourier Analysis
dialog (Figure 410).This tool performs the Fourier analysis of a data set by computing the
Discrete Fourier Transform (DFT) of an input array of complex numbers, using Fast Fourier
Transform (FFT) algorithms.

Figure 410: Fourier Analysis dialog


Input range
Specifies the cell range containing the source data. Usually a 2 x N or N x 2 range
representing an array of complex numbers to be transformed, where N is the length of
the array. The array contains the real and imaginary parts of the data.
Results to
Specifies the top left cell of the results area. When you run the tool, it will generate the
Fourier transform table starting at this cell. Be careful, Calc will replace any data that is in
the range of the table to be created.
Input range has label
Specifies whether the first row or column of the input array is a label and not part of the
data to be analyzed.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
Inverse
If ticked, the tool calculates an inverse Discrete Fourier Transform.
Output in polar form
If ticked, the tool outputs the results in polar coordinates (that is, magnitude and phase).
Minimum magnitude for polar form output
This option is only relevant when you select to output results in polar form. All frequency
components with magnitude less than the specified value in decibels will be suppressed
with a zero magnitude-phase entry. This is useful when looking at the magnitude-phase
spectrum of a signal because there is always some tiny rounding error when performing
FFT algorithms, which results in incorrect non-zero phase for non-existent frequencies.

398 |Calc Guide 24.8


By providing a suitable value to this parameter, these non-existent frequency
components can be suppressed.

Tip
Calc utilizes the small, otherwise blank area above the Help, OK, and Cancel
buttons to provide feedback on erroneous selections on the dialog. For example, the
text “Output address is not valid.” appears if a valid cell range has not been entered
in the Results to field. In this circumstance, the OK button is disabled until the error is
corrected.
To provide an example of using this tool, we make use of the input data set shown in columns B
(real values) and C (imaginary values) of the spreadsheet shown in Figure 411. The data shown
in columns E (real values) and F (imaginary values) of the spreadsheet are the Fourier transform
results calculated by the tool for this input data, using the settings shown in Figure 410.

Note
The Fourier Analysis tool uses different algorithms depending on the length of the
input sequence. If the sequence length is an even power of 2, a radix-2 decimation-
in-time FFT algorithm is applied. For sequences of other lengths, Bluestein’s FFT
algorithm is used. This detail may be of interest to those with a technical background
in algorithms.

Tip
For more information on Fourier analysis, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Fourier_analysis.

Chapter 11 Data Analysis | 399


Figure 411: Fourier analysis tool - example input data and results

400 |Calc Guide 24.8


Calc Guide 24.8

Chapter 12
Linking Data
Sharing data in and out of Calc
Using multiple sheets
Why use multiple sheets?
Chapter 1, Introduction, introduced the concept of multiple sheets in a spreadsheet. Multiple
sheets help keep information organized; once you link those sheets together, you unleash the
full power of Calc. Consider this case:
John is having trouble keeping track of his personal finances. He has several bank
accounts and the information is scattered and disorganized. He can’t get a good grasp on
his finances until he can see everything at once.
To resolve this, John decides to track his finances in LibreOffice Calc. John knows Calc can
do simple mathematical computations to help him keep a running tab of his accounts, and
he wants to set up a summary sheet so that he can see all of his account balances at once.

Note
For users with experience of using Microsoft Excel: what Excel calls a workbook,
Calc calls a spreadsheet (the whole document). Both Excel and Calc use the terms
sheet and worksheet.

Setting up multiple sheets


Chapter 1, Introduction, gives a detailed explanation of how to set up multiple sheets in a
spreadsheet. Here is a quick review.

Identifying sheets
When you open a new spreadsheet it has, by default, one sheet named Sheet1. You can specify
a different number of sheets to be created in a new document, or a different prefix name for new
sheets, by going to Tools > Options > LibreOffice Calc > Defaults on the Menu bar (Figure
412).

Figure 412: Options > LibreOffice Calc > Defaults dialog


Sheets in Calc are managed using tabs located at the bottom of the spreadsheet.

402 |Calc Guide 24.8


Inserting new sheets
There are several ways to insert a new sheet. The fastest method is to click on the Add Sheet
(+) icon located to the left of the sheet tabs, at the bottom of the spreadsheet. This inserts one
new sheet without opening any dialog, with a default name (Sheet2, for example) and with the
new sheet’s tab positioned at the right hand end of the sheet tabs.
Use one of these other methods to insert more than one sheet, to rename the sheet at the same
time, or to insert the sheet somewhere else in the sequence.
• Left-click a sheet tab and select Sheet > Insert Sheet on the Menu bar. Calc displays
the Insert Sheet dialog with the Before current sheet and New sheet options
preselected.
• Select Sheet > Insert Sheet at End on the Menu bar. Calc displays the Append Sheet
dialog.
• Select Sheet > Insert Sheet from File on the Menu bar. Calc displays the Insert Sheet
dialog with the Before current sheet and From file options preselected. Click on the
Browse button to open a file browser dialog to enable you to select the source file
containing the sheet to be inserted.
• Right-click on a sheet tab and select Insert Sheet in the context menu (Figure 413). Calc
displays the Insert Sheet dialog with the Before current sheet and New sheet options
preselected.
• Right-click in the empty space at the right end of the line of sheet tabs and select Insert
Sheet in the context menu (Figure 413). Calc displays the Insert Sheet dialog with the
Before current sheet and New sheet options preselected.

Figure 413: Creating a new sheet through the sheet tabs area
The above methods use either the Insert Sheet dialog (Figure 414) or the Append Sheet dialog
(Figure 415).
On the Insert Sheet dialog, you can:
• Choose whether to put the new sheet before or after the currently selected sheet tab.
• Choose how many sheets to insert.
• Choose the name for a single sheet (the Name field is unavailable if more than one
sheet is to be inserted).
The From file option is described in “Inserting sheets from a different spreadsheet” below.

Chapter 12 Linking Data | 403


Figure 414: Insert Sheet dialog

Figure 415: Append Sheet dialog


For John’s spreadsheet we need six sheets, one for each of his five accounts and one as a
summary sheet. We also want to name each of these sheets for the account they represent:
Summary, Checking Account, Savings Account, Credit Card 1, Credit Card 2, and Car Loan.
After creating a new spreadsheet with one sheet, we could:
• Insert five new sheets and rename all six sheets afterwards
• Rename the existing sheet, then insert the five new sheets one at a time, renaming each
new sheet during the insert step.
To insert sheets and rename them afterwards:
1) Make sure that the correct sheet tab is selected and open the Insert Sheet dialog.
2) Choose the position for the new sheets (in this example, we use After current sheet).
3) Choose New sheet and enter 5 after No. of sheets:. Because you are inserting more
than one sheet, the Name box is not available.
4) Click OK to insert the sheets.
For the subsequent steps to rename the sheets, see “Renaming sheets” (below).
To insert sheets and name them at the same time:
1) Rename the existing sheet as Summary, as described in “Renaming sheets” (below).
2) Make sure that the correct sheet tab is selected and open the Insert Sheet dialog.

404 |Calc Guide 24.8


3) Choose the sheet tab position for the new sheet (Before current sheet or After current
sheet, as applicable).
4) Choose New sheet and enter 1 in the No. of sheets field. The Name box is now
available.
5) In the Name box, type a name for this new sheet, for example Checking Account.
6) Click OK to insert the sheet.
7) Repeat steps 2) to 6) for each new sheet, giving them the names Savings Account,
Credit Card 1, Credit Card 2, and Car Loan.

Inserting sheets from a different spreadsheet


On the Insert Sheet dialog, you can also add a sheet from a different spreadsheet (for example,
another Calc or Microsoft Excel file), by choosing the From file option. Click Browse, select the
file using the file browser dialog, and click Open. A list of the available sheets in that file appears
in the adjacent list box (Figure 416). Select the sheet to import (you can only import one at a
time). If, after you select the file, no sheets appear, you probably selected an invalid file type (not
a spreadsheet, for example).

Figure 416: From file area of Insert Sheet dialog, with file path and available sheet names
If you prefer, select the Link option to insert the external sheet as a link instead of as a copy.
This is one of several ways to include “live” data from another spreadsheet – see also “Linking to
external data” (below). The links can be updated manually to show the current contents of the
external file using Edit > Links to External Files on the Menu bar. Alternatively the links can be
updated automatically whenever the file is opened, depending on the options set on the dialog
accessed by selecting Tools > Options > LibreOffice Calc > General on the Menu bar. The
three options available in the Update links when opening section are Always (from trusted
locations), On request, and Never.
To define trusted file locations, select Tools > Options > LibreOffice > Security > Macro
Security (Trusted Sources tab) on the Menu bar. This is useful if you want to use macros in your
spreadsheet. For more information about macros see Chapter 143, Macros.

Renaming sheets
Sheets can be renamed at any time. To give a sheet a more meaningful name:
• Enter the name in the Name box when you create the sheet.
• Double-click on the relevant sheet tab and replace the existing name through the
Rename Sheet dialog (Figure 417).
• Right-click on the relevant sheet tab, select Rename Sheet in the context menu, and
replace the existing name through the Rename Sheet dialog.
• Left-click on the relevant sheet tab to select it, select Sheet > Rename Sheet on the
Menu bar, and replace the existing name through the Rename Sheet dialog.

Chapter 12 Linking Data | 405


Figure 417: Rename Sheet dialog
A sheet name cannot be empty and must not be a duplicate of an existing name.

Note
The following characters are not allowed in sheet names: colon (:), back slash (\),
forward slash (/), question mark (?), asterisk (*), left square bracket ([), right square
bracket (]). The apostrophe (') character is not allowed as the first or last character of
the name.

Tip
In some LibreOffice Calc installations you can hold down the Alt key, click on the
sheet name, and enter the new name directly.
Your sheet tab area should now look like this.

Figure 418: Six renamed sheets


Now we will set up the account ledgers. This is just a simple summary that includes the previous
balance plus the amount of the current transaction. For withdrawals, we enter the current
transaction as a negative number so the balance gets smaller. A basic ledger is shown in Figure
419.
This ledger is set up in the sheet named Checking Account. The total balance is added up in cell
F3. You can see the equation for it in the Formula bar. It is the summary of the opening balance,
cell C3, and all of the subsequent transactions.

Figure 419: Checking ledger

406 |Calc Guide 24.8


Referencing other sheets
On the Summary sheet we display the balance from each of the other sheets. If you copy the
example in Figure 419 onto each of the five account sheets, the current balances will be in cell
F3 of each sheet.
There are two ways to reference cells in other sheets: by entering the formula directly using the
keyboard or by using the mouse.

Creating the reference with the mouse


On the Summary sheet, set up a place for all five account balances, so we know where to put
the cell reference. Figure 420 shows the Summary sheet with a blank Balance column. We want
to place the reference for the Checking Account balance in cell B3.

Figure 420: Blank Summary sheet


To make the cell reference in cell B3, select the cell and follow these steps:
1) Click on the = icon next to the Input line on the Formula bar. The icons on the Formula
bar change and an equals character appears in the Input line (Figure 421).

Figure 421: Equals character in Input line of Formula bar


2) Now, click on the sheet tab for the sheet containing the cell to be referenced. In this
case, that is the Checking Account sheet (Figure 422).

Figure 422: Click on the Checking Account sheet tab


3) Click on cell F3 (where the balance is) in the Checking Account sheet. The phrase
$'Checking Account'.F3 should appear in the Input line (Figure 423) and the selected
cell is surrounded by a colored border.

Chapter 12 Linking Data | 407


Figure 423: Cell reference selected
4) Click the Accept icon in the Input line of the Formula bar, or press the Enter key to
finish.
5) The Summary sheet should now look like Figure 424.

Figure 424: Finished Checking Account reference

Creating the reference with the keyboard


From Figure 424, you can deduce how the cell reference is constructed. The reference has two
parts: the sheet name prefixed by a dollar symbol ($'Checking Account'), and the cell
reference (F3). Notice that they are separated by a period. The default behavior of Calc is to
insert the dollar symbol to form an absolute sheet reference while giving a relative cell reference.

Note
The sheet name is in single quotation marks because it contains a space, and the
mandatory period (.) always falls outside any quotation marks.
So, you can fill in the Savings Account cell reference by just typing it in. Assuming that the
balance is in the same cell (F3) in the Savings Account sheet, the cell reference should be
=$'Savings Account'.F3 (Figure 425).

Figure 425: Savings Account cell reference

408 |Calc Guide 24.8


Protect spreadsheet structure
When you are satisfied with the structure of your spreadsheet in terms of its constituent sheets,
select Tools > Protect Spreadsheet Structure on the Menu bar to lock that structure. Calc
displays the Protect Spreadsheet Structure dialog (Figure 426). Press OK to inhibit the addition,
deletion, repositioning, and renaming of sheets. To subsequently unlock the structure, select
Tools > Protect Spreadsheet Structure again.

Figure 426: Protect Spreadsheet Structure dialog

Referencing other documents


John decides to keep his family account information in a different spreadsheet file from his own
summary. Fortunately Calc can link different files together. The process is the same as described
for different sheets in a single spreadsheet, but we add one more step to indicate which file the
sheet is in.

Creating the reference with the mouse


To create the reference with the mouse, both spreadsheets need to be open.
1) If necessary, switch to the spreadsheet containing the cell in which the formula is going
to be entered.
2) Select the cell in which the formula is going to be entered.
3) Click the = icon next to the Input line in the Formula bar.
4) Switch to the other spreadsheet (the process to do this may vary depending on which
operating system you are using).
5) Select the sheet (Savings Account) and then the reference cell (F3); see Figure 427. You
can press the keyboard Enter key at this point, or continue with steps 6) and 7).

Figure 427: Selecting the Savings Account reference cell


6) Switch back to the original spreadsheet.

Chapter 12 Linking Data | 409


7) Click the Accept icon in the Formula bar.
Your spreadsheet should now resemble Figure 428.
You will get a good feel for the format of the reference if you look closely at the Input line in the
Formula bar. Based on the contents of this line, you can create the reference using the
keyboard.

Figure 428: Linked files

Creating the reference with the keyboard


Typing the reference is simple once you know the format the reference takes. The reference has
three parts to it:
• Path and file name
• Sheet name
• Cell reference
In Figure 428, you can see that the general format for the reference is:
='file:///Path & File Name'#$'SheetName'.CellReference

Note
The reference for a file has three forward slashes ///, while the reference for a
hyperlink has two forward slashes //. See “Using hyperlinks and URLs” below.

Using hyperlinks and URLs


Hyperlinks can be used in Calc to jump to a different location from within a spreadsheet and can
lead to other parts of the current file, to different files, or even to web pages.

Relative and absolute hyperlinks


Hyperlinks stored within a file can be either relative or absolute.
A relative hyperlink says, Here is how to get there starting from where you are now (meaning
from the folder in which your current document is saved), while an absolute hyperlink says, Here
is how to get there no matter where you start from.
An absolute link will stop working if the target is moved. A relative link will stop working if the
start and target locations change relative to each other. For instance, if you have two
spreadsheets in the same folder linked to each other and you move the entire folder to a new
location, an absolute hyperlink will break but a relative one will not.
To change the way that Calc stores the hyperlinks in your file, select Tools > Options >
Load/Save > General and in the Save area of the dialog, choose if you want URLs (Universal
Resource Locators) saved relatively when referencing the file system, or the Internet, or both.
An absolute path such as c:\homepage\graphics\picture.gif would no longer function on a web
server. Operating systems such as Unix or macOS do not recognize drive letters, and even if the
folder homepage\graphics existed, your picture would not be available. It is better to use relative

410 |Calc Guide 24.8


linking for file links. Relative linking is only possible when the document you are working on is on
the same drive as the link destination.
Calc will always display an absolute hyperlink. Do not be alarmed when it does this even when
you have saved a relative hyperlink. This ‘absolute’ target address will be updated if you move
the file.

Note
HTML (Hypertext Markup Language) files containing links as relative to the file
system that are to be uploaded to a web server require the files be in a file structure
matching that of the web server. Otherwise, the links will point to the wrong folder.

Tip
When you rest the mouse pointer on a hyperlink, a help tip displays the absolute
reference, because Calc uses absolute path names internally. The complete path
and address can only be seen when you view the result of the HTML export (saving
a spreadsheet as an HTML file), by loading the HTML file as text, or by opening it
with a text editor.

Creating hyperlinks
You can insert a hyperlink into a Calc spreadsheet using one of these methods:
• Select the cell or text within a cell that you want to use for your hyperlink text, or place
the text cursor at the point where you want to insert a hyperlink. Select Insert >
Hyperlink on the Menu bar, or click the Insert Hyperlink icon on the Standard toolbar,
or press Ctrl+K, to access the Hyperlink dialog; see “Hyperlink dialog” below.
• Drag-and-drop an item from the Navigator to the point where you want to insert the
hyperlink (for example, a sheet or cell name).
• Type the target web address or URL at the point where you want to insert the hyperlink.
When you type text that can be used as a hyperlink (such as a website address or URL),
Calc formats it automatically, creating the hyperlink and applying color to the text. If this
does not happen, you can enable this feature using Tools > AutoCorrect Options >
Options on the Menu bar and selecting URL Recognition. Make sure you start the
hyperlink with http://, ftp or www.; if you type only libreoffice.org for example,
Calc will not recognize it as a hyperlink.
When you use the Hyperlink dialog to insert a hyperlink, you can select either a text hyperlink
(Figure 429) or a button hyperlink (Figure 430). In both cases, the visible text can be different
from the linked URL.

Figure 429: Example text hyperlink

Chapter 12 Linking Data | 411


Figure 430: Example button hyperlink
To change the color of text hyperlinks, go to Tools > Options > LibreOffice > Application
Colors on the Menu bar, scroll to Unvisited links and/or Visited links, pick the new colors, and
click OK.

Note
This will change the color for all hyperlinks in all components of LibreOffice, which
may not be what you want.
A button hyperlink is a type of form control. As with all form controls, it can be anchored or
positioned by right-clicking on the button in design mode. More information about forms can be
found in the Writer Guide.

Opening hyperlinks
To open a text hyperlink, do one of the following:
• Ctrl-click with the mouse pointer positioned over the hyperlink. This method only works if
the Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is selected.
• Left-click with the mouse pointer positioned over the hyperlink. This method only works if
the Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is not selected.
• Right-click with the mouse pointer positioned over the hyperlink and select the Open
Hyperlink option in the context menu.
To open a button hyperlink, left-click the button. This method only works when the form design
mode is deactivated; the status of this mode is controlled by clicking the Design Mode button on
either the Form Controls toolbar or the Form Design toolbar.

Hyperlink dialog
You can insert and modify hyperlinks using the Hyperlink dialog (Figure 431). To display this
dialog, choose Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink icon on the
Standard toolbar, or press Ctrl+K.
On the left side of the dialog, select one of the four categories of hyperlink:
• Internet. The hyperlink points to a web address or Uniform Resource Locator (URL).
• Mail. The hyperlink points to an email address.
• Document. The hyperlink points to a location in either the current document or another
existing document.
• New Document. Opening the hyperlink creates a new document.

412 |Calc Guide 24.8


Figure 431: Hyperlink dialog showing details for the Internet category
Figure 431 shows the Hyperlink dialog with the Internet category and the Web hyperlink type
selected.
The Further Settings area is provided for all four hyperlink categories. The controls above the
Further Settings area vary dependent on which of the four hyperlink categories is selected on
the left side of the dialog.
A full description of all the choices and their interactions is beyond the scope of this chapter. The
following is a summary of the most common choices used in Calc spreadsheets.
Internet
– URL. Enter the required web address.
– Text. Text specifies the text that will be visible to the user. If you do not enter anything
here, Calc will use the full URL or path as the link text. Note that if the link is relative
and you move the file, this text will not change, though the target will.
Mail
For Mail hyperlinks, the controls above the Further Settings area change to those shown
in Figure 432.
– Recipient. Enter the email address of the recipient, or select the address from an
existing database accessed by clicking the Data Sources button.
– Subject. Enter the text to be used as the subject line of the message.
The Text field (shown in the Hyperlink Type area in Figure 431 and Figure 432, is
provided within the Further Settings area for Mail, Document, and New Document
hyperlinks. Its function for these hyperlinks is as described above for Internet hyperlinks.
The Mail hyperlink only works if a mail client is installed.

Chapter 12 Linking Data | 413


Figure 432: Mail controls on the Hyperlink dialog
Document
For document hyperlinks, the controls above the Further Settings area change to those
shown in Figure 433.
– Path. Specify the path of the file to be opened. Leave this blank if you want to link to a
target in the same spreadsheet. The Open File icon opens a file browser for you to
locate the document to be opened.
– Target. Optionally specify the target in the document (for example a specific sheet).
Click on the Target in Document icon to open a Navigator window where you can
select the target, or if you know the name of the target, you can type it into the box.

Figure 433: Document controls on the Hyperlink dialog


New Document
For New Document hyperlinks, the controls above the Further Settings area change to
those shown in Figure 434.
– Edit now / Edit later. Specify whether to edit the newly created document immediately
or just create it.
– File. Enter the name of the file to be created. The Select Path icon opens a directory
picker dialog.
– File type. Select the type of document to be created (for example, text document,
spreadsheet, or drawing).

414 |Calc Guide 24.8


Figure 434: New Document controls on the Hyperlink dialog
The Further Settings section on the Hyperlink dialog is common to all the hyperlink categories,
although some choices are more relevant to some types of links and the Text option is omitted
from this area for Internet hyperlinks.
• Set the value of Frame to determine how the hyperlink will open. This applies to
documents that open in a web browser. Options are _top, _parent, _blank, and _self.
• Form specifies if the link is to be presented as text or as a button.
• Text specifies the text that will be visible to the user. If this is left blank, Calc will use the
full URL or path as the link text. Note that if the link is relative and you move the file, this
text will not change, though the target will.
• Name is applicable to HTML documents. It specifies text that will be added as a NAME
attribute in the HTML code behind the hyperlink.
• Events button: opens the Assign Macro dialog. Select a macro to run when the link is
clicked. This function is not covered further in this chapter.

Editing hyperlinks
To edit an existing text hyperlink, do any of the following:
• If the Tools > Options > LibreOffice > Security > Security Options and Warnings >
Options > Ctrl-click required to open hyperlinks option is selected, then click the cell
containing the hyperlink. Select Insert > Hyperlink on the Menu bar, or click the Insert
Hyperlink icon on the Standard toolbar, or press Ctrl+K.
• Select the cell containing the hyperlink. In some cases you may need to select a nearby
cell that does not contain a hyperlink and use the arrow keys to move the selection to the
hyperlink cell. Select Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink
icon on the Standard toolbar, or press Ctrl+K.
• Right-click on the hyperlink and select the Edit Hyperlink option in the context menu.
In all cases, Calc opens the Hyperlink dialog, where you can modify the characteristics of the
hyperlink.
For a button hyperlink, the spreadsheet must have the form design mode enabled in order to edit
the hyperlink. With the button selected, select Insert > Hyperlink on the Menu bar, or click the
Insert Hyperlink icon on the Standard toolbar, or press Ctrl+K. Make your changes and click
OK.
If you need to edit several hyperlinks, you can leave the Hyperlink dialog open until you have
edited all of them. Be sure to click Apply after each one. When you are finished, click Close.

Chapter 12 Linking Data | 415


You can also edit a button hyperlink by selecting the button (with form design mode enabled),
right-clicking, and selecting Control Properties in the context menu. Calc displays the
Properties dialog. Modify the button text by editing the Label field and modify the link address by
editing the URL field. Note that the Properties dialog do not contain an OK button, so after
executing the desired changes, just close the dialog.

Removing hyperlinks
To remove a text or button hyperlink from the document completely, select it and use one of the
many available deletion mechanisms (for example, select Edit > Cut on the Menu bar or Cut on
the Standard toolbar; or right-click on the hyperlink and select Cut in the context menu; or press
Backspace or Delete on the keyboard).

Linking to external data


You can insert data from another document into a Calc spreadsheet as a link.
Two methods are described in this section: using the External Data dialog and using the
Navigator. If your file has named ranges, database ranges, or named tables, and you know the
name of the range or table you want to link to, using the External Data dialog is quick and easy.
However, if the file has several ranges and tables, and you want to pick only one of them, you
may not be able to easily determine which is which; in that case, the Navigator method may be
easier.
Calc provides other methods for including linked data from external sources, see for example
“Linking to registered data sources” (below) and “Dynamic Data Exchange (DDE)” (below).

Note
When you open a file that contains links to external data, depending on your settings
you may be prompted to update the links or they may be updated automatically.
Depending on where the linked files are stored, the update process can take several
minutes to complete.

Using the External Data dialog


The External Data dialog inserts data from an HTML, Calc, CSV (Comma-Separated Values), or
Microsoft Excel file into the current sheet as a link. Calc utilizes a Web Page Query import filter,
enabling you to insert tables from HTML documents.
To insert a link to external data using the External Data dialog:
1) Open the Calc document where the external data is to be inserted. This is the target
document.
2) Select the cell where the upper left cell of the external data is to be inserted.
3) Choose Sheet > External Links on the Menu bar. Calc displays the External Data dialog
(Figure 435).
4) Type the URL of a web resource that is to be used as a data source, or type the address
of a source file, or select an entry in the drop-down list, or select a source file from the
file selection dialog accessed through the Browse button. For entries typed in, press
Enter on completion.
5) If you selected a HTML file as the data source at step 4), Calc displays the Import
Options dialog (Figure 437). On this dialog you can choose the import language of the
site. Select Automatic to let Calc import the data directly, or select Custom and choose

416 |Calc Guide 24.8


from the drop-down list of languages available. You can also select the option to have
Calc recognize special numbers, such as dates, on import.

Figure 435: External Data dialog


d) Click OK on the Import Options dialog. Calc loads the list of available tables/ranges
into the Available Tables/Ranges area of the External Data dialog. The Web Page
Query import filter can create names for cell ranges as they are imported. As much
formatting as possible is retained while the filter intentionally does not import any
images. The filter additionally creates two additional entries in the list: HTML_all to
permit selection of the entire document and HTML_tables to permit selection of all the
tables. Where a HTML table has a caption element, the text of the caption is appended
to the associated entry in the list of available tables and ranges (Figure 436) and this
helps identify a table of interest when there are many listed.

Figure 436: External Data dialog, with table captions


e) In the Available Tables/Ranges area, select the named ranges or tables you want to
insert (hold Ctrl to select multiple entries). The OK button then becomes available.

Chapter 12 Linking Data | 417


Figure 437: Import Options dialog
6) If you selected a CSV file as the data source at step 4), Calc displays the Text Import
dialog (Figure 438). This dialog is described in detail in Chapter 1, Introduction. Click OK
on the Text Import dialog and select CSV_all in the Available Tables/Ranges area of the
External Data dialog. The OK button then becomes available.

Figure 438: Text import dialog


7) If you selected a Calc or Microsoft Excel file as the data source at step 4), Calc
populates the Available Tables/Ranges area of the External Data dialog with the list of
range names and database ranges that are defined in the source file. Select the range

418 |Calc Guide 24.8


names and database ranges that you want to insert (hold Ctrl to select multiple entries)
and the OK button then becomes available.

Note
If the source Calc or Microsoft Excel spreadsheet contains no range names or
database ranges, then you cannot use that document as the source file in the
External Data dialog.
8) For all external data source file types, you can also specify that the data is refreshed at a
specific frequency, defined in seconds.
9) Click OK to close the External Data dialog and insert the linked data.
Calc adds the new entry to the Linked areas list in the Navigator (Figure 440). If you double-click
this entry, Calc highlights the linked data within the sheet. When you hover the mouse pointer
over the entry, a tooltip indicates the file location of the linked data.
To view a list of all external data links in the spreadsheet, select Edit > Links to External Files
on the Menu bar. Calc displays the Edit Links dialog (Figure 439).

Figure 439: Edit Links dialog

Figure 440: Linked areas in the Navigator

Chapter 12 Linking Data | 419


Note
The Edit Links dialog can display information about other links that were not created
using the External Data dialog.
For links that have been created using the External Data dialog, you can access that dialog
again by selecting the link on the Edit Links dialog and clicking the Modify button, or double-
clicking the link. If you click Break Link and confirm that you want to remove the selected link,
the previously-linked data becomes embedded in the spreadsheet. Click Update to refresh the
linked data in the target file so that it matches that in the source file.

Note
The Status column on the Edit Links dialog always shows Manual for a link created
using the External Data dialog. The status shown in this column does not reflect the
setting of the Update every … seconds option on the External Data dialog.

Using the Navigator


You can also use the Navigator dialog or the Navigator deck of the Sidebar to link external data.
Access the Navigator dialog by selecting View > Navigator on the Menu bar, or pressing F5.
See Chapter 1, Introduction, for more details about the Navigator.
To insert a link to external data using the Navigator:
1) Open the Calc spreadsheet in which the external data is to be inserted (target
document).
2) Open the document from which the external data is to be taken (source document) in
Calc. The source document does not need to be a Calc file; it could, for example, be a
Microsoft Excel file, an HTML file, or a CSV file. In the case of a HTML file, Calc displays
the Import Options dialog (Figure 437) before opening the file.
3) In the target document, open the Navigator (Figure 441). This illustration shows the
Navigator for a new file called Untitled 1, which currently has no range names, database
ranges, or linked areas.

Figure 441: Navigator for target file


4) At the bottom of the Navigator, select the source document in the drop-down menu
(Figure 442). In this case the source is called summary-indices-constituents and the file

420 |Calc Guide 24.8


contains three range names which are highlighted with a red box. You may need to click
the + icon at the left of the Range names field to view the names.

Figure 442: Navigator for source file


5) In the Navigator, select the Insert as Link option in the Drag Mode menu, as shown in
Figure 443.
You can also change the drag mode by right-clicking on a range name and selecting the required
option in the context menu.

Tip
The graphic on the Drag Mode icon on the Navigator changes to reflect the currently
selected drag mode.

Figure 443: Select Insert as Link from Drag Mode menu

Chapter 12 Linking Data | 421


6) Select the required Range names or Database ranges entry and drag it from the
Navigator into the target document, to the cell where you want the upper left cell of the
data range to be.
7) Re-select the target document in the drop-down menu at the bottom of the Navigator.
Instead of a + icon next to Range names, it shows a + icon next to Linked areas. Click
the + icon to see the entry dragged across from the source document, similar to Figure
440.

How to find the required data range or table


Calc’s Web Page Query import filter displays the data ranges (tables) in source order from the
web page. It also creates two additional range names:
• HTML_all – designates the entire document
• HTML_tables – designates all HTML tables in the document
If any of the data tables in the source HTML document have been given meaningful names
(using the ID attribute on the TABLE tag), those names appear in the Range names list, along
with the ranges Calc has sequentially numbered.
If the data range or table you want is not meaningfully named, how can you tell which one to
select?
Go to the source document, which you opened in Calc. In the Navigator, double-click on a range
name: that range is highlighted on the sheet. The example in Figure 444 shows a table of best-
selling albums of recorded music by year worldwide and was extracted from Wikipedia’s List of
best-selling albums page (https://en.wikipedia.org/wiki/List_of_best-selling_albums).

Figure 444: Using the Navigator to find a data range name


If the Formula bar is visible, the range name is also displayed in the Name Box at the left end
(Figure 445). The range name can be selected in the drop-down list to highlight it on the page.

422 |Calc Guide 24.8


Figure 445: Using the Name Box to find a data range name

Linking to registered data sources


You can access a variety of databases and other data sources and link them into Calc
documents.
First you need to register the data source with LibreOffice. To register means to tell LibreOffice
what type of data source it is and where the file is located. The way to do this depends on
whether or not the data source is a database in *.odb format.
To register a data source that is in *.odb format:
1) Select Tools > Options > LibreOffice Base > Databases on the Menu bar. Calc
displays the dialog shown in Figure 446.

Figure 446: Options – LibreOffice Base – Databases dialog


2) Click the New button to open the Create Database Link dialog (Figure 447).

Chapter 12 Linking Data | 423


Figure 447: Create Database Link dialog
3) Enter the location of the database file, select a database file in the drop-down list, or click
Browse to open a file browser and select the database file.
4) Type a name to use as the registered name for the database and click OK. The database
is added to the list of registered databases and LibreOffice uses the registered name to
access the database.

Note
The OK button on the Create Database Link dialog is enabled only when both the
Database file and Registered name fields are filled in.
To register a data source that is not in *.odb format:
1) Choose File > New > Database on the Menu bar to open the Database Wizard (Figure
448). For more about the Database Wizard, see the Base Handbook.
2) Select Connect to an existing database and select the appropriate database type in
the drop-down menu. The choices for database type depend on your operating system.
For example, Microsoft Access and other Microsoft products are not among the choices if
you are using Linux. The example database type menu shown in Figure 448 relates to a
Windows 10 installation.

Note
The exact interactions required to connect to a database vary depending on the type
of database. Steps 3) and 4) assume that you selected dBASE at step 2).
3) Click Next. Type the path to the folder where the dBase files are stored or click Browse
and use the folder selection dialog to navigate to the relevant folder before clicking the
Select Folder button.
4) Click Next. Select Yes, register the database for me, but clear the Open the database
for editing checkbox.
5) Click Finish. Name and save the database in the location of your choice.

Note
The above steps create a *.odb format database based on the content of the original
dBASE database. The original dBASE database remains unchanged.

424 |Calc Guide 24.8


Figure 448: Database Wizard
Once a data source has been registered, it can be used by any LibreOffice component (for
example, Calc or Writer).

Viewing data sources


Open a document in Calc. To view the data sources available, select View > Data Sources on
the Menu bar, or press Ctrl+Shift+F4. Calc opens the Data Source window above the
spreadsheet.
The Data Source window has four main components:
The Table Data toolbar
• The Table Data toolbar (Figure 449) is by default located at the top of the Data Source
window.

Chapter 12 Linking Data | 425


Figure 449: Table Data toolbar
11) Save current record 21) Sort Descending
12) Edit Data 22) AutoFilter
13) Cut 23) Apply Filter
14) Copy 24) Standard Filter
15) Paste 25) Reset Filter/Sort
16) Undo 26) Data to Text
17) Find Record 27) Data to Fields
18) Refresh 28) Mail Merge
19) Sort 29) Data Source of Current Document
20) Sort Ascending 30) Explorer On/Off
The Data Source Explorer
• The Data Source Explorer (Figure 450) is by default located on the left side of the Data
Source window, below the Table Data toolbar.
• The Data Source Explorer provides a list of the registered databases, which by default
includes the built-in Bibliography database.
• To view each database, click on the expand icon to the left of the name of the database.
This has already been done for the Automobiles database in Figure 450. Click on the
expand icon left of Tables to view the individual tables within the selected database;
similarly you can click on the expand icon left of Queries to view the individual queries
within the selected database. Click on the name of a table to view all the records held in
that table.

Figure 450: Data Source Explorer


Data records for selected table
• The data records for the selected table are displayed in the area at the right side of the
Data Source window, below the Table Data toolbar.

426 |Calc Guide 24.8


Figure 451: Data Source window records
• To see more columns in this area, you can click the Explorer On/Off icon on the Table
Data toolbar to hide the Data Source Explorer. Click again to show it back.
• Below the data records is a navigation bar, which shows which record is selected and
the total number of records. This provides the following buttons, from left to right:
– First record
– Previous record
– Next record
– Last record
– Add new record
• A horizontal scroll bar appears when the available columns do not all fit in the visible
area. A vertical scroll bar appears when the available data records do not all fit in the
visible area.
Show / hide window
• At the bottom center of the Data Source window is a control to hide and show the entire
window. This control is highlighted with a red box in Figure 451.

Editing data sources


Only registered Data Sources can be edited in the Data Source window.
In editable data sources, records can be edited, added, or deleted. If you cannot save your edits,
you need to open the database in Base and edit it there; see “Launching Base to work on data
sources” below. You can also hide columns and make other changes to the display.

Launching Base to work on data sources


You can launch LibreOffice Base at any time from the Data Source Explorer. Right-click on a
database, Tables, a table name, Queries, or a query name, and then select Edit Database File
in the context menu. Once in Base, you can edit, add, and delete tables, queries, forms, and
reports.
For more about using Base, see the Getting Started Guide, or the Base Guide.

Using data sources in Calc spreadsheets


Data from a table displayed on the right side of the Data Source window can be placed into a
Calc document in a variety of ways.

Chapter 12 Linking Data | 427


You can select a single cell, a single row, or multiple rows in the Data Source window and drag
and drop the data into the spreadsheet. The data is inserted at the place where you release the
mouse button. If you selected one or more rows, Calc will also include the column headings
above the data you insert. To select the rows of data you want to add to the spreadsheet:
1) Click the gray box to the left of the first row you want to select. That row is highlighted.
2) To select multiple adjacent rows, hold down the Shift key while clicking the gray box of
the last row you need.
3) To select multiple separate rows, hold down the Control key while selecting each row.
The selected rows are highlighted.
4) To select all the rows, click the gray box in the upper left corner. All rows are highlighted.
An alternative method uses the Data to Text icon on the Table Data toolbar and will include the
column headings above the data you insert:
1) Click the cell of the spreadsheet which you want to be the top left of your data, including
the column names.
2) Select the rows of data you want to add to the spreadsheet, as described in the previous
paragraph.
3) Click the Data to Text icon in the Table Data toolbar to insert the data into the
spreadsheet cells.
You can also drag the data source column headings (field names) onto your spreadsheet to
create a form for viewing and editing individual records one at a time. Follow these steps:
1) Drag and drop the gray box at the top of the column (containing the field name you wish
to use) to where you want the record to appear in the spreadsheet.
2) Repeat step 1) until you have moved all of the fields you need to where you want them.
3) Close the Data Source window by selecting View > Data Sources on the Menu bar or
pressing Ctrl+Shift+F4.
4) Save the spreadsheet and select Edit > Edit Mode on the Menu bar, or press
Ctrl+Shift+M, to make the spreadsheet read-only.
5) Select File > Reload on the Menu bar. All of the fields will show the value for the data of
the first record of the data source that you selected.
6) Select View > Toolbars > Form Navigation to show the Form Navigation toolbar (Figure
452). By default, this toolbar opens at the bottom of the Calc window, just above the
Status bar.

428 |Calc Guide 24.8


Figure 452: Form Navigation toolbar
1) Find Record (provides access to the 10) Delete Record
Record Search dialog)
11) Refresh
2) Absolute Record (type in the number
12) Refresh Control
of the required record)
13) Sort
3) First Record
14) Sort Ascending
4) Previous Record
15) Sort Descending
5) Next Record
16) AutoFilter
6) Last Record
17) Apply Filter
7) New Record
18) Form-Based Filters
8) Save Record
19) Reset Filter/Sort
9) Undo
20) Data source as Table
7) Click the arrows on the Form Navigation toolbar to view the different records of the table.
The toolbar indicates which record is currently displayed and the total number of records
available. The current record number changes as you move through the records and the
data in the spreadsheet fields updates to correspond to the data for that particular record
number.

Embedding spreadsheets
Spreadsheets can be embedded in other LibreOffice files and vice versa. This is often used in
Writer or Impress documents so that Calc data can be used in a text document or a
presentation. You can embed the spreadsheet as either an OLE (Object Linking and Embedding)
or DDE (Dynamic Data Exchange) object. The difference between a DDE object and a Linked
OLE object is that a linked OLE object can be edited from the document in which it is added as a
link, but a DDE object cannot.
For example, if a Calc spreadsheet is pasted into a Writer document as a DDE object, then the
spreadsheet cannot be edited in the Writer document. But if the original Calc spreadsheet is
updated, the changes are automatically made in the Writer document. If the spreadsheet is
inserted as a Linked OLE object into the Writer document, then the spreadsheet can be edited in
Writer as well as in the Calc document and both documents are in sync with each other.

Object Linking and Embedding (OLE)


The major benefit of an OLE object is that it is quick and easy to edit its contents just by double-
clicking on it. You can also insert a link to the object that will appear as an icon rather than an
area showing the contents itself.
OLE objects can be linked to a target document or embedded in the target document. Linking
inserts information which will be updated with any subsequent changes to the original file, while
embedding inserts a static copy of the data. If you want to edit the embedded spreadsheet,
double-click on the object.

Chapter 12 Linking Data | 429


Note
If your OLE object is empty, inactive, and not displayed as an icon, then it will be
transparent.
To embed a spreadsheet as an OLE object in a presentation:
1) Place the cursor in the document at the location where you want the OLE object to be.
2) Select Insert > Object > OLE Object on the Menu bar. Impress opens the Insert OLE
Object dialog shown in Figure 453, with the Create new option selected by default.
3) You can either create a new OLE object or create the OLE object from an existing file.
To create a new object:
1) Select the Create new option and select the required option from those available in the
Object Type list. In this example, you would select LibreOffice 7.2 Spreadsheet.
2) Click OK.
3) LibreOffice places an empty container in the slide, ready for you to enter information. By
default the Menu bar changes to reflect the Calc Menu bar; when you click on the slide,
anywhere outside the spreadsheet area, the Menu bar reverts to the Impress Menu bar.

Figure 453: Insert OLE Object dialog with Create new option selected
After clicking outside the spreadsheet area, double-click on the OLE object to re-enter the edit
mode of the object. The application devoted to handling that type of file (Calc in our example) will
open the object.
To save the inserted spreadsheet:
1) Click anywhere outside the spreadsheet to leave the edit mode.
2) Right-click on the spreadsheet and select Save Copy as in the context menu or select
Edit > Object > Save Copy as on the Menu bar.
3) Choose the name of the new file and the folder in which it will be saved.
4) Click the Save button.

Note
If the object inserted is handled by LibreOffice, then the transition to the program to
manipulate the object will be seamless; in other cases the object opens in a new

430 |Calc Guide 24.8


window and an option in the File menu becomes available to update the object you
inserted.
To insert an existing object:
1) To create on OLE object from an existing file, select the Create from file option. The
Insert OLE Object dialog changes to that shown in Figure 454.
2) Click Search, select the required file in the file browser, and then click Open.

Note
This facility is not limited to LibreOffice files; you can create OLE objects using
existing files from many other applications.

Figure 454: Insert OLE Object dialog with Create from file option selected
3) To insert the object as a link to the original file, select the Link to file option. Otherwise,
the object will be embedded in your document.
4) If you want the object to appear as a selectable icon, rather than a section of your file,
select the Display as icon option.
5) Click OK. A section of the inserted file is shown in the document. If your source
spreadsheet has multiple sheets, it’s possible to navigate between them in the edit
mode.

Other OLE objects


Under Windows, when you select the Create new option on the Insert OLE Object dialog, there
is an extra entry Further objects in the Object Type list.
1) Double-click on the entry Further objects to open the Insert Object dialog (Figure 455).
2) Select Create New to insert a new object of the type selected in the Object Type list, or
select Create from File to create a new object from an existing file.

Chapter 12 Linking Data | 431


Figure 455: Inserting an OLE object under Windows
3) If you choose Create from File, the layout of the Insert Object dialog changes to that
shown in Figure 456. Click Browse and choose the file to insert. The inserted file object
is editable by the Windows program that created it.
If instead of inserting an object, you want to insert a link to an object, select the Display
As Icon option.
4) Click OK.

Figure 456: Insert OLE object from a file under Windows

Non-linked OLE object


If the OLE object is not linked, it can be edited in the new document. For instance, if you insert a
spreadsheet into a Writer document, you can essentially treat it as a Writer table (with a little
more power). To edit it, double-click on it.

Linked OLE object


If the spreadsheet OLE object is linked and you change it in Writer, it will change in Calc; if you
change it in Calc, it will change in Writer. This can be a very powerful tool if you create reports in
Writer using Calc data, and want to make a quick change without opening Calc.

432 |Calc Guide 24.8


Note
You can only edit one copy of a spreadsheet at a time. If you have a linked OLE
spreadsheet object in an open Writer document and then open the same
spreadsheet in Calc, the Calc spreadsheet will be a read-only copy.

Dynamic Data Exchange (DDE)


DDE is an acronym for Dynamic Data Exchange, a mechanism whereby selected data in
document A can be pasted into document B as a linked, ‘live’ copy of the original. It would be
used, for example, in a report written in Writer containing time-varying data, such as sales
results sourced from a Calc spreadsheet. The DDE link ensures that, as the source spreadsheet
is updated so is the report, thus reducing the scope for error and reducing the work involved in
keeping the Writer document up to date.
DDE is a predecessor of OLE. With DDE, objects are linked through file reference, but not
embedded. You can create DDE links either within Calc cells in a Calc sheet, or in Calc cells in
another LibreOffice doc such as in Writer.

DDE link in Calc


Creating a DDE link in Calc is similar to creating a cell reference. The process is a little different,
but the result is the same. Carry out the following steps to create a DDE link from one Calc
spreadsheet to another:
1) In Calc, open the spreadsheet that contains the original data that you want to link to.
2) Select the cells that you want to make the DDE link to.
3) Copy the cells to the clipboard by selecting Edit > Copy on the Menu bar, or clicking the
Copy icon on the Standard toolbar, or right-clicking the selected area and selecting
Copy in the context menu, or pressing Ctrl+C.
4) Open the second spreadsheet that will contain the linked data.
5) Click in the top left cell of the area in the second spreadsheet where you want the linked
data to appear.
6) On the second spreadsheet, select Edit > Paste Special > Paste Special on the Menu
bar, or right-click the top left cell of the area and select Paste Special > Paste Special in
the context menu, or press Ctrl+Shift+V.
7) Calc displays the Paste Special dialog (Figure 457).
8) Select the As Link option on the Paste Special dialog (highlighted with a red box on
Figure 457) and then click OK.
9) If you now click on one of the linked cells you will see that the Formula bar shows a
reference beginning with the characters {=’. See Figure 458 for an example, highlighted
with a red box.
Save and close both spreadsheets.
If you subsequently edit the original cells in their spreadsheet and save the changes, next time
you open the spreadsheet containing the linked cells, the values in those linked cells will update
to reflect the latest values of the original cells.

Chapter 12 Linking Data | 433


Figure 457: Paste Special dialog

Figure 458: Example of DDE link to another Calc spreadsheet

Note
When you open a spreadsheet containing linked data, you may get a warning
message indicating that automatic update of external links has been disabled. You
will need to click the associated button to allow updating of the linked cells. You can
avoid this message and interaction by making sure that the spreadsheet containing
the original data is in a trusted file location and that the option is selected to always
update links from trusted locations when opening. Check these settings via Tools >
Options > LibreOffice > Security > Macro Security (Trusted Sources tab) and
Tools > Options > LibreOffice Calc > General (Update links when opening section)
respectively.

434 |Calc Guide 24.8


DDE link in Writer
The process for creating a DDE link from Calc to Writer is similar to creating a link within Calc.
You can check more details of this feature in the Writer Guide.
1) In Calc, select the cells to make the DDE link to. Copy them.
2) Go to the place in your Writer document where you want the DDE link. Select Edit >
Paste Special > Paste Special.
3) Writer displays its Paste Special dialog (Figure 459).
4) Select the Dynamic Data Exchange (DDE link) option in the Selection list.
5) Click OK.
6) Now the link has been created in Writer. When the Calc spreadsheet is updated, the
table in Writer is automatically updated.

Figure 459: Paste Special dialog in Writer, with DDE link selected

XML Source
The XML Source feature allows a user to import data from arbitrarily structured XML content into
cells in an existing spreadsheet document. It allows XML content to be imported either partially
or in full, depending on the structure of the XML content and the map definitions that the user
defines. The user can specify multiple non-overlapping sub-structures to be mapped to different
cell positions within the same document, and can select to import either element contents,
attribute values, or both.

Note:
The XML Source feature currently allows you to import XML data as a one-time
event; it will not store the information about the data source once the data is
imported.
Suppose that you have sales data in an XML file, such as the following:
<sales>
<sale>
<date>01/19/08</date>
<value>$2,032</value>
<category>Golf</category>
<region>West</region>

Chapter 12 Linking Data | 435


<employee>Brigitte</employee>
</sale>
<sale>
<date>01/25/08</date>
<value>$3,116</value>
<category>Sailing</category>
<region>East</region>
<employee>Hans</employee>
</sale>
<sale>
<date>01/26/08</date>
<value>$2,811</value>
<category>Tennis</category>
<region>South</region>
<employee>Fritz</employee>
</sale>
</sales>
To import this data into your Calc spreadsheet, take the following steps:
1) Select Data > XML Source. Calc displays the XML Source dialog (Figure 460).

Figure 460: XML Source dialog (on initial display)


2) Click the icon in the Source File area at the top of the dialog. Calc displays the Open
dialog, which lets you specify the path to the XML file that you wish to import into your
document.
3) Navigate to the correct folder, select the required file, and click the Open button.
4) Calc reads the content of the specified file and then populates the Map to Document
area on the XML Source dialog to show the structure of the XML, as can be seen in
Figure 461. The Map to Document area is described further below.
5) In the case of our example data, select sale in the Map to Document area. This will
import all <sale> entries within the XML content into the spreadsheet.
6) Click on the cell at the top left of the area where the data is to appear in your
spreadsheet. In the case of our example, click cell A1. A tellback of the cell clicked
appears in the Mapped cell text box.

436 |Calc Guide 24.8


7) The contents of the XML Source dialog should now look like that shown in Figure 461.
8) Click the Import button. This action starts the import process based on the link
definitions that the user has provided. Once the import finishes, the dialog will close.

Figure 461: XML Source dialog (populated)


Calc will place the XML content into the specified position in the spreadsheet, as shown in
Figure 462.

Figure 462: Imported XML content


The Map to Document area of the XML Source dialog shows the structure of the source XML
content as a tree. It is initially empty and gets populated when you specify the source file.
Each element in the tree can be one of three types:
• Attribute, represented by the symbol @.
• Single non-recurring element, represented by the symbol </>. A non-recurring element is
an element that can only occur once under the same parent. It is mapped to a single cell
in the document.
• Recurring element, represented by the symbol <//>. A recurring element is an element
that can appear multiple times under the same parent. It serves as an enclosing parent
of a single record entry of multiple record entries. These entries are imported into a
range whose height equals the number of entries plus one additional header row.
The Mapped cell field specifies the position of a cell in the document that an element or an
attribute is linked to. If it is a non-recurring element or an attribute, it simply points to the cell
where the value of the linked element/attribute will get imported. If it is a recurring element, it

Chapter 12 Linking Data | 437


points to the top-left cell of the range where the whole record entries plus header will get
imported.

438 |Calc Guide 24.8


Calc Guide 24.8

Chapter 13
Sharing and Reviewing
Spreadsheets
Introduction
This chapter covers methods for collaboration through sharing and reviewing spreadsheets:
simultaneous editing, recording changes, adding comments, reviewing changes, merging and
comparing documents, saving, and using document versions.
Some menu commands are not available (grayed out) when sharing or change tracking are
active.

Sharing spreadsheets
Sharing a spreadsheet allows several users to open the same file for editing at the same time.
The spreadsheet needs to be on a shared drive, server, website, or similar. Some conditions
must be met on operating systems with user permission management:
• The shared file needs to reside in a location which is accessible by all collaborators.
• The file permissions for both the document and the corresponding lock file need to be
set so that all collaborators can create, delete, and change the files.
Consult your operating system’s documentation for details on setting file permissions. See also
“Opening and saving files on remote servers” in the Getting Started Guide.

Tip
In order to correctly identify the changes, each collaborator should enter their name
in Tools > Options > LibreOffice > User Data on the Menu bar.

Setting up a spreadsheet for sharing


With the spreadsheet open, choose Tools > Share Spreadsheet on the Menu bar to enable or
disable sharing.

Figure 463: Share Document dialog

To enable sharing, select the checkbox at the top of the dialog (Figure 463) and click OK. If the
spreadsheet has been saved previously, a message appears stating that you must save it to

440 |Calc Guide 24.8


activate shared mode; click Yes to continue. If the spreadsheet has not been saved previously,
the Save dialog opens. After saving, the text “(shared)” is shown on the Title bar, after the title.
Tools > Share Spreadsheet on the Menu bar can also be used to switch a spreadsheet from
shared to unshared. However, this means that other users can no longer edit it. Instead, you
may wish to save a copy of the shared spreadsheet using another name or path, thus creating a
copy of the shared spreadsheet, and then switch the copy to unshared.

Opening a shared spreadsheet


When you open a shared spreadsheet, a message appears stating that some features are not
available in this mode. After reading it, click OK to remove the message and open the document.
You can select the option to not show the warning again.
The following features are disabled in a shared spreadsheet:
Edit > Track Changes, except for Merge Document
Insert > Media > Audio or Video
Insert > Comment
Insert > Object
Insert > Chart
Insert > Named Range or Expression
Insert > Pivot Table
Insert > Floating Frame
Insert > Fontwork
Insert > Signature Line
Format > Merge Cells
Format > Print Ranges
Sheet > Move or Copy Sheet
Sheet > Delete Sheet
Sheet > Insert Sheet from File
Sheet > Named Ranges and Expressions
Sheet > Rename Sheet
Sheet > Sheet Tab Color
Data > Define Range
Data > Sort
Data > Sort Ascending
Data > Sort Descending
Data > Subtotals
Data > Validity
Data > Multiple Operations
Data > Consolidate
Data > Group and Outline
Data > Pivot Table
Tools > Protect Sheet
Tools > Protect Spreadsheet Structure

Saving a shared spreadsheet


When you save a shared spreadsheet, and if it has not been modified and saved by another
user since you opened it, it is saved as usual.
If the spreadsheet has been modified and saved by another user since you opened it, one of the
following will occur:

Chapter 13 Sharing and Reviewing Spreadsheets | 441


• If the changes do not conflict, the document is saved, the message “Your spreadsheet
has been updated with changes saved by other users” appears, and any cells modified
by the other user are shown with a red border.

Figure 464: Resolve Conflicts dialog

• If the changes conflict, the Resolve Conflicts dialog (Figure 464) is shown. You must
decide for each conflict which version to keep, yours or the other person’s. When all
conflicts are resolved, the document is saved. While you are resolving the conflicts, no
other user can save the shared document.
• If another user is trying to save the shared spreadsheet and resolve conflicts, they see a
message that the file is locked due to a merge in progress. They can cancel the Save
command and retry saving later.
When you successfully save a shared spreadsheet, the document shows the latest version of all
changes saved by all users.

Reviewing documents
You can use several methods to review, edit, and comment on a spreadsheet. Each reviewer
works on a separate copy of the document.
• You can use change marks to show added and deleted material. Later, you or another
person can review the document and accept or reject each change.
• You can make changes to a copy of the document (stored in a different folder, under a
different name, or both), then use Calc to compare the files and show the changes. See
“Comparing documents” below.
• You can save versions that are stored as part of the original file. See “Saving versions”
below.
Reviewers can leave comments in the document, either attached to specific changes or
standalone.

Preparing a document for review (optional)


Before you send a spreadsheet to someone else to review or edit, you may want to set it up so
that the editor or reviewer does not have to remember to turn on the revision marks.

442 |Calc Guide 24.8


After you have turned on revision marks, you can optionally password protect the spreadsheet
so that any user must enter the correct password in order to accept or reject changes.
1) Open the spreadsheet and select Edit > Track Changes > Record on the Menu bar.
You can also use File > Properties > Security and select Record changes.
2) If you want to protect the spreadsheet, click Edit > Track Changes > Protect on the
Menu bar. On the Protect Records dialog, type a password (twice) and click OK. You can
also use File > Properties > Security and click the Protect button to open the similar
Enter Password dialog. Both dialogs incorporate a password strength meter to indicate
the strength of the entered password. This provides a colored bar to reflect password
strength, with red indicating a weak password and green indicating a strong password. In
addition, the longer the colored bar, the greater the strength of the password.

Recording changes
To record changes, open the spreadsheet and make sure that the Edit > Track Changes >
Record menu item has a check mark next to it, indicating that change recording is active.

Caution
After making some changes, do not turn off change recording. Turning off change
recording in Calc causes all the recorded changes to be accepted and no longer
shown as changes. A message box will warn if you try to do this.
When changes are made in a cell, a colored border with a dot in the upper left-hand corner
appears around the cell (Figure 465). A deleted column or row is marked by a heavy colored bar.

Figure 465: Edited document with red border on changed cells

To see the changed information, hover the mouse pointer over the changed cell. See Figure 466.

Figure 466: Showing details of the change

Note

Chapter 13 Sharing and Reviewing Spreadsheets | 443


Some changes, for example cell formatting, are not recorded and marked.

Tip
To change the color that indicates a changed cell, select Tools > Options >
LibreOffice Calc > Changes on the Menu bar.
You may want to explain your rationale for the changes. You can do this by adding comments to
the changes you made or by adding general comments to the spreadsheet.

Adding comments to changes


Calc automatically adds to any recorded change a comment that describes what was changed
(for example, Cell B4 changed from ‘9’ to ‘4’). Reviewers and authors can add their own
comments to explain their reasons for the changes or provide any other helpful insights.
To add a comment to a change:
1) Make the change to the spreadsheet.
2) Select the cell with the change.
3) Choose Edit > Track Changes > Comment on the Menu bar. A small dialog opens.
Type your comment and click OK. See Figure 467.

Note
Do not use Insert > Comment on the Menu bar or the context menu for this
purpose. Comments inserted using that method are handled differently (see “Adding
other (general) comments” below) and do not appear in the Manage Changes dialog.

Figure 467: Entering a comment associated with a change

After you have added a comment to a changed cell, you can see the change and the comment
by hovering the mouse pointer over the cell, as shown in Figure 468.

444 |Calc Guide 24.8


Figure 468: Comment added to cell B3

The comment also appears on the Manage Changes dialog when you are accepting and
rejecting changes, as shown in the first line of Figure 472 on page 448.

Editing comments on changes


1) Select the cell with the change comment that you want to edit.
2) Choose Edit > Track Changes > Comment on the Menu bar. The box shown in Figure
467 opens.
3) Edit the comment and click OK.
The automatically-added comment provided by Calc cannot be edited.
You can move through the comments by using the arrows at the bottom of the dialog.

Adding other (general) comments


Calc provides another type of comment, which authors and reviewers often use to exchange
ideas or ask for suggestions.
To add a general comment:
1) Select the cell that the comment applies to.
2) Select Insert > Comment on the Menu bar, or right-click and select Insert Comment in
the context menu, or press Ctrl+Alt+C. The box shown in Figure 469 appears.

Figure 469: Inserting a comment

3) Type your comment in the box, then click outside the box to close it.
Now the cell to which you added the comment has a colored triangle in the upper right-hand
corner, as shown in Figure 470. It does not have a colored border, unless the cell also has a
change comment.

Figure 470: Colored triangle in cell containing a comment

Chapter 13 Sharing and Reviewing Spreadsheets | 445


Tip
You can change the colors Calc uses for comments by selecting Tools > Options >
LibreOffice > Application Colors and adjusting the colors for Notes background
and Comments in the Spreadsheet section.
To view the comment you just added, hover the mouse pointer over the cell that has a comment.
The comment appears, as shown in Figure 471.

Figure 471: Viewing a comment

Note
If you hover the mouse pointer over a cell that has both a change comment and a
general comment, both comments are shown in the displayed tip.

Editing general comments


You can edit and format the text of a general comment, just as you do for any other text.
1) Right-click on the cell containing the comment marker and choose Edit comment in the
context menu, or left-click on the cell and press Ctrl+Alt+C.
2) Calc shows the cell’s comment. The pointer changes to the usual text-entry pointer, and
the Formatting toolbar changes to show text attributes.
3) When editing is done, click outside the comment to deselect it.

Formatting general comments


You can change the background color, border style, transparency, and other attributes of a
comment.
1) Right-click on the cell containing the comment marker, and choose Show comment in
the context menu. The authorship data shown at the top of the comment in Figure 471 is
not displayed when a general comment is shown via this interaction.
2) Click on the comment itself. The Formatting toolbar changes to show many of the
comment formatting options. These are the same as the options for formatting graphics;
see Chapter 6, Using Images and Graphics, for more information.
You can also right-click on the comment to see a menu of choices, some of which lead to
dialogs where you can fine-tune the formatting; these dialogs are also discussed in
Chapter 6.
3) When done, click outside the comment to deselect it. To hide the comment again, right-
click on the cell and choose Hide Comment in the context menu.

446 |Calc Guide 24.8


Finding general comments
If the comment markers in the corners of cells are difficult to see, Calc provides two other ways
to find them: by showing all comments and by using the Navigator.
1) To show all general comments, choose View > Comments on the Menu bar. To hide all
comments, choose View > Comments again. The authorship data shown at the top of
the comment in Figure 471 is not visible when all general comments are shown in this
way.
2) If any general comments are in the spreadsheet, the Navigator shows a symbol (usually
a + or an arrow) next to the word Comments. Click on this symbol to display a list of the
comments. Double-click on a comment in the list to jump directly to the cell it is
associated with.

Note
View > Comments and the Navigator show general comments but not the
comments associated with tracked changes.

Accepting or rejecting changes


When you receive a document with changes, you can step through each change and decide
how to proceed. To begin this process:
1) Open the edited document.
2) Select Edit > Track Changes > Manage on the Menu bar. The Manage Changes dialog
shown in Figure 472 appears.
3) You can step through the changes one at a time, choosing to accept or reject each
change as you go through. You can also accept or reject all changes at one time.
The Comment column by default contains an explanation of the change that was made. If the
reviewer added a comment to the change, it is displayed, followed by the description of the
change.
If a change has been superseded by a later change (by either the same person or another
person), the changes are hierarchically arranged with an expansion symbol for opening up the
hierarchy.
Below the list of changes to be accepted or rejected are shown any changes that have
previously been dealt with.

Chapter 13 Sharing and Reviewing Spreadsheets | 447


Figure 472: Manage Changes dialog – List tab

Figure 473: Manage Changes dialog – Filter tab

On the Filter tab of the Manage Changes dialog (Figure 473), you can choose how to filter the
list of changes: by date, author, cell range, or comments containing specific terms. After
selecting the filter criteria, switch back to the List tab to see the results. Filtering the changes
affects only the contents of the List tab on the dialog, you will not see any filtered results in your
spreadsheet.

448 |Calc Guide 24.8


Merging documents
The processes discussed to this point are effective when you have one reviewer at a time.
Sometimes, however, multiple reviewers all return edited copies of a spreadsheet. In this case, it
may be faster to review all of the changes at once, rather than one review at a time. For this
purpose, you can merge documents in Calc.
To merge documents, all of the edited documents (but not the original document) need to have
recorded changes in them.
1) Open the original document into which you want to merge all the copies.
2) Select Edit > Track Changes > Merge Document on the Menu bar.
3) A file selection dialog opens. Select a file you want to merge and click Open.
4) After the documents merge, the Manage Changes dialog opens, showing changes by
more than one reviewer. If you want to merge more documents, close the dialog and
then repeat steps 2) and 3).
Now all of the changes are combined into one document and you can accept or reject the
changes. Changes from different authors appear in cells outlined in different colors.

Comparing documents
Sometimes reviewers may not record the changes they make. Calc can find the changes by
comparing documents.
To compare documents, you need to have the original document and the one that is edited.
1) Open the edited document that you want to compare with the original document.
2) Select Edit > Track Changes > Compare Document.
3) A file selection dialog opens. Select the original document and click Open.
4) Calc opens the Manage Changes dialog showing the changes identified.
Calc finds and marks the changes as follows:
• All data that occurs in the edited document but not in the original is identified as inserted.
• All data in the original document that is not in the edited document is identified as
deleted.
• All data that is changed is marked as changed.
From this point you can go through and accept or reject changes, as described earlier.

Saving versions
For auditing and other purposes, you may need to save new versions of a spreadsheet. You can
do this by saving a copy of the spreadsheet (under a different name) after each revision, or by
using Calc’s version feature.

Caution
If you select File > Save As on the Menu bar, or press Ctrl+Shift+S, for a
document with different versions stored in it, the old versions are not saved in the
new file.

Chapter 13 Sharing and Reviewing Spreadsheets | 449


To use version management in Calc:
1) Choose File > Versions on the Menu bar. A version management dialog (Figure 474)
opens, showing a list of the existing versions saved in this file.

Figure 474: Version management dialog

2) Click the Save New Version button to save a new version. The Insert Version Comment
dialog (Figure 475) opens where you can enter comments about this version.

Figure 475: Insert Version Comment dialog


3) After you enter your comment and click OK, the new version is included in the Existing
Versions list (Figure 476).
4) Save the file. Both versions are now included in the same file.
From this point you can:
• View an old version – Select the version and click Open. A read-only copy of a previous
version opens.
• Compare all versions – Clicking Compare performs an action similar to merging
documents. A Manage Changes dialog opens, showing all of the changes through the
different versions.
• Review the version comments – Select a version and click Show to display the full
comments made by yourself or other reviewers.

450 |Calc Guide 24.8


• Delete a version – Select a version and click Delete. Be careful with this option, when
deleting a version, there is no request for confirmation.

Figure 476: Updated version list

Chapter 13 Sharing and Reviewing Spreadsheets | 451


Calc Guide 24.8

Chapter 14
Macros
Automating repetitive tasks
Introduction
Chapter Getting Started with Macros of the Getting Started Guide is an introduction to the macro
facilities that are available in LibreOffice. The current chapter provides further introductory
information about the use of macros within a Calc spreadsheet.
A macro is a set of commands or keystrokes that are stored for later use. An example of a
simple macro is one that enters your address into the current cell of an open spreadsheet. You
can use macros to automate both simple and complex tasks, and they enable you to introduce
new features that are not built into Calc.
The simplest way to create a macro is to record a series of actions through Calc’s user interface.
Calc saves recorded macros using the open-source LibreOffice Basic scripting language, which
is a dialect of the well-known BASIC programming language. Such macros can be edited and
enhanced after recording using the built-in LibreOffice Basic Integrated Development
Environment (IDE).
The most powerful macros in Calc are created by writing code using one of the four supported
scripting languages (LibreOffice Basic, Python, JavaScript, and BeanShell). This chapter
provides an overview of Calc’s macro facilities, mostly focused on its default macro scripting
language, LibreOffice Basic. Some examples are included for the Python, JavaScript, and
BeanShell scripting languages but fuller descriptions of the facilities for these languages are
beyond the scope of this document.

On Visual Basic for Applications (VBA) compatibility


The LibreOffice Basic programming language and the VBA programming language – found in
many Microsoft Office documents including Excel spreadsheets – are dialects of the BASIC
language. If you want to use macros written in Microsoft Excel using the VBA macro code in
LibreOffice, you must first edit the code in the LibreOffice Basic IDE.
Some tips for converting Excel macros written in VBA are detailed at the end of this chapter.

Using the macro recorder


Chapter Getting Started With Macros, of the Getting Started Guide includes examples showing
how to use the macro recorder and understand the generated LibreOffice Basic scripts. The
following steps give a further example, specific to a Calc spreadsheet, without the more detailed
explanations of the Getting Started Guide. A macro is created and saved which performs a paste
special with multiply operation across a range of spreadsheet cells.

Note
Use Tools > Options > LibreOffice > Advanced on the Menu bar and select the
Enable macro recording (may be limited) option to enable the macro recorder.
5) Use File > New > Spreadsheet on the Menu bar to create a new spreadsheet.
6) Enter the numbers shown in Figure 477 into cells A1:C3 of Sheet1 in the new
spreadsheet.

Figure 477: Enter numbers into cells A1:C3

454 |Calc Guide 24.8


7) Select cell A3, which contains the number 3, and use Edit > Copy on the Menu bar to
copy the value to the clipboard.
8) Select all cells in the range A1:C3.
9) Use Tools > Macros > Record Macro on the Menu bar to start the macro recorder. Calc
displays the Record Macro dialog, which includes a Stop Recording button (Figure
478).

Figure 478: Record Macro dialog with Stop Recording button


10) Use Edit > Paste Special > Paste Special on the Menu bar to open the Paste Special
dialog (Figure 479).

Figure 479: Paste Special dialog


11) Select the All option in the Paste area and Multiply in the Operations area (both options
are highlighted with a red box in Figure 479), and click OK. The values in cells A1:C3 are
now multiplied by 3 (Figure 480).

Figure 480: Cells A1:C3 multiplied by 3


12) Click the Stop Recording button to stop the macro recorder. Calc displays a variant of
the Basic Macros dialog (Figure 481).

Chapter 14 Macros | 455


Note
The Save Macro In area of the Basic Macros dialog shows the existing LibreOffice
Basic macros, hierarchically structured into library containers, libraries, modules, and
macros as described in the Getting Started Guide. Figure 481 shows the My Macros
library container, the LibreOffice Macros library container, the library container for the
open balance.ods file, and the library container for the untitled file created at step 5).
Use the expand/collapse icons to the left of each library container name to view the
libraries, modules, and macros within that container.

Figure 481: Parts of the Basic Macros dialog


1 My Macros 5 Current document
2 LibreOffice Macros 6 Create new library
3 Expand/collapse icon 7 Create new module in library
4 Open documents 8 Macros in selected module

13) Select the entry for the current document in the Save Macro In area. As the current
document in this example has not been saved, it is referred to by its default name
Untitled 1.
14) Documents that have been saved include a macro library named Standard. This library is
not created until the document is saved or the library is needed, so at this point in the
example procedure your new document does not contain a library. You can create a new
library to contain the macro you have just created, but this is not necessary.
15) Click the New Module button. Calc displays the New Module dialog (Figure 482). Type a
name for the new module or leave the name as the default Module1.

456 |Calc Guide 24.8


Figure 482: New Module dialog

Note
The libraries, modules, and macro names must follow some strict rules. Following
the main rules, the names must:
Comprise lower case letters (a..z), upper case letters (A..Z), digits (0..9), and
underscore characters (_)
Begin with a letter or an underscore
Not contain any other spaces, punctuation symbols, or special characters (including
accents)
16) Click the OK button to create a new module. As no macro libraries exist in our current
document, Calc automatically creates and uses a Standard library.
17) On the Basic Macros dialog, select the entry for the newly created module in the Save
Macro In area, type the text PasteMultiply in the Macro Name box, and click the
Save button (Figure 483).

Figure 483: Select the module and name the macro


The macro is saved with the name PasteMultiply in the newly created module within the
Standard library of the Untitled 1 document. Listing 1 shows the contents of the macro.
Listing 1. Paste special with multiply macro
1|Sub PasteMultiply
2| ' --------------------------------------------------------------
3| ' define variables
4| dim document as object
5| dim dispatcher as object
6| ' --------------------------------------------------------------
7| ' get access to the document
8| document = ThisComponent.CurrentController.Frame

Chapter 14 Macros | 457


9| dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
10|
11| ' --------------------------------------------------------------
12| dim args1(5) as new com.sun.star.beans.PropertyValue
13| args1(0).Name = "Flags"
14| args1(0).Value = "A"
15| args1(1).Name = "FormulaCommand"
16| args1(1).Value = 3
17| args1(2).Name = "SkipEmptyCells"
18| args1(2).Value = false
19| args1(3).Name = "Transpose"
20| args1(3).Value = false
21| args1(4).Name = "AsLink"
22| args1(4).Value = false
23| args1(5).Name = "MoveMode"
24| args1(5).Value = 4
25|
26| dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args1())
27|
28|End Sub

Note
The component model used in LibreOffice is Universal Network Objects (UNO) and
the macro recorder uses the UNO dispatcher for most commands. However, there
are two problems associated with this technical approach. One is that the dispatches
are not fully documented and may be subject to change. Another is that the recorder
ignores some values from dialogs that are opened while recording a macro – it is
possible, therefore, that you will record a complicated macro that will not actually
execute everything as expected. For more information, search for “macro recording –
limitations” in the Help index.

Write your own functions


Create a function macro
You can write a macro and then call it as you would call a Calc function. Use the following steps
to create a simple function macro:
1) Use File > New > Spreadsheet on the Menu bar to create a new spreadsheet, save it
with the name CalcTestMacros.ods, and leave it open in Calc.
2) Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic
Macros dialog (Figure 484). Note that the layout of the Basic Macros dialog in this
circumstance is different from the version that Calc displays when the user clicks the
Stop Recording button on the Record Macro dialog (Figure 481).

458 |Calc Guide 24.8


Figure 484: Basic Macros dialog
3) The Macro From area lists the available macro library containers, including those relating
to any LibreOffice documents that are currently open. My Macros contains macros that
you write or add to LibreOffice and are available to more than one document. LibreOffice
Macros contains macros that were included with your LibreOffice installation and should
not be changed.
4) Click Organizer to open the Basic Macro Organizer dialog (Figure 485).
Click on the Libraries tab and, in the Location area, select the entry for the name of the
current document. The Library area updates to show the name of the empty Standard
library.

Figure 485: Basic Macro Organizer


5) Click New to open the New Library dialog to create a new library for this document
(Figure 486).

Chapter 14 Macros | 459


Figure 486: New Library dialog
6) Enter a descriptive library name (such as AuthorsCalcMacros) and click OK to create
the library. The Library area of the Basic Macro Organizer dialog updates to include the
name of the newly created library. A library name can comprise up to 30 characters. Note
that in some cases, the dialog may show only a portion of the name.

Figure 487: The new library is shown in the Library area


7) Select the AuthorsCalcMacros entry in the Library area and click Edit to edit the library.
Calc automatically creates a module named Module1 and a macro named Main. Calc
displays the LibreOffice Basic Integrated Development Environment (IDE), shown in
Figure 488.
Figure 488 shows the default configuration for the LibreOffice Basic IDE. This comprises:
• A menu bar.
• Two toolbars (Macro and Standard). The Macro toolbar provides various icons for
editing and testing programs.
• The Object Catalog, enabling the selection of the required library container, library,
module, and macro.
• The Editor Window, in which you can edit the LibreOffice Basic program code. The
column on the left side is used to set breakpoints in the program code.
• The Watch Window (located at the left, below the Object Catalog and Editor Window)
displays the contents of variables or arrays during a single step process.

460 |Calc Guide 24.8


Figure 488: LibreOffice Basic Integrated Development Environment
The Calls Window (located to the right, below the Object Catalog and Editor Window) provides
information about the call stack of procedures and functions when a program runs.
• A tab control area.
• A status bar.
The LibreOffice Basic IDE provides powerful facilities for the development and debugging of
LibreOffice Basic macros. A fuller description of this facility is beyond the scope of this
document, but more information can be found in the Help system.
1) In the Editor Window, modify the code so that it is the same as that shown in Listing 2.
The important addition is the creation of the NumberFive function, which returns the
value 5.

Tip
The Option Explicit statement forces all variables to be declared before they are
used. If Option Explicit is omitted, variables are automatically defined at first use
as type Variant.
2) Within the LibreOffice Basic IDE select File > Save on the Menu bar, or click the Save
icon on the Standard toolbar, or press Ctrl+S, to save the modified Module1.
Listing 2. Function that returns the value 5
1|' ***** BASIC *****
2|Option Explicit
3|Sub Main
4|
5|End Sub

Chapter 14 Macros | 461


6|
7|Function NumberFive ()
8| NumberFive = 5
9|End Function

Using a macro as a function


Using your newly created CalcTestMacros.ods spreadsheet, select a cell and enter the
formula =NumberFive() (Figure 489). Calc finds the macro, calls it, and displays the result (5) in
that cell.

Figure 489: Use the NumberFive macro as a Calc function

Tip
Function names are not case sensitive. In Figure 489, the function name was
entered as NumberFive but Calc displays it as NUMBERFIVE in the Formula bar.

Macro security warnings


You should now save the Calc document, close it, and open it again. Depending on your settings
in the Macro Security dialog accessed using Tools > Options > LibreOffice > Security >
Macro Security on the Menu bar, Calc may display one of the warnings shown in Figures 490
and 491.

Figure 490: Warning that a document contains macros


In the case of the warning shown in Figure 490, you will need to click Enable Macros, or Calc
will not allow any macros to be run in the document. If you do not expect a document to contain
a macro, it is safer to click Disable Macros in case the macro is a virus.
In the case of the warning shown in Figure 491, Calc will not allow any macros to be run in the
document and you should click the OK button to remove the warning from the screen.
When the document loads with macros disabled, Calc will not be able to find any macro
functions and will indicate an error in any affected cell by displaying the text #NAME? in that cell.

462 |Calc Guide 24.8


Figure 491: Warning that macros in the document are disabled

Loaded / unloaded libraries


When it opens a spreadsheet, Calc does not open all macro libraries that it can find in the
available library containers because this would be a waste of resources. Instead, Calc
automatically loads just the Standard library within the My Macros library container and the
document’s own Standard library.
When you re-open your CalcTestMacros.ods spreadsheet, Calc does not contain a function
named NumberFive(), so it checks all visible, loaded macro libraries for the function. Loaded
libraries in LibreOffice Macros, My Macros, and the document are checked for an appropriately
named function. In our initial implementation, the NumberFive() function is stored in the
AuthorsCalcMacros library, which is not automatically loaded when the document is opened.
Hence the NumberFive() function is not found and an error condition appears in the cell where it
is called (Figure 492).

Figure 492: The macro function is not available


Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic Macros
dialog (Figure 493). The icon for a loaded library (for example, Standard) has a different
appearance to the icon for a library that is not loaded (for example, AuthorsCalcMacros).
Click the expand icon next to AuthorsCalcMacros to load the library. The icon changes
appearance to indicate that the library is now loaded. Click Close to close the Basic Macros
dialog.

Figure 493: Different symbols for loaded and unloaded libraries

Chapter 14 Macros | 463


Unfortunately, the cell containing =NumberFive() in our initial implementation is still in error.
Calc does not recalculate cells in error unless you edit them or somehow change them. The
usual solution is to store macros used as functions in the Standard library. If the macro is large
or if there are many macros, a stub with the desired name is stored in the Standard library. The
stub macro loads the library containing the implementation and then calls the implementation.
The following steps illustrate this method.
1) Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic
Macros dialog. Select the NumberFive macro and click Edit to open the macro for editing
(Figure 494).

Figure 494: Select a macro and click Edit


2) Calc displays the LibreOffice Basic IDE (Figure 488), with the input cursor in the Editor
Window at the line Function NumberFive (). Change the name of NumberFive to
NumberFive_Implementation so that the function’s code matches Listing 3.
Listing 3. Change the name of NumberFive to NumberFive_Implementation
1|Function NumberFive_Implementation ()
2| NumberFive_Implementation = 5
3|End Function
3) Click the Select Macro button in the Standard toolbar of the LibreOffice Basic IDE to
open the Basic Macros dialog (Figure 494).
4) Select the Standard library in the CalcTestMacros.ods document and click the New
button to create a new module. Enter a meaningful name such as CalcFunctions and
click OK. Calc automatically creates a macro named Main and opens the module for
editing.
5) Create a macro in the CalcFunctions module of the Standard library that loads the
AuthorsCalcMacros library if it is not already loaded, and then calls the implementation
function. See Listing 4.
Listing 4. Create a new NumberFive function to call the NumberFive_Implementation function
1|Function NumberFive()
2| If NOT BasicLibraries.isLibraryLoaded("AuthorsCalcMacros") Then
3| BasicLibraries.LoadLibrary("AuthorsCalcMacros")
4| End If
5| NumberFive = NumberFive_Implementation()
6|End Function
6) Save, close, and reopen the Calc document. This time, if macros are enabled, the
NumberFive() function works as expected.

464 |Calc Guide 24.8


Passing arguments to a macro
To illustrate a function that accepts arguments, we will write a macro that calculates the sum of
its arguments that are positive. It will ignore arguments that are less than zero (see Listing 5).
Listing 5. PositiveSum calculates the sum of its positive arguments
1|Function PositiveSum(Optional x)
2| Dim TheSum As Double
3| Dim iRow As Integer
4| Dim iCol As Integer
5|
6| TheSum = 0.0
7| If NOT IsMissing(x) Then
8| If NOT IsArray(x) Then
9| If x > 0 Then TheSum = x
10| Else
11| For iRow = LBound(x, 1) To UBound(x, 1)
12| For iCol = LBound(x, 2) To UBound(x, 2)
13| If x(iRow, iCol) > 0 Then TheSum = TheSum + x(iRow, iCol)
14| Next
15| Next
16| End If
17| End If
18| PositiveSum = TheSum
19|End Function
The macro in Listing 5 demonstrates some important techniques:
1) The argument x is Optional. When an argument is not Optional and the function is
called without it, Calc outputs a warning message every time the macro is called. If Calc
calls the function many times, then the error is displayed many times.
2) The function IsMissing checks that an argument was passed before it is used.
3) The function IsArray checks to see if the argument is a single value, or an array. For
example, =PositiveSum(7) or =PositiveSum(A4). In the first case, the number 7 is
passed as an argument, and in the second case, the value of cell A4 is passed to the
function. In both these cases, IsArray returns the value False.
4) If a range is passed to the function, it is passed as a two-dimensional array of values; for
example, =PositiveSum(A2:B5). The functions LBound and UBound are used to
determine the array bounds that are used. Although the lower bound is one, it is
considered safer to use LBound in case it changes in the future.

Tip
The macro in Listing 5 is careful and checks to see if the argument is an array or a
single argument. The macro does not verify that each value is numeric. You may be
as careful as you like. The more things you check, the more robust the macro is, but
the slower it runs.
Passing one argument is as easy as passing two: add another argument to the function
definition (see Listing 6). When calling a function with two arguments, separate the arguments
with a comma; for example, =TestMax(3, -4).
Listing 6. TestMax accepts two arguments and returns the larger one
1|Function TestMax(x, y)
2| If x >= y Then
3| TestMax = x
4| Else

Chapter 14 Macros | 465


5| TestMax = y
6| End If
7|End Function

Arguments are passed as values


Arguments passed to a macro from Calc are always values. It is not possible to know what cells,
if any, are used. For example, =PositiveSum(A3) passes the value of cell A3, and PositiveSum
has no way of knowing that cell A3 was used. If you must know which cells are referenced rather
than the values in the cells, pass the range as a string, parse the string, and obtain the values in
the referenced cells.

Writing macros that act like built-in functions


Although Calc finds and calls macros as normal functions, they do not really behave as built-in
functions. For example, macros do not appear in the function lists. It is possible to write functions
that behave as regular functions by writing an Add-In. However, this is an advanced topic that is
for experienced programmers and is beyond the scope of this guide. Some information, along
with links to more detailed reading, is available in the Help.

Deleting LibreOffice Basic macros


Use the following steps to delete an unwanted macro:
1) Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic
Macros dialog (Figure 494).
2) Select the macro to be deleted and click the Delete button.
3) Calc displays a confirmation dialog. Click Yes to continue.
4) Click the Close button to remove the Basic Macros dialog from the screen.
Use the following steps to delete an unwanted module:
1) Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic
Macros dialog (Figure 494).
2) Click the Organizer button to open the Basic Macro Organizer dialog (Figure 495).
3) Make sure that the Modules tab is selected.
4) Select the module to be deleted in the Module area.
5) Click the Delete button.
6) Calc displays a confirmation dialog. Click Yes to continue.
7) Click the Close button to remove the Basic Macro Organizer dialog from the screen.
8) Click the Close button to close the Basic Macros dialog.

466 |Calc Guide 24.8


Figure 495: Basic Macro Organizer dialog, Modules tab

Accessing cells directly


You can access the LibreOffice internal objects directly to manipulate a Calc document. For
example, the macro in Listing 7 adds the values in cell A2 from every sheet in the current
document. ThisComponent is automatically set to reference the current document when the
macro starts. A Calc document contains sheets and the macro accesses these via a call to
ThisComponent.getSheets(). Use getCellByPosition(col, row) to return a cell at a
specific row and column.
Listing 7. SumCellsAllSheets adds the values in cell A2 of every sheet
1|Function SumCellsAllSheets()
2| Dim TheSum As Double
3| Dim i As integer
4| Dim oSheets
5| Dim oSheet
6| Dim oCell
7|
8| TheSum = 0
9| oSheets = ThisComponent.getSheets()
10| For i = 0 To oSheets.getCount() - 1
11| oSheet = oSheets.getByIndex(i)
12| oCell = oSheet.getCellByPosition(0, 1) ' GetCell A2
13| TheSum = TheSum + oCell.getValue()
14| Next
15| SumCellsAllSheets = TheSum
16|End Function

Tip
A cell object supports the methods getValue(), getString(), and getFormula()
to get the numerical value, the string value, or the formula used in a cell. Use the
corresponding set functions to set appropriate values.
Use oSheet.getCellRangeByName("A2") to return a range of cells by name. If a single cell is
referenced, then a cell object is returned. If a cell range is given, then an entire range of cells is

Chapter 14 Macros | 467


returned (see Listing 8). Notice that a cell range returns data as an array of arrays, which is
more cumbersome than treating it as an array with two dimensions as is done in Listing 5.
Listing 8. SumCellsAllSheets adds the values in cells A2:C5 of every sheet
1|Function SumCellsAllSheets()
2| Dim TheSum As Double
3| Dim iRow As Integer, iCol As Integer, i As Integer
4| Dim oSheets, oSheet, oCells
5| Dim oRow(), oRows()
6|
7| TheSum = 0
8| oSheets = ThisComponent.getSheets()
9| For i = 0 To oSheets.getCount() - 1
10| oSheet = oSheets.getByIndex(i)
11| oCells = oSheet.getCellRangeByName("A2:C5")
12|
13| ' The getDataArray() method returns strings and numbers
14| ' but is not used in this function.
15|
16| ' The getData() method returns only numbers and is applicable
17| ' to this function.
18|
19| oRows() = oCells.getData()
20| For iRow = LBound(oRows()) To UBound(oRows())
21| oRow() = oRows(iRow)
22| For iCol = LBound(oRow()) To UBound(oRow())
23| TheSum = TheSum + oRow(iCol)
24| Next
25| Next
26| Next
27| SumCellsAllSheets = TheSum
28|End Function

Tip
When a macro is called as a Calc function, the macro cannot modify any value in the
sheet from which the macro was called, except the value of the cell that contains the
function.

Sorting
Consider sorting the data shown in Figure 496. First, sort on column B descending and then on
column A ascending.

Figure 496: Sort column B descending and column A ascending


The example in Listing 9 demonstrates how to sort on these two columns. Run the macro by
clicking the Run icon in the Macro toolbar of the LibreOffice Basic IDE.

468 |Calc Guide 24.8


Listing 9. SortRange sorts cells A1:C5 of Sheet 1
1|Sub SortRange
2| Dim oSheet ' Calc sheet containing data to sort.
3| Dim oCellRange ' Data range to sort.
4|
5| ' An array of sort fields determines the columns that are
6| ' sorted. This is an array with two elements, 0 and 1.
7| ' To sort on only one column, use:
8| ' Dim oSortFields(0) As New com.sun.star.util.SortField
9| Dim oSortFields(1) As New com.sun.star.util.SortField
10|
11| ' The sort descriptor is an array of properties.
12| ' The primary property contains the sort fields.
13| Dim oSortDesc(0) As New com.sun.star.beans.PropertyValue
14|
15| ' Get the sheet named "Sheet1"
16| oSheet = ThisComponent.Sheets.getByName("Sheet1")
17|
18| ' Get the cell range to sort
19| oCellRange = oSheet.getCellRangeByName("A1:C5")
20|
21| ' Uncomment the following code to select the range to sort.
22| ' The only purpose would be to emphasize the sorted data.
23| 'ThisComponent.getCurrentController.select(oCellRange)
24|
25| ' The columns are numbered starting with 0, so
26| ' column A is 0, column B is 1, etc.
27| ' Sort column B (column 1) descending.
28| oSortFields(0).Field = 1
29| oSortFields(0).SortAscending = FALSE
30| ' If column B has two cells with the same value,
31| ' then use column A ascending to decide the order.
32| oSortFields(1).Field = 0
33| oSortFields(1).SortAscending = TRUE
34|
35| ' Setup the sort descriptor.
36| oSortDesc(0).Name = "SortFields"
37| oSortDesc(0).Value = oSortFields()
38|
39| ' Sort the range.
40| oCellRange.Sort(oSortDesc())
41|End Sub

Overview of BeanShell, JavaScript, and Python macros


Introduction
Many programmers may not be familiar with LibreOffice Basic and so Calc supports macros
written in three other languages that may be more familiar. These are BeanShell, JavaScript,
and Python.
The primary macro scripting language for Calc is LibreOffice Basic and the standard LibreOffice
installation provides a powerful integrated development environment (IDE) together with more
options for this language.
Macros are organized in the same way for all four scripting languages. The LibreOffice Macros
container holds all the macros that are supplied in the LibreOffice installation. The My Macros

Chapter 14 Macros | 469


library container holds your macros that are available to any of your LibreOffice documents.
Each document can also contain your macros that are not available to any other document.
When you use the macro recording facility, Calc creates the macro in LibreOffice Basic. To use
the other available scripting languages you must write the code yourself.
When you select to run a macro using Tools > Macros > Run Macro on the Menu bar, Calc
displays the Macro Selector dialog. This dialog enables the selection and running of any
available macro, coded in any of the available languages (Figure 497).
When you select to edit a macro using Tools > Macros > Edit Macros on the Menu bar, Calc
displays the LibreOffice Basic IDE. This dialog enables selection and editing of any available
LibreOffice Basic macro, but not macros in other languages.
The component model used in LibreOffice is known as Universal Network Objects or UNO.
LibreOffice macros in any scripting language use a UNO runtime application programming
interface (API). The XSCRIPTCONTEXT interface is provided to macro scripts in all four languages
and provides a means of access to the various interfaces which they might need to perform
some action on a document.

Figure 497: Macro Selector dialog

BeanShell macros
BeanShell is a Java-like scripting language that was first released in 1999.
When you select Tools > Macros > Organize Macros > BeanShell on the Menu bar, Calc
displays the BeanShell Macros dialog (Figure 498).

470 |Calc Guide 24.8


Figure 498: BeanShell Macros dialog
Click the Edit button on the BeanShell Macros dialog to access the BeanShell Debug Window
(Figure 499).

Figure 499: BeanShell Debug Window


Listing 10 is an example of a BeanShell macro that inserts the text “Hello World from BeanShell”
in cell A1 of the active Calc spreadsheet.
Listing 10. Sample BeanShell macro
1|import com.sun.star.uno.UnoRuntime;
2|import com.sun.star.sheet.XSpreadsheetView;
3|import com.sun.star.text.XText;
4|model = XSCRIPTCONTEXT.getDocument();
5|
6|controller = model.getCurrentController();

Chapter 14 Macros | 471


7|
8|view = UnoRuntime.queryInterface(XSpreadsheetView.class, controller);
9|
10|sheet = view.getActiveSheet();
11|
12|cell = sheet.getCellByPosition(0, 0);
13|
14|cellText = UnoRuntime.queryInterface(XText.class, cell);
15|
16|textCursor = cellText.createTextCursor();
17|
18|cellText.insertString(textCursor, "Hello World from BeanShell", true);
19|
20|return 0;

JavaScript macros
JavaScript is a high-level scripting language that was first released in 1995.
When you select Tools > Macros > Organize Macros > JavaScript on the Menu bar, Calc
displays the JavaScript Macros dialog (Figure 500).

Figure 500: JavaScript Macros dialog

Note
You cannot edit JavaScript macros inside LibreOffice. You must edit the macro on an
external editor.
Listing 11 is an example of a JavaScript macro that inserts the text “Hello World from JavaScript”
in cell A1 of the first sheet in a Calc spreadsheet.
Listing 11. Sample JavaScript macro
1|importClass(Packages.com.sun.star.uno.UnoRuntime);
2|importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
3|importClass(Packages.com.sun.star.container.XIndexAccess);
4|importClass(Packages.com.sun.star.table.XCellRange);
5|importClass(Packages.com.sun.star.table.XCell);
6|
7|documentRef = XSCRIPTCONTEXT.getDocument();
8|
9|spreadsheetInterface = UnoRuntime.queryInterface(XSpreadsheetDocument,
documentRef);

472 |Calc Guide 24.8


10|
11|allSheets = UnoRuntime.queryInterface(XIndexAccess,
spreadsheetInterface.getSheets());
12|
13|theSheet = allSheets.getByIndex(0);
14|
15|Cells = UnoRuntime.queryInterface(XCellRange,theSheet);
16|
17|cellA1 = Cells.getCellByPosition(0,0);
18|
19|theCell = UnoRuntime.queryInterface(XCell,cellA1);
20|
21|theCell.setFormula("Hello World from JavaScript");

Python macros
Python is a high-level, general-purpose programming language that was first released in 1991.
In recent years it has grown in popularity and is commonly used by data scientists
When you select Tools > Macros > Organize Macros > Python on the Menu bar, Calc displays
the Python Macros dialog (Figure 501).

Figure 501: Python Macros dialog


Facilities to edit and debug Python scripts are not currently integrated into the standard
LibreOffice user interface. However, you can edit Python scripts with your preferred text editor or
an external IDE. The Alternative Python Script Organizer (APSO) extension eases the editing of
Python scripts, in particular when embedded in a document. Using APSO you can configure your
preferred source code editor, start the integrated Python shell and debug Python scripts.
For more information search for “Python macros” in the LibreOffice Help system and visit the
Designing & Developing Python Applications section of The Document Foundation’s wiki
(https://wiki.documentfoundation.org/Macros/Python_Design_Guide).
Listing 12 is an example of a Python macro that sets cell A1 of the first sheet in a Calc
spreadsheet to the text “Hello World from Python”.
Listing 12. Sample Python macro
1|import uno
2|
3|def HelloWorld():

Chapter 14 Macros | 473


4| doc = XSCRIPTCONTEXT.getDocument()
5| cell = doc.Sheets[0]['A1']
6| cell.setString('Hello World from Python')
7| return

ScriptForge library
Macro programmers frequently need to perform tasks such as creating and opening files,
accessing form controls, reading data from databases embedded in LibreOffice Base
documents, and so forth. The objective of the ScriptForge library is to simplify the creation of
macros by making it easier to execute such commands without having to learn the required
LibreOffice APIs (Application Programming Interfaces) and commands, which may be difficult for
casual programmers.
The ScriptForge library supports both LibreOffice Basic and Python. It is organized into a set of
services, each of which provides methods and properties related to a specific topic. For
example, the Dialog service provides access to dialogs available in script modules and the
Database service allows execution of SQL commands in Base documents.
Chapter Getting Started with Macros, of the Getting Started Guide contains additional
introductory material about the ScriptForge library and includes a simple example. More detailed
information and many examples can be found in the LibreOffice Help system, by searching for
the term “ScriptForge” in the index.

Built-in object inspector


LibreOffice has an extensive API (Application Programming Interface) that can be used by macro
programmers to automate almost any aspect of its applications. However, one of the main
challenges for programmers is to discover UNO (Universal Network Objects) object types as well
as their supported services, methods, and properties.
The built-in object inspector can be used to help macro developers inspect objects and discover
how they can be accessed and used. To access this tool, go to Tools > Development Tools on
the Menu bar and an object inspector window (Figure 502) will be opened. By default this
window is docked at the bottom of the user interface.
The left portion of the window consists of the Document Object Model (DOM) navigator, which
allows the user to navigate through all the objects in the document. When an object is selected,
the following information about the object is shown on tabs within the right portion of the window:
• The names of all implemented interfaces.
• The names of all services supported by the object.
• The names and types of all properties available in the object.
• The names, arguments and return types of all methods that can be called by the object.
Instead of inspecting objects using the DOM navigator, it is possible to directly inspect the
currently selected object in the document by toggling the Current Selection button.

474 |Calc Guide 24.8


Figure 502: Object inspector window
“Getting Started with Macros” in the Getting Started Guide contains additional information about
the built-in object inspector. More detailed information and examples can be found in the
LibreOffice Help system, by searching for the term “development tools” in the help index.

Working with VBA macros


For the Excel/VBA programmer, LibreOffice Basic is a programming language very similar to
VBA. The primary reason that VBA does not work in Calc, even though Calc can read the Excel
workbook, is that Calc uses a different mechanism to access the workbook (called spreadsheet
in Calc) components, such as cells on the worksheet (called sheet in Calc). Specifically, the
objects, attributes, and methods use different names and the corresponding behavior is
sometimes slightly different.
To convert VBA code, you must first load the VBA code in LibreOffice.

Loading VBA code


On the VBA Properties page (Tools > Options > Load/Save > VBA Properties), you can
choose whether to keep any macros in Microsoft Office documents that are opened in
LibreOffice.

Figure 503: Choosing Load/Save VBA Properties


If you choose Load Basic code, you can edit the macros in LibreOffice. The changed code is
saved in an ODF document but is not retained if you save it into a Microsoft Office format.

Chapter 14 Macros | 475


If you choose Save original Basic code, the macros will not work in LibreOffice but are retained
unchanged if you save the file into Microsoft Office format.
If you are importing a Microsoft Word or Excel file containing VBA code, you can select the
option Executable code. Whereas normally the code is preserved but rendered inactive (if you
inspect it with the Basic IDE you will notice that it is all commented), with this option the code is
ready to be executed.
Save original Basic code takes precedence over Load Basic code. If both options are
selected and you edit the disabled code in LibreOffice, the original VBA code will be saved when
saving in a Microsoft Office format.
To remove any possible macro viruses from the Microsoft Office document, deselect Save
original Basic code. The document will be saved without the VBA code.

Option VBASupport statement


The Option VBASupport statement specifies that LibreOffice Basic will support some VBA
statements, functions, and objects. The statement must be added before the executable
program code in a module.

Note
The support for VBA is not complete but covers a large portion of the common usage
patterns.
When VBASupport is enabled, LibreOffice Basic function arguments and return values are the
same as their VBA counterparts. When the support is disabled, LibreOffice Basic functions may
accept arguments and return values different from their VBA counterparts.
Listing 13. Option VBASupport usage
1|Option VBASupport 1
2|Sub Example
3| Dim sVar As Single
4| sVar = Worksheets("Sheet1").Range("A1")
5| Print sVar
6|End Sub
Without the Option VBASupport statement, the code in Listing 13 must be converted to the
LibreOffice Basic of Listing 14.
Listing 14. Converted VBA code
1|Sub Example
2| Dim sVar As Single
3| Dim oSheet as Object
4| Dim oCell as Object
5| ' Worksheets(“Sheet1”).
6| oSheet = ThisComponent.getSheets().getByIndex(0)
7| ' Range("A1")
8| oCell = oSheet.getCellByPosition(0, 0)
9| sVar = oCell.getValue()
10| Print sVar
11|End Sub
Option VBASupport may affect or assist in the following situations:
• Allow special characters as identifiers. All characters that are defined as letters in the
Latin-1 (ISO 8859-1) character set, are accepted as part of identifiers. For example,
variables with accented characters in their names.
• Create VBA constants including non-printable characters (vbCrLf, vbNewLine,...).

476 |Calc Guide 24.8


• Support Private/Public keywords for procedures.
• Compulsory Set statement for objects.
• Default values for optional parameters in procedures.
• Named arguments when multiple optional parameters exist.
• Preload of LibreOffice Basic libraries.

VBA UserForms (LibreOffice Basic Dialogs)


UserForms (Dialogs) appear frequently in macros that demand your interaction and parameter
selections. The code snippet below is a recipe for such conversions, which are not handled
automatically by VBA options.
Listing 15. VBA display of a UserForm [Dialog] called “MyForm”
1|Sub MyProc
2| MyForm.Show
3|End Sub
Listing 16. LibreOffice Basic display of a UserForm [Dialog] called “MyForm”
' oDlg should be visible at the module level
1|Dim oDlg As Object
2|Sub MyProc
3| DialogLibraries.LoadLibrary("Standard")
4| oDlg = CreateUnoDialog(DialogLibraries.Standard.MyForm)
5| oDlg.execute()
6|End Sub

Note
The oDlg variable is visible at the module level to all other procedures that are
accessing controls on the dialog. This means all the procedures manipulating or
accessing controls on this dialog panel are housed in a single module.

Conclusion
This chapter provides an overview of how to create libraries and modules, using the macro
recorder, using macros as Calc functions, writing your own macros without the macro recorder,
and converting VBA to LibreOffice Basic. Each topic deserves at least one chapter, and writing
your own macros for Calc could easily fill an entire book. In other words, this is just the
beginning of what you can learn.
If you are already familiar with the BASIC language (or with one programming language), the
LibreOffice Extensions website (https://extensions.libreoffice.org) has a set of LibreOffice Basic
quick reference cards. These can be located quickly by selecting the Documentation and Macro
tag filters.
Additional detail about Calc’s macro facilities can be obtained from the LibreOffice Help system
(search for “macros” in the index for general information, or search for “VBA Support” to find
some specific VBA Support information), The Document Foundation’s wiki pages
(https://wiki.documentfoundation.org/Macros) and other Internet sources (for example the
https://ask.libreoffice.org/ Q&A site).

Chapter 14 Macros | 477


Calc Guide 24.8

Chapter 15
Calc as a Database
Introduction
In many everyday scenarios, Calc spreadsheets can be used to aggregate sets of data and to
perform analyses on them. As the data in a spreadsheet is laid out in a table view, plainly visible
and easily edited or extended, some users may not need the comprehensive relational database
facilities provided by the Base component of LibreOffice. For such users, Calc has sufficient
functionality to act as a simple yet capable database-like platform. This chapter presents an
overview of these capabilities.
For those users who initially choose to manage their data in a Calc spreadsheet and
subsequently decide that they need to use a more comprehensive database system, migrating
Calc data to Base is straightforward. In the other direction, for Base users who wish to take
advantage of some of Calc’s features to analyze or visualize their data, Base can be used for
creating linked data ranges in Calc files, for pivot table analysis, or as the basis for charts. See
the Base Guide for more information.
Earlier versions of this chapter contained several examples with LibreOffice Basic macros.
These are now available on The Document Foundation’s wiki at
https://wiki.documentfoundation.org/Macros/Calc. Much of the macro information on those pages
is drawn or adapted from Andrew Pitonyak’s book, OpenOffice.org Macros Explained (OOME)
and LibreOffice’s API reference at https://api.libreoffice.org/docs/idl/ref/index.html.

A database primer
In a typical database, related data is organized into tables, which are arranged in a grid-like
series of rows and columns similar to a spreadsheet. Each row of a table represents a data
record, while each column represents a field within each record. Each cell in a field contains an
individual data item or attribute, such as a name, while each record consists of related attributes
that correspond to a single entity, like a person. A database table tends to have a fixed number
of fields, but can have an indefinite number of records.
While a table may have hundreds or thousands of rows, individual records can be easily found,
retrieved, and updated using information requests, called queries, that search for records that
meet a specified set of criteria. It is this ease of access that makes a database table more useful
than simply filing away information in an unordered spreadsheet.
To illustrate this concept of a database table, consider the example of a class grading sheet
(Figure 504). In this sheet, each row represents individual students taking the class, while each
column contains their names and grades. With this table, you can quickly look up individual
students’ grades simply by searching for their names, and you can determine which students are
passing the class by filtering out records with failing average scores.

Figure 504: Grading sheet example


Many modern database management systems are based on the relational database model, in
which the data and relationships are represented by a series of inter-related tables. The Base

480 |Calc Guide 24.8


component of LibreOffice is a fully featured relational database management system. Calc does
not support the relational database model.

Calc as a database-like program


A Calc sheet is similar to a flat, non-relational database table, and it is possible for a database
table to be contained in a Calc sheet. The data can be deeply analyzed using a wide range of
tools and functions. It can be sorted, filtered, pivoted, and presented visually in 2-D/3-D charts
and graphics. Calc is not a replacement for a fully featured database application but it can be
useful for managing data in many small-scale personal or professional contexts.

Associating a range with a name


In order to set up a database table in a Calc sheet, you first need to set up an area for it to
occupy. This is necessary since some of Calc’s database-like features depend on accessing or
modifying a table’s location. Such an area is represented by a range, which is a contiguous
group of one or more cells. To make the range for a table easy to access, you can assign a
meaningful name to it. Doing this has four particular benefits:
• Giving a range a name makes it easier to identify, especially if you are working with
multiple ranges in a document.
• A named range can be referenced by its name rather than just by its address. For
example, if you have a range named Scores, you can simply reference it in a cell with a
formula like =SUM(Scores).
• References by name to a named range are automatically updated every time the
range’s address is changed. This avoids the need to change individual references
every time a range’s location is modified.
• All named ranges can be quickly viewed and accessed through the Navigator,
which is opened by selecting View > Navigator on the Menu bar, pressing the F5 key, or
clicking the Navigator icon on the Sidebar tab panel.
Two types of named range exist in Calc: database ranges, which store settings for database-like
operations, and standard named ranges, which do not.

Named ranges
Technically a named range is a named formula expression and its content is always set as a
string. A commonly used type of expression is an absolute cell range like
“$Sheet1.$A$1:$E$15”. However, other expression types are possible. For example, the
expression “$Sheet1.$A$1:$A$4~$Sheet1.$B$1:$B$4” encompasses two separate cell
ranges (the tilde character is a reference concatenation operator). Alternatively a formula
expression such as “PI()*B1*B1” might be defined to calculate the area of a circle, given the
radius. In the remainder of this section we will be concerned only with named ranges defined as
a single matrix-like cell range.
A quick way of creating a new named range is to select the relevant cells in your sheet and then
simply start typing a name in the Name Box, located at the left of the Formula bar. Notice the
“Define Name for Range” tooltip that appears as you type and press the Enter key when you
have finished typing.
Named ranges are also created using the Define Name dialog (Figure 505), which is opened
either by selecting Sheet > Named Ranges and Expressions > Define on the Menu bar or by
clicking the Add button on the Manage Names dialog (Figure 506).

Chapter 15 Calc as a Database | 481


Figure 505: Define Name dialog
To create a named range, select a range of cells from a sheet, then open the Define Name
dialog. Next, give the range a meaningful name, and click on Add to add it to the current
document’s list of named ranges. You can then access and modify these ranges using the
Manage Names dialog (Figure 506), which is opened by selecting Sheet > Named Ranges and
Expressions > Manage on the Menu bar, or pressing Ctrl+F3, or selecting Manage Names in
the Name Box located at the left of the Formula bar.

Figure 506: Manage Names dialog


To reduce the typing required when referencing a named range, a Paste Names dialog (Figure
507) can be accessed by selecting Insert > Named Range or Expression or Sheet > Named
Ranges and Expressions > Insert on the Menu bar. Select the entry for the relevant named

482 |Calc Guide 24.8


range and click the Paste button to insert the selected named range at the current cursor
position.

Figure 507: Paste Names dialog


For more detail about how to create and manage ranges, see Chapter 8, Printing, Exporting,
Emailing, and Signing, and Chapter 9, Using Formulas and Functions.

Creating named ranges using row or column headers


With the Create Names tool, which is accessed by selecting Sheet > Named Ranges and
Expressions > Create on the Menu bar (Figure 508), you can create multiple named ranges
simultaneously from the headers of a table. These headers can be drawn from the table’s
borders – top and bottom rows, and left and right columns – and each row or column that
corresponds to a header is used to create the named ranges themselves. For example, if you
choose to create ranges from headers contained in the top row of a table, each range will be
generated from the individual columns that correspond to each header label.

Note
Header cells are not included in the named ranges generated using the Create
Names tool. This is because the labels in each of these cells are used to name the
ranges.

Figure 508: Create Names dialog


To use the Create Names tool:
1) In a sheet, select the table from which to create the named ranges. Be sure to include
the header rows or columns as part of your selection.
2) Open the Create Names dialog by selecting Sheet > Named Ranges and Expressions
> Create on the Menu bar.

Chapter 15 Calc as a Database | 483


3) Calc automatically identifies which rows or columns contain headers, and will mark the
checkboxes – Top row, Left column, Bottom row, Right column – that apply.
However, if you wish to change this selection, you can manually select or deselect any of
the boxes at this point.
4) Click OK to close the dialog and create the new named ranges.

Tip
Avoid giving multiple rows or columns the same label, as the ranges generated from
them will likewise share the same name, and can end up being overwritten by Calc.

Database ranges
Although it can be used like a regular named range, a database range is intended to be used
like a database table, with each row representing a record and each cell a field within a record.
Specifically, a database range differs from a named range in the following ways:
• A database range cannot be a formula expression, only a single rectangular cell range.
This range can be formatted as a table, with the first row reserved for headings and the
last row for subtotals. Cell formatting can also be preserved for each field in the table.
• Database ranges cannot be referenced relative to a base address within a sheet, which
is possible with a named range.
• Database ranges store sorting, filtering, subtotaling, and data import settings in data
structures called descriptors, which can be retrieved and accessed using macros. All
descriptors of a database range are updated when a database operation is carried out on
the cell range of the database range.
• Unlike a named range, a database range can be connected to an external data source,
from where you can fetch data into the spreadsheet document.
Database ranges can be created, modified, and deleted using the Define Database Range
dialog (Figure 509).

Figure 509: Define Database Range dialog

484 |Calc Guide 24.8


To create a database range:
1) If you want Calc to automatically determine the full extent of your database table, then
select a single cell within its cell area. If you want to explicitly define the extent of the
database table, then select all relevant cells.
2) Open the Define Database Range dialog by selecting Data > Define Range on the Menu
bar.
3) Type a name for the range in the Name field. Only use letters, numbers, and
underscores; spaces, hyphens, and other characters are not allowed.
4) Click on the expand symbol (usually a plus or a triangle) next to the Options label to
expand this section and view and select the following options:
– Contains column labels – Denotes whether the top row is reserved for field headings.
– Contains totals row – Denotes whether the bottom row is reserved for totals.
– Insert or delete cells – If active, this option will insert new rows and columns into the
database range when new records are added to its source. Only relevant if an external
database source is linked to the range. To manually update the database range, use
Data > Refresh Range on the Menu bar.
– Keep formatting – Applies the existing cell formats of the first data row to the whole
database range.
– Don’t save imported data – If selected, this option only saves a reference to the source
database; the contents of the range’s cells are not preserved.
– Source – Displays information about the current database source, if one exists. For
example, “Bibliography/biblio”.
– Operations – Denotes what operations (if any) have been applied to the database
range. For example, “Sort”, “Filter”, or “Subtotals”.
5) Click Add to add a range to the database range list under the Name field.
6) Click OK to close the dialog and save the database range.
To modify an existing database range:
1) Open the Define Database Range dialog by selecting Data > Define Range on the Menu
bar.
2) Select a range from the range list under the Name field or type its name into the Name
field. The Add button will change to Modify at this point.
3) Make any modifications in the Range field and the Options section.
4) Click Modify to update the database range.
5) Click OK to close the dialog and save the modified database range.
To delete an existing database range:
1) Open the Define Database Range dialog by selecting Data > Define Range on the Menu
bar.
2) Select the range to be deleted from the list in the upper section of the dialog.
3) Click Delete and then click the Yes button on the confirmation dialog that appears.
4) Click OK to close the Define Database Range dialog.
To select an existing database range from the current document, open the Select Database
Range dialog by choosing Data > Select Range on the Menu bar (Figure 510). Next, select a
range in the Ranges list and click OK. Another way to select an existing database range is using

Chapter 15 Calc as a Database | 485


the Navigator deck on the Sidebar. Calc will automatically highlight the range’s position in the
sheet in which it is located.

Figure 510: Select Database Range dialog

Fetching data from data sources


To fetch data from a data source to create a new database range, carry out the following steps:
1) Open the Data Sources Explorer by selecting View > Data Sources on the Menu bar or
pressing Ctrl+Shift+F4.
2) In the left pane of the Data Sources Explorer, click the expand symbol at the left of the
data source name of interest. This action opens the tree to display the tables or queries
associated with the data source.
3) Click on the required table or query to display its constituent data in the right pane of the
Data Sources Explorer.
4) Click on the blank rectangular area at the top left corner of the right pane of the Data
Sources Explorer to select all the data in the displayed table or query.
5) Drag and drop the data to the cell that is to be at the top left corner of the data in your
spreadsheet. Search for “drag and drop – data source view” in the Help system for more
information about dragging and dropping data from the Data Sources Explorer.
6) Calc automatically creates a new database range with default parameters,
encompassing the cell range of the imported data and with a default name of the form
Import1, Import2, etc.
7) If required, access the Define Database Range dialog (Figure 509) to update settings of
the new database range.
Select Data > Refresh Range on the Menu bar to refresh the contents of a database range
once the data in the associated data source is updated. The data in the sheet is updated to
match the data in the external database. Registering and linking to external database sources
are explained in more detail in Chapter 12, Linking Data.

Referencing in a Calc Database Table


LibreOffice can make formulas in Calc database tables easier to read and maintain, by
referencing a cell rectangle or the entire database range without using direct references like
$B$1:$D$23. To use database tables references you need to know:
• the name of the database range;
• its field names, usually given by the first row of the database range;
• specific reference keywords;

486 |Calc Guide 24.8


For example: myData[[#Totals];[Sales]]
This concept is similar to “structured references" for a "table" in Microsoft Excel. An Excel "table"
is loaded as a database-range in Calc.

Note
When saving as an .xlsx file in Excel, "structured references" are retained. However,
in Calc, the ODF standard does not yet have the means to save "structured
references". When saving as an .ods file, a "structured reference" is converted into a
direct reference using the values present at the time of saving.

Setting up a table
Spreadsheet "tables" are defined by database ranges (Data > Define Range). See Database
ranges above. In addition to the name of the database, the following is mandatory for using
"structured references":
• Tables must be vertically oriented.
• Tables must have column labels, if interoperability with Excel is required.
• The column label names must follow the named range rules. See Named ranges above.
The table below contains values used in examples later on in this document.
A B C D
1 Name Region Sales Seniority
2 Smith West 21 5
3 Jones East 23 11
4 Johnson East 9 7
5 Taylor West 34 11
6 Brown East 23 15
7 Walker East 12 4
8 Edwards East 15 12
9 Thomas West 17 10
10 Wilson West 31 3
11 Totals 2 185 8.67
The cell range A1:D11 was defined as database range "myData". The options Contains column
labels and Contains totals row were checked when defining the database range (Figure 509).

Reserved reference keywords


[#Headers]
The keyword [#Headers] references the row of field names (column labels). It is the first
row of the database range.
Example: The expression myData[#Headers] references the cells A1:D1.
If the database range has no labels, a #REF! error is generated.
[#Data]
The keyword [#Data] references the data records of the database range, excluding the
columns header row and the totals row.

Chapter 15 Calc as a Database | 487


Example: The expression myData[#Data] references the cell rectangle A2:D10.
The short form myData[] can be used as well.
[#Totals]
The keyword [#Totals] references the row of totals. It is the last row of the database
range.
Example: The expression myData[#Totals] references the cells A11:D11.
If the database range has no totals, a #REF! error is generated.
[#All]
The keyword [#All] references the entire database range including column headers
and totals.
Example: The expression myData[#All] references the cells A1:D11.
[#This Row]
This keyword describes an implicit intersection. See Implicit intersection of array
formulas in Chapter 89 – Using Formulas and Functions for more information and
examples.
Example: If the expression myData[#This Row] is used in a formula in cell F2, it
references A2:D2. If the same expression is used in a formula in cell F5, it references
A5:D5.

Note
The intersection is only possible with rows of the database range. A similar This
Column does not exist. If a database row does not exist in the row where the formula
is placed, a #VALUE! error is generated.

Tip
When switching from Excel to Calc, Excel does not allow the keyword [#This Row]
for the entire table range. If applied to non-data record rows, such as header or totals
rows, an error is produced.
In the user interface, Excel uses the short form myData[@]. This implicit intersection operator @
is not currently available in Calc.

Referencing data in tables


A "structured reference" to cells in a database range has the form name of database range […]
where the part inside the square brackets can be one of the keywords described in the previous
section, a field name in square brackets, or a combination of the two.
In case a single keyword or a single field name is used, single brackets are used instead of
double brackets. For example: myData[#Headers] instead of myData[[#Headers]] or
myData[Region] instead of myData[[Region]].

Field name in square brackets


To address the array of all values in the records that belong to the same field, use the form
[field name]. The referenced cell range does not include label and totals. For example, the
expression myData[[Region]] or its simplified form myData[Region] references the cells
B2:B10. If the database range has no label row, generic labels like Column1, Column2 can be
used.

488 |Calc Guide 24.8


Note
In Excel, if the formula cell belongs to the table, then the name of the table may be
omitted. For example, the formula =SUM(myData[Sales]) in cell C11 could be
written as =SUM([Sales]). Omission of the table name is not yet possible in Calc.

Combinations
To reference a combination of the labels row and data records, use the format [#Headers];
[#Data] or [#Headers],[#Data], where the separator is the same separator as for function
parameters. So whether to use a semicolon or a comma depends on the setting defined in Tools
> Options > Calc > Formula.
To reference a combination of data records and totals row, use [#Data];[#Totals]. For
example, myData[[#Data];[#Totals]] references the cells A2:D11.
A combination like [#Headers];[#Totals] is not possible as that would result in two disjoint
cell rectangles.
To address several adjacent columns, use the range operator “:”. For example, the formula
myData[[Name]:[Sales]] addresses the cells A2:C10.
The use of non-adjacent columns is not possible since it would reference two separate cell
rectangles.
The reference via field name and the use of a reference keyword can be combined, first the
keyword, then function separator and last the field name in brackets. For example,
myData[[#Totals];[Sales]] references the cell C11.

Using structured references


The use of structured references is only allowed if the database range has a vertical orientation.
Using a structured reference on a horizontally oriented database range will produce invalid
results without producing an error message.
A direct use such as =myData[#Headers] is possible. The generated array Names Region
Sales Seniority spills over 4 columns.

Note
Instead of using the formula =myData. which will copy the entire database range in
LibreOffice and then produce an error when opened in Excel, use the formula
=myData[#All].
The output array or value of a structured reference can be used as input to other functions. For
example, the cells in row 11 have these formulas:
B11 =COUNTA(UNIQUE(myData[Region]))
C11 =SUM(myData[Sales])
D11 =AVERAGE(myData[Seniority])
If a formula uses a structured reference and it references an array of more than one cell, then
the formula has to be handled as array formula that has enclosing curly brackets in the input line
like {=myData[#Headers]}.

Sorting
Sorting is the process of rearranging data in a range or a sheet according to a specified sort
order.

Chapter 15 Calc as a Database | 489


The simplest way to sort a database table based on the contents of a single column is to use the
Sort Ascending and Sort Descending tools, as follows:
1) Select any cell in the column.
2) To sort in ascending order, select Data > Sort Ascending on the Menu bar or click the
Sort Ascending icon on the Standard toolbar. If you have enabled AutoFilters (see next
section), you can also select Sort Ascending on the relevant column’s AutoFilter combo
box.
3) To sort in descending order, select Data > Sort Descending on the Menu bar or click the
Sort Descending icon on the Standard toolbar. If you have enabled AutoFilters, you can
also select Sort Descending on the relevant column’s AutoFilter combo box.
When using the Sort Ascending and Sort Descending tools, Calc automatically identifies the full
cell range occupied by your table and sorts the entire area based only on the values in the
indicated column. However, it also recognizes the first row as a header row and excludes it from
the sort.
The AutoFilter combo box described in the “Filtering” section also provides Sort Ascending and
Sort Descending options, in addition to a Sort by Color menu which allows sorting by cell
background or font colors.
For more complex sorting, use the Sort dialog (Figure 511), which is accessed by selecting Data
> Sort on the Menu bar or by clicking the Sort icon on the Standard toolbar. If you select just
one cell within the database table before accessing the Sort dialog, then the entire table will be
shown as selected when the dialog is displayed.

Figure 511: Sort dialog


On the Sort Criteria tab of the dialog, you can specify three levels of sorting. The data is
sorted first by the values in the column selected in the Sort Key 1 drop-down, second by the
values in the column selected in the Sort Key 2 drop-down, and third by the values in the column
selected in the Sort Key 3 drop-down. Checking the Headers option will exclude the first row (for
column sorting) or column (for row sorting) from sorting with the rest of the data.
The Options tab of the Sort dialog provides additional sorting options. For more information
about how to use this dialog and its options, see Chapter 2, Entering and Editing Data, and the
Help system.

490 |Calc Guide 24.8


Filtering
A filter is a tool that hides or displays records within a sheet based on a set of filtering criteria.
Similar to sorting, filters are useful for narrowing down long lists of data in order to find particular
data items. In Calc, three types of filter exist:
• AutoFilters
• Standard filters
• Advanced filters
If you want to remove any filtering applied to your database table, simply select Data > More
Filters > Reset Filter on the Menu bar.
Filters are also described in Chapter 2, Entering and Editing Data.

AutoFilter
AutoFilters are the most straightforward of the three filter types. They work by providing access
to a combo box through a down-arrow button located at the top of one or more data columns. To
add AutoFilters to all columns of a database table, click on a cell anywhere within the table area
and then select Data > AutoFilter on the Menu bar, click the AutoFilter icon on the Standard
toolbar, or press Ctrl+Shift+L. It is possible to add AutoFilters to individual columns by
selecting those columns before choosing Data > AutoFilter, clicking the AutoFilter icon, or
pressing Ctrl+Shift+L, but this is not normally necessary for a database table. To access the
AutoFilter combo box for a column, click on the down-arrow button in the header cell of that
column.
To remove AutoFilters from all columns of a database table, click on a cell anywhere within the
table area and select Data > AutoFilter on the Menu bar, select Data > More Filters > Hide
AutoFilter on the Menu bar, click the AutoFilter icon on the Standard toolbar, or press
Ctrl+Shift+L. The down-arrow buttons at the tops of columns will disappear.

Tip
Selecting Data > AutoFilter, clicking the AutoFilter icon, and pressing
Ctrl+Shift+L toggle AutoFilters on/off.

Each AutoFilter combo box (Figure 512) provides the following options:
• A basic sort can be applied using the Sort Ascending and Sort Descending options.
• Use the Sort by Color menu to sort entries by background or font color, based on any
such color that appears in the column of interest.
• Use the Filter by Color menu to filter entries by background or font color for any such
color that appears in the column of interest.
• The Filter by Conditions menu provides Empty, Not Empty, Top 10, and Bottom 10
filter options. In addition the menu contains a menu item to access the Standard Filter
dialog (Figure 513).
• Check the All box to display or hide all values in the current column.
• Show only the current item and Hide only the current item shortcut buttons are
provided, located adjacent to the All box. In the context of these buttons, the term
“current” refers to the item highlighted in the set of check boxes below the buttons (for
example the “1” in Figure 512).
• If any filter has been applied to a column, use the Clear Filter option to remove all filters
defined for that column.

Chapter 15 Calc as a Database | 491


• The AutoFilter combo box includes check boxes for each unique value in the current
column. If a check box is not ticked, rows of the database table that contain that value in
this column are not displayed. Change the filtering status of a particular value by marking
or removing the mark from the relevant check box.
For more information on how to use the AutoFilter combo box and its options, see Chapter 2,
Entering and Editing Data.

Figure 512: Autofilter combo box

Standard filters
Standard filters are more complex than AutoFilters, and allow for up to eight filter conditions.
Powerful filters can be set up using regular expressions. Also, unlike AutoFilters, standard filters
use a dialog (Figure 513), which is accessed by selecting Data > More Filters > Standard Filter
on the Menu bar or the Standard Filter option on an AutoFilter combo box.
For more information on how to use this dialog and its options, see Chapter 2, Entering and
Editing Data.

492 |Calc Guide 24.8


Figure 513: Standard Filter dialog

Advanced filters
The criteria for an advanced filter are stored in a sheet rather than entered into a dialog. As a
result, you must first set up a cell range that contains the criteria before you use the Advanced
Filter dialog (Figure 514).

Figure 514: Advanced Filter dialog


To set up a criteria range:
1) Copy the column headings of the range to be filtered to an empty space in a sheet. It
does not need to be the same sheet as the one with the source range.
2) Enter filter criteria underneath the column headings in the criteria range. Each individual
criterion in the same row is connected with AND, while the criteria groups from each row
are connected with OR. Empty cells are ignored. Up to eight criteria rows may be defined
for a filter.

Tip
Although it is possible for the criteria area to contain only the headings for columns
with defined filter criteria, for simplicity you may choose to copy all of your database
table’s headings to the criteria area.

Chapter 15 Calc as a Database | 493


After creating a criteria range, set up an advanced filter as follows:
1) Select the cell range that you wish to filter. For a database table you can simply click a
cell within the table area and Calc will automatically select the whole table as it opens the
dialog at step 2).
2) Go to Data > More Filters > Advanced Filter on the Menu bar to open the Advanced
Filter dialog (Figure 514).
3) In the Read Filter Criteria From field, enter the address for the criteria range, either by
selecting a named range from the drop-down box, typing in a reference, or selecting cells
from a sheet. Remember to use the Shrink / Expand button if you need to temporarily
minimize the dialog while selecting cells.
4) Click OK to apply the filter and close the dialog.

Note
For an individual named range, it is possible to tick a Filter checkbox on the Define
Name and Manage Names dialogs (Figures 505 and 506 respectively). Only named
ranges marked for filtering in this way can be selected in the drop-down box in the
Read Filter Criteria From area of the Advanced Filter dialog. Database ranges cannot
be selected in the drop-down box.
Advanced filter options are the same as standard filter options, and are described in further
detail in Chapter 2, Entering and Editing Data.
Figure 515 demonstrates an example criteria range for the grading sheet example in Figure 504.

Figure 515: Advanced filter criteria range (in Sheet 2)


In this range, there are two criteria groups: the first displays the records of students who scored
above a 75% in every homework, and the second displays records of any student named
“Ferdinand”. Figure 516 displays the result of this filter operation using these criteria.

Figure 516: Grading sheet example filtered using an advanced filter

Useful database-like functions


Database category functions
The twelve functions in the Database category are intended to help you analyze a simple
database that occupies a rectangular spreadsheet area comprising columns and rows, with the

494 |Calc Guide 24.8


data organized as one row for each record. The header cell of each column displays the name of
the column and that name usually reflects the contents of each cell in that column.
The functions in the Database category take three arguments as follows:
1) Database. The cell range of the database.
2) DatabaseField. The column containing the data to be used in the function’s calculations.
3) SearchCriteria. The cell range of a separate area of the spreadsheet containing search
criteria.
These arguments are described more fully below.
All functions have the same simple concept of operation. The first logical step is to use the
specified SearchCriteria to identify the subset of records in the Database that are to be used
during subsequent calculations. The second step is to extract the data values and perform the
calculations associated with the specific function (average, sum, product, and so on). The values
processed are those in the DatabaseField column of the selected records.

Database function arguments


The following argument definitions apply for all functions in the Database category:
Database argument
Database specifies the range of cells occupied by the database table. The first row of
the range contains the field names, and subsequent rows are records with corresponding
field values.
One way of defining the range of cells is to enter the cell reference for the upper left-
hand cell, followed by a colon (:), and then the lower right-hand cell reference. An
example might be A1:E10.
The Database argument may also be specified by passing the name of a named range
or database range. Using a meaningful name to define the cell range can enhance
formula readability and document maintenance. If the name does not match the name of
a defined range, Calc reports a #NAME? error.
Other errors that might be reported as a result of an invalid Database argument are
#VALUE! and Err:504 (error in parameter list).
DatabaseField argument
DatabaseField specifies the column which the function will use for its calculations after
the search criteria have been applied and the data rows have been selected. It is not
related to the search criteria.
Specify the DatabaseField argument in any of the following ways:
– By entering a reference to a header cell within the Database area. Alternatively, if the
cell has been given a meaningful name as a named range or database range, enter
that name. If the name does not match the name of a defined range, Calc reports a
#NAME? error. If the name is valid but does not correspond to one cell only, Calc
reports Err:504 (error in parameter list).
– By entering a number to specify the column within the Database area, starting with 1.
For example, if a Database occupied the cell range D6:H123, then enter 3 to indicate
the header cell at F6. Calc expects an integer value that lies between 1 and the
number of columns defined within Database and ignores any digits after a decimal
point. If the value is less than 1, Calc reports Err:504 (error in parameter list). If the
value is greater than the number of columns in Database, Calc reports a #VALUE!
error.

Chapter 15 Calc as a Database | 495


– By entering the literal column header name from the first row of the Database range,
placing quotation marks around the header name; for example, “Distance to School”. If
the string does not match one of the Database area’s column headings, Calc reports
Err:504 (error in parameter list). You can also provide a reference to an arbitrary cell
(not within the Database and SearchCriteria areas) that contains the required string.
The DatabaseField argument is optional for the DCOUNT and DCOUNTA functions but
it is required for the other ten Database functions.
SearchCriteria argument
SearchCriteria specifies the range of cells containing search criteria. Like Database, its
first row is also field names, and subsequent rows are conditions for related fields. The
Database and SearchCriteria areas need not be adjacent, or even on the same sheet.
One way of defining the range of cells is to enter the cell reference for the upper left-
hand cell, followed by a colon (:), and then the lower right-hand cell reference; for
example, A13:B14. The cell range may also be specified by passing the name of a
defined named range or database range. If the name does not match the name of a
defined range, Calc reports a #NAME? error.
Err:504 (error in parameter list) may also be reported as a result of an invalid
SearchCriteria argument.
The contents of the SearchCriteria area are described in more detail in the next section.

Defining search criteria


The number of columns occupied by the SearchCriteria area need not be the same as the width
of the Database area. All headings that appear in the first row of SearchCriteria must be
identical to headings in the first row of Database. However, not all headings in Database need
appear in the first row of SearchCriteria, while a heading in Database can appear multiple
times in the first row of SearchCriteria.
Search criteria are entered into the cells of the second and subsequent rows of the
SearchCriteria area, below the row containing headings. Blank cells within the SearchCriteria
area are ignored.
Create criteria in the cells of the SearchCriteria area using the comparison operators <, <=, =,
<>, >=, and >. = is assumed if a cell is not empty but does not start with a comparison operator.
If you write several criteria in one row, they are connected by AND. If you write several criteria in
different rows, they are connected by OR.
Criteria can be created using wildcards, providing that wildcards have been enabled via the
Enable wildcards in formulas option on the Tools > Options > LibreOffice Calc > Calculate
dialog. When interoperability with Microsoft Excel is important for your spreadsheet, this option
should be enabled.
Even more powerful criteria can be created using regular expressions, providing that regular
expressions have been enabled via the Enable regular expressions in formulas option on the
Tools > Options > LibreOffice Calc > Calculate dialog.

Tip
When using functions where a search criterion string can be a regular expression,
the first attempt is to convert the criterion string to numbers. For example, ".0" will
convert to 0.0 and so on. If successful, the match will not be a regular expression
match but a numeric match. However, switching to a locale where the decimal
separator is not the dot makes the regular expression conversion work. To force the

496 |Calc Guide 24.8


evaluation of the regular expression instead of a numeric expression, use some
expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".
Another setting that affects how the search criteria are handled is the Search criteria = and <>
must apply to whole cells option on the Tools > Options > LibreOffice Calc > Calculate
dialog. This option controls whether the search criteria you set for the Database functions must
match the whole cell exactly. When interoperability with Microsoft Excel is important for your
spreadsheet, this option should be enabled.

Example of Database function use

Figure 517 - Example usage of a Database function


Figure 517 provides a simple example demonstrating how to use one of the functions in the
Database category. The formula in the selected cell E15 can be seen in the Formula bar and
comprises a call to the DCOUNT function. The arguments of this function call are as follows:
• Database argument. The database table used for this example extends over the cell
range A1:E10.
• DatabaseField argument. As the DCOUNT function counts the records that match the
criteria without further calculation, it is not necessary to provide a value for this argument,
although the relevant argument separators (commas in this case) must be provided.
• SearchCriteria argument. The search criteria area used in this example extends over
the cell range A12:E13. The condition in cell D13 (“>600”) will cause DCOUNT to count
all records which have a value greater than 600 meters in the Distance (meters) column.
In many cases it may be convenient to replicate the column headings of the database
table within the search criteria area as shown in Figure 517. However this is not essential
and the formula =DCOUNT(A1:E10,,D12:D13) would give exactly the same value of 5.
Many more examples can be found by searching for “database functions” in the Help system, or
by visiting the relevant page for each function within the Calc Functions Wiki at
https://wiki.documentfoundation.org/Documentation/Calc_Functions.

Chapter 15 Calc as a Database | 497


List of Database functions

Note
Calc will treat dates and logical values (such as TRUE or FALSE) as numeric when
calculating with these functions.
DAVERAGE
For all rows (database records) that match the specified search criteria, DAVERAGE
calculates the average of the numeric values in the cells (fields) of the specified column.
Non-numeric values in those cells are ignored.
Returns a #DIV/0! error if no records match the specified search criteria, or if there are
no numeric values in the cells of the specified column for the matching records.
Syntax: DAVERAGE(Database; DatabaseField; SearchCriteria)
DCOUNT
For all rows (database records) that match the specified search criteria, DCOUNT counts
the number of cells (fields) of the specified column that contain numeric values. However,
if no column is specified, DCOUNT returns the count of all records that match the
specified search criteria irrespective of their contents.
Syntax: DCOUNT(Database; [DatabaseField]; SearchCriteria)
DCOUNTA
For all rows (database records) that match the specified search criteria, DCOUNTA
counts the number of cells (fields) of the specified column that are not blank. Blank cells
of the specified column are not counted. However, if no column is specified, DCOUNTA
returns the count of all records that match the specified search criteria irrespective of
their contents.
Syntax: DCOUNTA(Database; [DatabaseField]; SearchCriteria)
DGET
For the single row (database record) that matches the specified search criteria, DGET
returns the contents of the cell (field) of the specified column.
Calc reports Err:502 (invalid argument) if multiple matches are found, or a #VALUE! error
(wrong data type) if no matches are found. A #VALUE! error is also reported if a single
match is found but the relevant cell is empty.
Syntax: DGET(Database; DatabaseField; SearchCriteria)
DMAX
For all rows (database records) that match the specified search criteria, DMAX calculates
the maximum value across the cells (fields) of the specified column that contain numeric
values. Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells
of the specified column for the matching records.
Syntax: DMAX(Database; DatabaseField; SearchCriteria)
DMIN
For all rows (database records) that match the specified search criteria, DMIN calculates
the minimum value across the cells (fields) of the specified column that contain numeric
values. Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells
of the specified column for the matching records.

498 |Calc Guide 24.8


Syntax: DMIN(Database; DatabaseField; SearchCriteria)
DPRODUCT
For all rows (database records) that match the specified search criteria, DPRODUCT
calculates the product of all numeric values in the cells (fields) of the specified column.
Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no numeric values in the cells of the
specified column for the matching records.
Syntax: DPRODUCT(Database; DatabaseField; SearchCriteria)
DSTDEV
For all rows (database records) that match the specified search criteria, DSTDEV
calculates the sample standard deviation based on the numeric values in the cells (fields)
of the specified column. Non-numeric values are ignored.
Returns a #NUM! error if exactly one record matches the specified search criteria, or if
there is only one numeric value in the cells of the specified column for the matching
records.
Returns 0 if no matches are found, or if there are no numeric values in the cells of the
specified column for the matching records.
Syntax: DSTDEV(Database; DatabaseField; SearchCriteria)
DSTDEVP
For all rows (database records) that match the specified search criteria, DSTDEVP
calculates the population standard deviation based on the numeric values in the cells
(fields) of the specified column. Non-numeric values are ignored.
Returns a #NUM! error if no records match the specified search criteria, or if there are no
numeric values in the cells of the specified column for the matching records.
Syntax: DSTDEVP(Database; DatabaseField; SearchCriteria)
DSUM
For all rows (database records) that match the specified search criteria, DSUM
calculates the sum of all numeric values in the cells (fields) of the specified column.
Blank cells or cells containing non-numeric characters are not included.
Returns 0 if no matches are found, or if there are no numeric values in the cells of the
specified column for the matching records.
Syntax: DSUM(Database; DatabaseField; SearchCriteria)
DVAR
For all rows (database records) that match the specified search criteria, DVAR calculates
the sample variance based on the numeric values in the cells (fields) of the specified
column. Non-numeric values are ignored.
Returns a #NUM! error if exactly one record matches the specified search criteria, or if
there is only one numeric value in the cells of the specified column for the matching
records.
Returns 0 if no matches are found, or if there are no numeric values in the cells of the
specified column for the matching records.
Syntax: DVAR(Database; DatabaseField; SearchCriteria)

Chapter 15 Calc as a Database | 499


DVARP
For all rows (database records) that match the specified search criteria, DVARP
calculates the population variation based on the numeric values in the cells (fields) of the
specified column. Non-numeric values are ignored.
Returns a #NUM! error if no records match the specified search criteria, or if there are no
numeric values in the cells of the specified column for the matching records.
Syntax: DVARP(Database; DatabaseField; SearchCriteria)

Other database-like functions


Calc includes over 500 functions to help you analyze and reference data. Some of these
functions are intended for use with tabular data (such as HLOOKUP and VLOOKUP), while
others can be used in any context. This section provides a list of some of the functions that may
be useful if you intend to utilize tables in Calc for your database. Many will be familiar as typical
spreadsheet functions used in other contexts, while some may be less frequently used but are
particularly helpful with database tables.
Further reference material for all Calc’s functions can be found in the Help system and in the
Calc Functions area of the The Document Foundation’s wiki, at
https://wiki.documentfoundation.org/Documentation/Calc_Functions.
Table 23: Some useful database-like functions

Function Category Description


Returns an overall result calculated by applying a selected
aggregation function to the specified data. Nineteen
selectable aggregation functions are available, including
AGGREGATE Mathematical
average, count, large, maximum, median, minimum,
mode, percentile, product, quartile, small, standard
deviation, sum, and variance.
Returns the arithmetic mean of the specified data, ignoring
AVERAGE Statistical
empty cells and cells that contain text.
Returns the arithmetic mean of the specified data, ignoring
AVERAGEA Statistical empty cells but assigning the value 0 to any cell that
contains text.
Returns the arithmetic mean of all cells in a range that
AVERAGEIF Statistical
satisfy a given criterion.
Returns the arithmetic mean of all cells in a range that
AVERAGEIFS Statistical
satisfy multiple criteria in multiple ranges.
Returns one value from the specified data, selected
CHOOSE Spreadsheet
according to the index passed as an argument.
Returns a count of the numeric values in the specified
COUNT Statistical
data, ignoring empty cells and cells that contain text.
Returns a count of the numeric and text values in the
COUNTA Statistical
specified data, ignoring empty cells.
COUNTBLANK Statistical Returns the number of empty cells in the specified data.
Returns the number of cells in a range that satisfy a given
COUNTIF Statistical
criterion.
Returns the number of cells that satisfy multiple criteria in
COUNTIFS Statistical
multiple ranges.

500 |Calc Guide 24.8


Searches for a specified value in the first row of a table
(often a column heading) and returns a value retrieved
HLOOKUP Spreadsheet
from the same column but a different row. HLOOKUP
stands for horizontal lookup.
Returns the contents of one cell in a table. The position of
that cell is specified by row and column offsets. Can also
INDEX Spreadsheet
be used in an array formula context to retrieve data from
multiple cells.
Returns a valid reference constructed from a supplied
string representation of the reference. This function is
INDIRECT Spreadsheet
powerful because it enables a user to create dynamic
references.
Searches for a specified value in a single row or column
and returns a value from the same position in a second
LOOKUP Spreadsheet
row or column. It is not necessary for the search and result
areas to be adjacent.
Returns the relative position of a search item in a single
MATCH Spreadsheet
row or column range.
Returns the maximum value in the specified data, ignoring
MAX Statistical
empty cells and cells that contain text.
Returns the maximum value in the specified data, ignoring
MAXA Statistical empty cells but assigning the value 0 to any cell that
contains text.
Returns the maximum value of all cells in a range that
MAXIFS Statistical
satisfy multiple criteria in multiple ranges.
Returns the median value of the specified data. The
median of a finite list of numbers is the "middle" number,
MEDIAN Statistical
when those numbers are listed in order from smallest to
greatest.
Returns the minimum value in the specified data, ignoring
MIN Statistical
empty cells and cells that contain text.
Returns the minimum value in the specified data, ignoring
MINA Statistical empty cells but assigning the value 0 to any cell that
contains text.
Returns the minimum value of all cells in a range that
MINIFS Statistical
satisfy multiple criteria in multiple ranges.
Returns the mode value of the specified data. The mode is
MODE the most common value in a list of values. If there are
Statistical
MODE.SNGL several values with the same frequency, the smallest
value is returned.
Returns a vertical array of the mode values of the
specified data. The mode is the most common value in a
MODE.MULT Statistical list of values. The function returns more than one value
when there are multiple modes sharing the same
frequency of occurrence.
Returns a modified reference to a single cell or a range of
OFFSET Spreadsheet cells, offset by a certain number of rows and columns from
a given reference point.
Returns the product of the numeric values in the specified
PRODUCT Mathematical
data, ignoring empty cells and cells that contain text.

Chapter 15 Calc as a Database | 501


STDEV Returns the sample standard deviation of the specified
Statistical
STDEV.S data, ignoring empty cells and cells that contain text.
Returns the sample standard deviation of the specified
STDEVA Statistical data, ignoring empty cells but assigning the value 0 to any
cell that contains text.
STDEVP Returns the population standard deviation of the specified
Statistical
STDEV.P data, ignoring empty cells and cells that contain text.
Returns the population standard deviation of the specified
STDEVPA Statistical data, ignoring empty cells but assigning the value 0 to any
cell that contains text.
Returns an overall result calculated by applying a selected
total function to the specified data. Eleven selectable total
functions are available, including average, count,
SUBTOTAL Mathematical
maximum, minimum, product, standard deviation, sum,
and variance. Use this function with AutoFilter to take only
the filtered records into account.
Returns the sum of the specified data, ignoring empty cells
SUM Mathematical
and cells that contain text.
Returns the sum of all cells in a range that satisfy a given
SUMIF Mathematical
criterion.
Returns the sum of all cells in a range that satisfy multiple
SUMIFS Mathematical
criteria in multiple ranges.
VAR Returns the sample variation of the specified data,
Statistical
VAR.S ignoring empty cells and cells that contain text.
Returns the sample variation of the specified data,
VARA Statistical ignoring empty cells but assigning the value 0 to any cell
that contains text.
VARP Returns the population variation of the specified data,
Statistical
VAR.P ignoring empty cells and cells that contain text.
Returns the population variation of the specified data,
VARPA Statistical ignoring empty cells but assigning the value 0 to any cell
that contains text.
Searches for a specified value in the first column of a table
(often a row heading) and returns a value retrieved from
VLOOKUP Spreadsheet
the same row but a different column. VLOOKUP stands for
vertical lookup.

502 |Calc Guide 24.8


Calc Guide 24.8

Chapter 16
Setting up and Customizing
Introduction
This chapter presents some, but not all, of the setup options found under Tools > Options on
the Menu bar (LibreOffice > Preferences on macOS). Information about options not covered in
this chapter are covered in the Help and in the Getting Started Guide.
This chapter does explain how to customize menus, toolbars, and keyboard shortcuts.
Application extensions available from the LibreOffice website and other providers can simplify
the customization process.
Utilizing the “Type to search” function under Tools > Options on the Menu bar is useful for
finding a particular option to customize. When typing in this field, Calc automatically hides the
options in the tree that do not match the entered keywords.

LibreOffice options
The settings described in this section apply to all components of LibreOffice and are of particular
interest to users of Calc. To access the options:
1) Choose Tools > Options to open the Options dialog. The dynamic list on the left-hand
side only displays options applicable to open applications. The illustrations in this chapter
show the list as it appears when Calc is open.
2) Click the expansion symbol (+ or triangle) next to LibreOffice to reveal the list of
subsections.

Figure 518: LibreOffice options

Note
The Reset button, located in the lower right of the full Options dialog, has the same
effect on all pages of the dialog. It resets the options to the values that were in place
when you opened the dialog.

504 |Calc Guide 24.8


User data
User data entries are used by templates and wizards in LibreOffice. For example, Calc uses the
first and last name entries to populate the Created and Modified fields in the document
properties, in the footer of a printed spreadsheet, or as the username associated with
comments.
Cryptography
Set the preferred public key for OpenPGP encryption and digital signature. These
preferred keys will be pre-selected in key selection dialog every time you sign or encrypt
a document, so you don't have to select it yourself when signing with one specific key
frequently.
OpenPGP signing key
Select your OpenPGP key from the drop-down list for signing ODF documents.
OpenPGP encryption key
Select your OpenPGP key from the drop-down list for encrypting ODF documents.
When encrypting documents, always encrypt to self
Mark this checkbox to also encrypt the file with your public key, so you can open the
document with your private key.

Warning
Keep this option selected!
Otherwise you will not be able to decrypt documents you've encrypted for other
people.

General
Set preferences for Help, Open/Save, File Associations, and more. You can also disable the tip
of the day popups here.

View
View settings affect how the document window looks and behaves. Users can change the size
and style of toolbar and sidebar icons, among other settings.

Print
The print options may be set to suit your default printer and your most common printing method.
You can change these settings at any time, either through this dialog or during the printing
process using the Print dialog. Calc-specific print options are described in “Print options” below.
See Chapter 8, Printing, Exporting, Emailing, and Signing, for more about these options.

Paths
The paths options can be used to change the location of files associated with, or used by,
LibreOffice. Some items can have at least two paths listed: one to a shared folder (which might
be on a network) and one to a user-specific folder (normally on the user’s personal computer).
You could, for example, change the default path to a shared server instead of your PC.

Chapter 16 Setting up and Customizing | 505


Security
The security options can be adjusted to change the behavior of the application when a potential
security issue is present, such as hidden information or macros. The controls for the security
options shown in the screenshot are described in detail below.
Security Options and Warnings
If you record changes, save multiple versions, or include hidden information or notes in
your documents, and you do not want some of the recipients to see that information, you
can set warnings to remind you to remove this information, or you can have LibreOffice
remove some information automatically. Note that, unless removed, much of this
information is retained in a file whether the file is in LibreOffice’s default OpenDocument
Format, or has been saved to other formats, including PDF.
Click the Options button to open a separate dialog with specific choices (see Figure
520).
Passwords for Web Connections
You can enter a master password to enable easy access to websites that require a user
name and password. If you select the Persistently save passwords for web
connections option, the Set Master Password dialog opens. LibreOffice will securely
store all passwords that you use to access files from web servers. You can retrieve the
passwords from the list after you enter the master password.

Figure 519: Choosing security options for opening and saving documents
Macro Security
Click the Macro Security button to open the Macro Security dialog, where you can
adjust the security level for executing macros and specify trusted sources.
Certificate Path
Users can digitally sign documents using LibreOffice. A digital signature requires a
personal signing certificate. Most operating systems can generate a self-signed
certificate. However, a personal certificate issued by an outside agency (after verifying an
individual’s identity) has a higher degree of trust associated with it than a self-signed
certificate. LibreOffice does not provide a secure method of storing these certificates, but

506 |Calc Guide 24.8


it can access certificates that have been saved using other programs. Click the
Certificate button, and select the preferred certificate store to use.

Note
The Certificate Path option appears only on Linux and macOS systems. On
Windows, LibreOffice uses the default Windows location for storing and retrieving
certificates.
TSAs –Time Stamping Authorities
Allows you to select a Time Stamping Authority (TSA) URL for PDF documents created
by LibreOffice. Adding a trusted timestamp to an electronic signature on a PDF provides
a digital seal of data integrity and a trusted date and time of when the file was signed.
Recipients of PDF documents with a trusted timestamp can verify when the document
was digitally or electronically signed, as well as verify that the document was not altered
after the date the timestamp vouches for.
GPG Certificate Manager
Select your preferred GPG certificate manager. Note that LibreOffice tries to locate
installed ones automatically. Press the Browse button to locate the certificate manager
executable in your system.

Security Options and Warnings


While most of the options available on the Security Options and Warnings dialog (Figure 520)
are straightforward, those listed below benefit from additional explanation.

Figure 520: Security Options and Warnings dialog


Security warnings
Warnings take the form of a suitable icon and text displayed in an infobar located above
the grid of cells.
Remove personal information on saving
Select this option to always remove user data from the file properties when saving the
file. Control the granularity of the user data removed using the four check boxes located
below this option. To manually remove personal information from specific documents,

Chapter 16 Setting up and Customizing | 507


deselect this option and then use the Reset Properties button under File > Properties >
General on the Menu bar.
Ctrl-click required to open hyperlinks
The default behavior in most components of LibreOffice is to Ctrl+click on a hyperlink to
open the linked document, but you can choose to open hyperlinks using a single click.

Application colors
On the LibreOffice – Application Colors page (Figure 521), you can specify which user interface
elements are visible and the colors used to display them. Scroll down the list until you find the
section headed Spreadsheet. To change the default color for Grid lines or other on-screen
indicators, click the down-arrow by the color and select a new color in the drop-down list.

Figure 521: Changing the color of elements in Calc


If you wish to save your color changes as a color scheme, click Save, type a name in the Name
of color scheme box in the pop-up dialog, and then click OK.
LibreOffice is supplied with a default color scheme (“LibreOffice”) and an alternative preset color
scheme (“LibreOffice Dark”). The latter may be preferable in some working environments where
a reduction in the amount of bright white light on the screen could be beneficial. Use the
Scheme drop-down menu to select one of these schemes, or an alternative scheme that you
have already created and saved. As you make selections in this menu, the Custom Colors area
on the dialog is updated to show the settings for the chosen scheme and the underlying Calc
window is also updated accordingly – if you subsequently press the Cancel button, the
previously selected color scheme is re-applied.

Advanced options
Two items of interest on this page are found under Optional Features:
Enable experimental features (may be unstable)
Selecting this option enables features that are not yet complete or contain known bugs.
The list of these features is different version by version.

508 |Calc Guide 24.8


Enable macro recording (may be limited)
This option enables macro recording, with some limitations. For more about macro
recording, see the Getting Started Guide, and Chapter 14, Macros, in this book.
Open Expert Configuration
The expert configuration dialog contains advanced settings for LibreOffice. Avoid
changing any of these configurations without good knowledge fo the consequences,
which may not be visible immediately and can turn the user profile unusable and subject
to a factory reset or to a call to the Help desk.

Options for loading and saving documents


You can set the Load/Save options to suit the way you work. This chapter describes only a few
of the options, those most relevant to working with Calc. See the Getting Started Guide for a
description of the other options.
If the Options dialog is not already open, click Tools > Options on the Menu bar. Click the
expansion symbol (+ or triangle) by Load/Save on the left-hand side to display the list of
load/save options pages.

General
Many of the choices on the Load/Save – General page (Figure 522) are familiar to users of other
office suites. Those of most interest to Calc users are in the Default File Format and ODF
Settings section.
Default File Format and ODF Settings
ODF format version: LibreOffice by default saves documents in OpenDocument Format
(ODF) version 1.3 Extended. You will rarely need to change this for compatibility when
exchanging files with other people.
Document type: If you routinely share documents with users of Microsoft Excel, you
might want to change the Always save as option to one of the Excel formats, including
XLSX. However, you can choose an Excel format when you save any individual file.
We recommend that you always save a working copy in ODS format and only create an
Excel version if necessary for sharing. Also, note that recent versions of Microsoft Excel
can open ODS files, so this may no longer be needed.

Chapter 16 Setting up and Customizing | 509


Figure 522: Choosing Load and Save general options

Note
The Save AutoRecovery information every and Always create backup copy
options are enabled by default. Also by default, backup copies accumulate in the
folder specified by going to Tools > Options > LibreOffice > Paths, but this can be
changed by selecting the Place backup in same folder as document option.

VBA Properties
On the Load/Save – VBA Properties page (Figure 523), you can choose whether to keep any
VBA (Visual Basic for Applications) macros in Microsoft Office documents that are opened in
LibreOffice.

Figure 523: Choosing Load/Save VBA Properties


If you choose Load Basic code, you can edit the macros in LibreOffice. The changed code is
saved in an ODF document but is not retained if you save into a Microsoft Office format.
If you choose Save original Basic code, the macros will not work in LibreOffice but are retained
unchanged if you save the file into Microsoft Office format.
If you are importing a Microsoft Word or Excel file containing VBA code, you can select the
option Executable code. Whereas normally the code is preserved but rendered inactive (if you

510 |Calc Guide 24.8


inspect it with the LibreOffice Basic IDE you will notice that it is all commented), with this option
the code is ready to be executed.
Save original Basic code takes precedence over Load Basic code. If both options are
selected, and you edit the disabled code in LibreOffice, the original Microsoft Basic code will be
saved when saving in a Microsoft Office format.
To remove any possible macro viruses from the Microsoft Office document, deselect Save
original Basic code. The document will be saved without the Microsoft Basic code.

Microsoft Office
On the Load/Save – Microsoft Office page (Figure 524), you can choose what to do when
importing or exporting Microsoft Office OLE objects (linked or embedded objects or documents
such as spreadsheets or equations): convert them into or from the corresponding LibreOffice
OLE object or load and save them in their original format.
Select the [L] options to convert Microsoft OLE objects into the corresponding LibreOffice OLE
objects when a Microsoft document is loaded into LibreOffice.
Select the [S] options to convert LibreOffice OLE objects into the corresponding Microsoft OLE
objects when a document is saved in a Microsoft format.

Figure 524: Choosing Load/Save Microsoft Office options


The Character Highlighting options enable you to select between the two text highlighting
(character background) attributes that Microsoft Office provides, Highlighting or Shading.
Shading is the initial default.
The Create MSO lock file option improves interoperability with Microsoft Office for shared
spreadsheets. When enabled, Calc writes two lock files when opening a Microsoft Office format
file, one LibreOffice lock file and one Microsoft Office lock file. This enables users of both suites
to be made aware that the file is in use. The option is initially disabled by default.

HTML Compatibility
Choices made on the Load/Save – HTML Compatibility page (Figure 525) affect how LibreOffice
imports or exports HTML pages. See the Getting Started Guide, and “HTML documents
importing/exporting” in the Help, for more information.
The main items of interest for Calc users are in the Export section.
LibreOffice Basic
Select this option to include LibreOffice Basic macros (scripts) when exporting to HTML
format. You must activate this option before you create the LibreOffice Basic macro;
otherwise the script will not be inserted. LibreOffice Basic macros must be located in the

Chapter 16 Setting up and Customizing | 511


header of the HTML document. Once you have created the macro in the LibreOffice
Basic IDE, it appears in the source text of the HTML document in the header.
If you want the macro to run automatically when the HTML document is opened, choose
Tools > Customize > Events. See Chapter 14, Macros, for more information.
Display warning
When the LibreOffice Basic option (see above) is not selected, the Display warning
option becomes available. If the Display warning option is selected, then when
exporting to HTML a warning is shown that LibreOffice Basic macros will be lost.
Print layout
Select this option to export the print layout of the current document as well. The HTML
filter supports CSS2 (Cascading Style Sheets Level 2) for printing documents. These
capabilities are only effective if print layout export is activated.
Copy local images to Internet
Select this option to automatically upload the embedded pictures to an Internet server
when uploading using FTP.

Figure 525: Choosing HTML compatibility options

Calc-specific options
Calc must be open in order for the LibreOffice Calc options to be displayed in the Options dialog.
Click the expansion symbol (+ or triangle) by LibreOffice Calc. A list of subsections drops down
(Figure 526).

512 |Calc Guide 24.8


Figure 526: Calc options

General
The choices on the LibreOffice Calc – General page (Figure 527) affect the units used for rulers
and other measurements, the default tab stop positions, the updating of links and fields, and
various input settings.
Metrics section
Choose the unit of measurement used in spreadsheets and the default tab stops
distance.
Update links when opening section
Choose whether to update links when opening a document: Always, On request, or
Never. Spreadsheets that include many or large charts or graphics may load slowly if this
option is set to Always.

Chapter 16 Setting up and Customizing | 513


Figure 527: Selecting general options for Calc

Input Settings section


Press Enter to move selection
Specifies that pressing Enter moves the cursor to another cell. You can also choose the
direction the cursor moves: Up, Down, Left, or Right. If this option is not selected,
pressing Enter places the data into the cell but does not move the cursor.
Press Enter to switch to edit mode
Specifies that pressing Enter puts the selected cell into edit mode. To end edit mode
and move the cursor in the desired direction, press Enter again.
Press Enter to paste and clear clipboard
When the content of a cell is copied to the clipboard, you can paste the information in
another cell by pressing the Enter key. After pasting occurs, the clipboard is cleared.
Here you can enable/disable this feature.
Expand formatting
Specifies whether to automatically apply the formatting attributes of the selected cell to
empty adjacent cells. If, for example, a selected cell has the bold attribute, this attribute
will also apply to empty adjacent cells. However, cells that already have a special format
will not be modified by this function. To see the affected range, press Ctrl+*
(multiplication sign on the number pad). The format will also apply to all new values
inserted within this range. This feature works only while you are inserting data in
adjacent cells with the previous formatting style; if you insert some data in a non-
adjacent cell, Expand formatting will no longer work. In order to get it to work again, you
will need to format a cell again (it could be the same one if you like) and insert data into
its adjacent cells.
Expand references when new columns/rows are inserted
Specifies whether to expand references when inserting columns or rows adjacent to the
reference range. This is only possible if the reference range, where the column or row is
inserted, originally spanned at least two cells in the desired direction.

514 |Calc Guide 24.8


Example: If the range A1:B1 is referenced in a formula and you insert a new column after
column B, the reference is expanded to A1:C1. If the range A1:B1 is referenced and a
new row is inserted under row 1, the reference is not expanded, since there is only a
single cell in the vertical direction.
If you insert rows or columns in the middle of a reference area, the reference is always
expanded.
Update references when sorting range of cells
When selected, references to cells are updated when a range of cells is sorted. If not
selected, the references are unchanged.
Highlight selection in column/row headers
Specifies whether to highlight column and row headers in the selected columns or rows.
Use printer metrics for text formatting
Select this option to use the properties of the default printer to format the display of a
spreadsheet. Those properties can be found by choosing File > Printer Settings and
then selecting the Properties button for the default printer. If the printer has options for
page setup, those settings will be applied to Calc documents. If this option is not
selected, pages will be configured for a generic printer.
Show overwrite warning when pasting data
Pasting contents of the clipboard into a cell will replace the contents of that cell with what
is in the clipboard. Select this option to be alerted to a possible loss of data when
pasting.
Position cell reference with selection
With this option set, expanding a selection (with Ctrl+Shift+Down/Up) jumps to the end
of the range in the column that was added as last to the initial selection. When the option
is not set, expanding a selection (with Ctrl+Shift+Down/Up) jumps to the end of the
range in the column where selecting the cell range was started. The same applies when
extending a selection on rows, with Ctrl+Shift+Left/Right.

Defaults
On the LibreOffice Calc – Defaults page you can enter the number of sheets to be opened by
default when you start a new spreadsheet, and either accept the default sheet prefix or type a
new one. After a spreadsheet has been created, you can add new sheets and change the label
of any tab; see Chapter 1, Introduction, for more information.

View
The options on the LibreOffice Calc – View page (Figure 529) affect the way the document
window looks and behaves when viewed onscreen.

Display section
Select various options for the display.
Formulas
Display the content of a cell either as a formula or as the result of that formula.
Zero values
Display a zero in a cell when the cell has a value of zero, or display as a blank cell.

Chapter 16 Setting up and Customizing | 515


Note
A blank cell is not the same as an empty cell. In the case of zero display value
setting, a cell can display as blank when its value is zero but is not empty.
Comment indicator
Select this option to show a small symbol in the top right corner of a cell that contains a
comment.

Figure 528: Comment indicator


To always display a comment, right-click on the cell and select Show comment in the
context menu.

Figure 529: Selecting view options for Calc


Formula indicator and hint
Select this option to draw a blue triangle in the bottom-left corner of each cell that
contains a formula. When hovering the pointer over the blue triangle, the formula is
shown in a tool tip.

Figure 530: Formula indicator


Value highlighting
Select this option to highlight all values, or results of formulas, in the sheet. Text is
highlighted in black; numbers, dates and logical values in blue, since they are all handled
as numbers by Calc; formulas are displayed in green. When this option is active, any
colors assigned in the document are not displayed.

516 |Calc Guide 24.8


Column/Row highlighting
Select this option to highlight the entire row and column of the active cell using a
transparent color.
Anchor
If an inserted object, such as a picture, is anchored to a cell, an image of an anchor will
appear in the cell to which the object is anchored.
Show references in color
Select this option to provide a visual aid to assist the editing of a formula. Each reference
is then highlighted in color in the formula, and the referenced cell range is enclosed by a
colored border as soon as the cell containing the reference is selected for editing.

Figure 531: Formula references – visual aids

Window section
The following elements of the spreadsheet window can be made visible or invisible:
column and row headers, horizontal and vertical scroll bars, sheet tabs, and, if an outline
has been defined, outline symbols.
If the Sheet tabs option is not selected, you can only switch between the sheets by using
the Navigator.
The Summary on search option controls the display of the Search Results dialog, which
is described in detail in Chapter 2, Entering and Editing Data.

Visual Aids section


Grid lines
Grid lines are the borders around the cells of a spreadsheet when viewed onscreen. The
options are: Show, Show on colored cells, or Hide. If grid lines are hidden, tables will
be displayed on a solid background with no grid around cells. The color choice overrides
the selection made in Tools > Options > LibreOffice > Application Colors >
Spreadsheet > Grid lines.

Note
To print grid lines, choose Format > Page Style > Sheet > Print > Grid.
Pointer
When the mouse pointer lies over the grid of cells on a Calc spreadsheet, the default
pointer (“System”) is normally shown, typically as an arrow pointer. However, an
alternative pointer (“Themed”) is available to allow you to switch to using the pointer
shape defined in the icon theme (typically a “fat” cross, Figure 532).

Chapter 16 Setting up and Customizing | 517


Figure 532: Typical System (left) and Themed (right) cursors
Page breaks
Specifies whether to view the page breaks within a defined print area.
Helplines while moving
Specifies whether to view helplines when moving drawings, frames, graphics, and other
objects. These lines help you align objects.
In Figure 533, the graph with the dark background represents the image in its original
location. The lighter area represents the position of the image as it is being moved.
Helplines are the horizontal and vertical dotted lines at the corners of the lighter object.

Figure 533: Helplines visible when moving a graphic

Objects section
Choose whether to show or hide graphics, charts, and drawing objects.

Zoom section
Select the Synchronize sheets option to apply any selected zoom (magnification) factor
to all sheets in the spreadsheet. If this option is not selected, separate zoom factors can
be applied to individual sheets.

Calculate
Use the LibreOffice Calc – Calculate page (Figure 534) to define the calculation settings for
spreadsheets.

518 |Calc Guide 24.8


Figure 534: Calc calculation options

Formulas Wildcards section


Enable wildcards in formulas
Specifies that wildcards are enabled when searching and also for character string
comparisons. Select this option for spreadsheets that need to be interoperable with
Microsoft Excel.
Enable regular expressions in formulas
Specifies that regular expressions instead of simple wildcards are enabled when
searching and also for character string comparisons. Do not enable regular expressions
in formulas for spreadsheets that need to be interoperable with Microsoft Excel.
No wildcards or regular expressions in formulas
Specifies that only literal strings are used when searching and also for character string
comparisons. Do not disable wildcards in formulas for spreadsheets that need to be
interoperable with Microsoft Excel.
The options listed above are mutually exclusive. For more information about them, see
Chapter 9, Using Formulas and Functions.

Date section
Select the start date for the internal conversion from days to numbers.
12/30/1899 (default) – Sets December 30, 1899 as day zero.
01/01/1900 (StarCalc 1.0) – Sets January 1, 1900 as day zero. Use this setting for
StarCalc 1.0 spreadsheets containing date entries.
01/01/1904 – Sets January 1, 1904 as day zero. Use this setting for spreadsheets that
are imported from foreign formats.

General Calculations section


Specify a variety of options relevant to spreadsheet calculation.

Chapter 16 Setting up and Customizing | 519


Case sensitive
Specifies whether to distinguish between upper and lower case in texts when comparing
cell contents. For example: type 'Test' in cell A1; and 'test' in B1. Then type the formula
=A1=B1 in cell C1. If the Case sensitive option is checked, FALSE will appear in the cell;
if the analysis was case insensitive, TRUE will appear in the cell. This option is not
applied to the EXACT text function, which is always case-sensitive.
Precision as shown
Specifies whether to make calculations using the rounded values displayed in the sheet.
Charts will be shown with the displayed values. If the Precision as shown option is not
marked, the displayed numbers are rounded, but they are calculated internally using the
non-rounded number.
Search criteria = and <> must apply to whole cells
The default search method in Calc is to search for any instance of the target regardless
of the position of the target within a word. For example, when searching for day, Calc will
match Friday, Sunday, and days. Select this option to search an exact occurrence of the
target. Wildcard symbols can be used to expand the search to match the default
condition.
Automatically find column and row labels
Calc will name the range of data, under a column heading or to the right of a row
heading, using the text in those headings.
Example: Cell E5 contains the text Europe. Below, in cell E6, is the value 100 and in cell
E7 the value 200. If the Automatically find column and row labels option is selected,
you can write the following formula in cell A1: =SUM(Europe).
Limit decimals for general number format
Limits the number of decimals to be displayed for numbers with the general number
format. This overrides the setting applied in the General option of the Format section
inside the Number Category in Format > Cells > Numbers. This setting refers to how
numbers are displayed. When decimal places are limited, calculations are not affected
because of rounding.

Iterative References section


Iterative references are formulas that are continuously repeated until the problem is
solved. In this section you can choose the number of approximation steps carried out
during iterative calculations and the degree of precision of the answer.
Iterations
Select this option to enable iterations. If this option is not selected, an iterative reference
causes an error message.
Steps
Sets the maximum number of iteration steps.
Minimum change
Specifies the difference between two consecutive iteration step results. If the result of the
iteration is lower than the minimum change value, then the iteration will stop.

CPU Threading Settings section


Enable multi-threaded calculation
Controls the use of multi-threading / parallelism, which can be used to speed up
LibreOffice Calc calculations on computers with multiple processing cores. See
Chapter 9, Using Formulas and Functions for more information.

520 |Calc Guide 24.8


Caution
When calculations involve a range that includes an empty cell, take note of the
setting for Zero values in the LibreOffice Calc > View options. If this option is not
selected, a value of zero will display as an empty cell. Empty cells and the value zero
are treated differently by many functions. For example, COUNT will not include an
empty cell as an item to be counted. The average of eight cells, one of which
contains the value zero, is not the same as the average of eight cells, one of which is
empty (an empty cell is not included in determining the average).

Formula
Use the LibreOffice Calc – Formula page (Figure 535) to specify the following formula options.

Formula Options
Formula syntax
Syntax is the format in which formulas are written. Choose the syntax most appropriate
for your work. If you regularly open or save to Microsoft Excel formats, you may wish to
use one of the Excel syntaxes.
To illustrate the differences between syntaxes, assume a spreadsheet contains two
sheets.
The cell C4 can be referenced in three ways:
Calc A1 =$Sheet2.C4 – the default syntax for Calc.
Excel A1 =Sheet2!C4 – the default of Microsoft Excel.
Excel R1C1 =Sheet2!R[3]C[2] – the relative row and column addressing used in Excel.

Figure 535: Formula options


Use English function names
The default names for functions in Calc are those for the user's locale. For English users,
the localized names are the same as the English names. When the language set by

Chapter 16 Setting up and Customizing | 521


locale is not English, you may wish to express functions in English; if so, select this
option to change formula input and display, Function Wizard, and formula tips.

Separators
Separators are used in functions to distinguish points in the range used in the function:
the symbols used between elements. Enter the separator character to be used for
functions, row arrays, and column arrays. For example, a comma can be used as a
separator in functions and instead of writing =SUM(A1;B1;C1) the function would be
expressed as =SUM(A1,B1,C1).

Detailed Calculation Settings


Most users will not need to change the default setting. For custom settings, select
Custom and click Details to choose reference syntax and whether to treat empty strings
as zero.

Recalculation on File Load


Recalculating formulas can take significant time while loading very large files.
Excel 2007 and newer.
Loading a large spreadsheet file can take a long time. If you do not need to update your
large spreadsheet data immediately, you can postpone the recalculation to a better time.
Calc allows you to defer recalculation of Excel 2007 (and more recent) spreadsheets to
speed up loading time.
ODF spreadsheet (not saved by LibreOffice)
Recent versions of Calc cache spreadsheet formula results in its ODF file. This feature
helps Calc to recalculate a large ODF spreadsheet saved by Calc faster. For ODF
spreadsheets saved by other programs, where such cached formula results may not
exist, recalculation can be deferred to speed up file loading as with Excel 2007 files.
For each of these two options, the following choices are possible: Never recalculate (no
formulas will be recalculated on loading the file), Always recalculate (all formulas will be
recalculated on file load), and Prompt user (prompt user for action).
Calc saved ODF spreadsheets will honor Never recalculate and Always recalculate
options.
Optional Row height
For large spreadsheets documents, optimal row height calculation depends on the cell
contents formatting and also on the result of the conditional formatted formulas. This
setting helps to shorten load times by controlling the optimal row height calculation.

Sort lists
View, define, delete, and edit sort lists on the LibreOffice Calc – Sort Lists page. Sort lists are
utilized for various purposes beyond just sorting, such as populating a series of cells during data
entry. These lists are organized in a specific sequence, but not necessarily in alphabetical or
numerical order; for instance, the days of the week. Besides the provided lists, you have the
option to create and modify your own lists, as detailed in Chapter 2, Entering and Editing Data.

522 |Calc Guide 24.8


Figure 536: Defining sort lists in Calc

Changes
On the LibreOffice Calc – Changes page, you can assign specific colors for insertions, deletions,
and other changes, or you can let Calc assign colors based on the author of the change. In the
latter case, one color will apply to all changes made by that author. The selections made here
are applied when change recording is enabled by Edit > Track Changes > Record on the Menu
bar.

Figure 537: Calc options for highlighting changes

Compatibility
Key Bindings
The LibreOffice Calc – Compatibility page provides a quick way to switch between
LibreOffice’s default key bindings and OpenOffice.org’s legacy default key bindings for
Calc. Most of the defaults are identical, but there are some differences.

Chapter 16 Setting up and Customizing | 523


The actions associated with the two key binding choices are shown in the table below.
Key Binding Default OpenOffice.org legacy
Backspace Opens Delete Contents dialog Immediately deletes contents
Delete Immediately deletes contents Opens Delete Contents dialog
Control+D Fills cell content down within Opens the Selection List
(Command+D on macOS) selection dialog
Alt+DownArrow
Select header of range;
(Option+DownArrow on Increases row height
no action in empty cell
macOS)

Hyperlinks
Calc can insert multiple hyperlinks in a cell as text fields, but multiple hyperlinks in a cell
cannot be saved to Excel file formats. This option prevents inserting multiple hyperlinks
in a cell when Excel files are edited, in order to be interoperable with Excel.

Grid options
The LibreOffice Calc – Grid page defines the grid settings for spreadsheets. Using a grid helps
determine the exact position of any charts or other objects you may add to a spreadsheet. You
can also set this grid in line with the snap grid.
If you have activated the snap grid but wish to move or create individual objects without snap
positions, press the Ctrl key to deactivate the snap grid for as long as needed.
Grid section
Snap to grid activates the snap function.
Visible grid displays grid points on the screen. These points are not printed.
Resolution and Subdivision sections
Here you can set the unit of distance for the spacing between horizontal and vertical grid
points and subdivisions (intermediate points) of the grid.
Synchronize axes changes the current grid settings symmetrically.

Figure 538: Calc grid options

Print options
Use the LibreOffice Calc – Print page to choose defaults for printing spreadsheets. You can
override these for individual print jobs.

524 |Calc Guide 24.8


Figure 539: Calc Print options

Default colors for charts


Use Tools > Options > Charts > Default Colors to change the default colors used for charts or
to add new data series to the list provided.
To add new colors to the choices, see “Adding custom colors” below.
To change the default color for a data series, select it in the left-hand column and then click on
the required color in the color table.
To add another data series, click Add, then select the new series and click on the required color.
Click Default to restore the color settings that were defined when the program was installed.

Figure 540: Defining chart colors

Customizing the user interface


You can customize menus, toolbars, keyboard shortcuts, and the tabbed interface; add new
menus and toolbars; and assign macros to events.

Chapter 16 Setting up and Customizing | 525


Tip
Changes to menus and toolbars can be saved in a template. First, save them in a
document; then, save that document as a template, as described in Chapter 4, Using
Styles and Templates.

Menu content
You can add and rearrange menus on the Menu bar or context (right-click) menus; add,
rearrange, and remove commands on menus; and make other changes.
To customize menus, choose Tools > Customize on the Menu bar. On the Customize dialog, go
to the Menus tab (Figure 541) or the Context Menus tab. The following examples focus on the
Menus tab but the Context Menus tab is similar in appearance and behavior.

Figure 541: The Menus tab of the Customize dialog

Modifying an existing menu


To modify an existing menu:
1) In the Scope drop-down list in the upper right of the Customize dialog, choose whether to
save this changed menu for Calc or for a selected document.
2) In the Target drop-down list, select the menu that you want to customize. The list
includes all the sub-menus as well as the main menus. The commands on the selected
menu are shown in the Assigned Commands list below.

526 |Calc Guide 24.8


3) To add a command to the selected menu, click on a command in the Available
Commands list and then click the right arrow. You can narrow the search by using the
Search box on the top left or selecting the Category in the drop-down list. Use the up and
down arrows on the far right-hand side to move the command into the place where you
want it in the Assigned Commands list.
4) To remove a command from the selected menu, click on it in the Assigned Commands
list and then click the left arrow.
5) To insert a separator or submenu, use the commands in the Insert drop-down under
Customize at the bottom right.

Figure 542: Customize dialog, Menus tab, Insert drop-down


6) To rename a menu item, select it in the Assigned Commands list and choose Rename in
the Modify drop-down below.

Figure 543: Customize dialog, Menus tab, Modify drop-down


7) Use the Reset button to reset Calc’s menu configuration to the default settings.
8) When you have finished making all your changes, click OK to save them.

Creating a new menu


To add a menu:
1) On the Menus tab of the Customize dialog, click the button next to the Target field
(Figure 544) and select Add in the drop-down list to display the New Menu dialog (Figure
545).

Figure 544: Location of command to add a new menu


2) In the New Menu dialog, type a name for the new menu in the Menu name box.
3) Use the up and down arrow buttons to move the new menu into the required position on
the Menu bar. Click OK to save and return to the Customize dialog.
The new menu now appears on the list of menus in the Customize dialog. It will appear on the
Menu bar itself after you save your customizations.
After creating a new menu, you need to add some commands to it.

Chapter 16 Setting up and Customizing | 527


Figure 545: Adding a new menu

Creating an accelerator
You can allocate a letter in a custom menu’s name to be used as a keyboard shortcut. (That
letter will become underlined.) When you press Alt+that letter, that menu or command will
be invoked. Existing submenus can also be edited to change the letter which is used to select
them using the keyboard when the menu is open.
To create an accelerator:
1) On the Customize dialog, select a menu item in the Assigned Commands list.
2) Click the Modify button and select Rename.
3) Add a tilde (~) in front of the letter to use as an accelerator.
4) Click OK to save the change.
For example. if you enter “~Art”, the “A” in the menu item Art is now underlined. Press Alt+A and
the Art menu will open.

Caution
When assigning an accelerator, be careful not to use a letter that is already assigned
to a menu or command associated with a menu item. The same letter-key
combinations can be used for commands associated with different menu items but
not for those associated with the same menu or menu item.

Toolbars
You can customize toolbars in several ways, including choosing which icons are visible and
locking the position of a docked toolbar, as described in the Getting Started Guide. This section
describes how to create new toolbars and add or delete icons (commands) on a toolbar.
To get to the toolbar customization dialog (Figure 546), do any of the following:
• On the toolbar, right-click in the toolbar and choose Customize Toolbar.

528 |Calc Guide 24.8


• Choose View > Toolbars > Customize on the Menu bar and go to the Toolbars tab.
• Choose Tools > Customize on the Menu bar and go to the Toolbars tab.

Figure 546: The Toolbars tab of the Customize dialog


To customize a toolbar:
1) In the Scope drop-down list on the upper right of the Customize dialog, choose whether
to save this changed toolbar for Calc or for a selected document.
2) In the Target drop-down list, select the toolbar that you want to customize. The current
toolbar content is displayed in the Assigned Commands list.
3) Select the command to be added in the Available Commands list. You can narrow your
search by using the Search box on the top left or choosing a category in the drop-down
list just below.
4) Click on the large right arrow to add the command to the Assigned Commands list for the
toolbar. Use the up and down arrows in the far right to position the command in the
toolbar.
5) To remove a command from a toolbar, select it in the Assigned Commands list and click
the large left arrow.
6) To show or hide a command assigned to a toolbar, mark or clear the checkbox next to its
icon in the Assigned Commands list.
7) To insert a separator, use the command in the Insert drop-down under Customize at the
bottom right.

Chapter 16 Setting up and Customizing | 529


8) To rename a toolbar item, select it in the Assigned Commands list and choose Rename
in the Modify drop-down.
9) Use the Reset button to reset Calc’s toolbar configuration to the default settings.
10) When you have finished making all your changes, click OK to save them.

Creating a new toolbar


To create a new toolbar:
1) Choose Tools > Customize on the Menu bar.
2) On the Toolbars tab of the Customize dialog, click the button next to the Target field and
select Add in the drop-down list, to display the Name dialog.
3) On the Name dialog, type the new toolbar's name and choose in the Save In drop-down
list where to save this new toolbar – for Calc or for the open document.
The new toolbar now appears on the list of toolbars in the Customize dialog.
To add commands to the new toolbar, follow the instructions earlier for modifying a toolbar.

Choosing icons for toolbar commands


Toolbar buttons can be displayed with Icon only, Text only, or Icon and text. This selection is
made through the menu that drops down from the button to the right of the Target field. However,
not all of the commands have associated icons.
To choose an icon for a command, select the command and click Modify > Change Icon. On
the Change Icon dialog (Figure 547), scroll through the available icons, select one, and click OK
to assign it to the command.

Figure 547: Change Icon dialog


To use a custom icon, create it in a graphics program and import it into LibreOffice by clicking the
Import button on the Change Icon dialog. For best quality, custom icons should be 24 x 24
pixels in size; other sizes will be scaled automatically.
Select Modify > Reset Icon to revert to the option’s default icon.

Tabbed interface
By default, Calc’s commands are grouped in cascading menus and in toolbars filled with icons.
In addition, LibreOffice provides other user interface variants, displaying contextual groups of
commands and contents. You can find more information about these variants and how to switch
between them in Chapter 17, User Interface Variants.

530 |Calc Guide 24.8


Three of LibreOffice’s user interface variants utilize a notebook bar and these are the Tabbed,
Tabbed Compact, and Groupedbar Compact options. In these variants, the area at the top of the
workspace is divided into tabs, where each tab displays a set of icons grouped by context. The
context can change depending on the object selected in the document, for example a table or an
image.
Use the checkboxes on the Notebookbar tab of the Customize dialog (Figure 548) to show and
hide the individual options on the various tabs that are provided in the most recently selected of
the three tabbed user interfaces (with Tabbed being the initial default).

Figure 548: The Notebookbar tab of the Customize dialog


Use the Reset button to reset the displayed configuration to the default settings.

Keyboard shortcuts
Along with utilizing the built-in keyboard shortcuts (found in Appendix A), you have the ability to
create your own. You can assign shortcuts to standard LibreOffice functions or your custom
macros, and save them for use across the entire LibreOffice suite or exclusively for Calc.

Caution
Avoid reassigning your operating system’s predefined shortcut keys.

Note
Shortcut keys that are grayed out in the listing on the Customize dialog, such as F1
and F10, are not available for reassignment.

Chapter 16 Setting up and Customizing | 531


To adapt shortcut keys to your needs, use the Customize dialog, as described below.
1) Select Tools > Customize on the Menu bar and select the Keyboard tab. (Figure 549).

Figure 549: Customizing a keyboard shortcut


2) To have the shortcut key assignment available only with Calc, select Calc in the upper
right corner of the page; otherwise select LibreOffice to make it available to every
component.
3) Next select the required function in the Category and Function lists.
4) Now select the desired shortcut keys in the Shortcut Keys list and click the Assign
button at the upper right.
5) Click OK to accept the change. Now the chosen shortcut keys will execute the function
chosen in step 3) above whenever they are pressed.

Note
All existing shortcut keys for the currently selected Function are listed in the Keys
selection box. If the Keys list is empty, it indicates that the chosen key combination is
free for use. If it were not, and you wanted to reassign a shortcut key combination
that is already in use, you must first delete the existing key.

Saving changes to a file


Changes to the shortcut key assignments can be saved in a keyboard configuration file for use
at a later time, thus permitting you to create and apply different configurations as the need
arises, or to create a standard keyboard configuration file to be distributed among many users.
To save keyboard shortcuts to a file:
1) After making your keyboard shortcut assignments, click the Save button on the right of
the Customize dialog (Figure 549).

532 |Calc Guide 24.8


2) In the Save Keyboard Configuration dialog, enter a name for the keyboard configuration
file in the File name box, or select an existing file (the file extension is .cfg for
Configuration).
3) Click Save. A confirmation dialog appears if you are about to overwrite an existing file,
otherwise there will be no feedback and the file will be saved.

Loading a saved keyboard configuration


To load a saved keyboard configuration file and replace your existing configuration, click the
Load button on the right of the Customize dialog, and then select the configuration file from the
Load Keyboard Configuration dialog.

Resetting the shortcut keys


To reset all of the keyboard shortcuts to their default values, click the Reset button on the right of
the Customize dialog (adjacent to the Load and Save buttons). Use this feature with care as no
confirmation dialog will be displayed; the defaults will be set without any further notice or user
input.

Running macros from key combinations


You can also define shortcut key combinations that will run macros. These shortcut keys are
strictly user-defined; none are built in. For more information on macros, see Chapter 14, Macros.

Assigning macros to events


In LibreOffice, when something happens, we say that an event occurred. For example, a
document was opened, a key was pressed, or the mouse moved. You can associate a macro
with an event, so the macro is run when the event occurs. A common use is to assign the “open
document” event to run a macro that performs certain setup tasks for the document.
To associate a macro with an event, use the Events tab of the Customize dialog. For more
information, see the Getting Started Guide.

Adding functionality with extensions


An extension is a package that can be installed into LibreOffice to add new functionality.
Although individual extensions can be found in different places, the official LibreOffice extension
repository is at https://extensions.libreoffice.org/. These extensions are free of charge.
Extensions from other sources may be free or may be available for a fee. Check the descriptions
to see what licenses and fees apply to the ones that interest you.

Installing extensions
To install an extension that is listed in the repository, follow these steps:
1) In LibreOffice, select Tools > Extensions on the Menu bar, or press Ctrl+Alt+E. In the
Extension Manager dialog, click the Get more extensions online link.
2) A browser window will open. Find the extension you want and download it to your
computer.
3) After the extension is downloaded and saved, return to the Extensions dialog and click
Add. Find and select the extension you want to install and click Open. The extension
begins installing. You may be asked to accept a license agreement.
4) When the installation is complete, the extension is listed in the Extensions dialog.

Chapter 16 Setting up and Customizing | 533


To install an extension that is not listed in the repository, download the extension, then continue
with step 3) above.

Updating extensions
Click the Check for Updates button on the Extensions dialog to check for updates to installed
extensions.

Removing and disabling extensions


To uninstall an extension that you have installed, select the extension in the main window of the
Extensions dialog and click the Remove button. To disable an extension without uninstalling it,
select the extension in the main window of the Extensions dialog and click the Disable button,
which will then change to Enable.

Tip
Extensions can be installed from some other places in Calc, such as the Gallery on
the Sidebar, the Templates dialog, the Languages and Locales > Writing Aids page
of the Tools > Options dialog and the Icon Style section in the View page of the
Tools > Options dialog. In each of these places you will find a small button leading
to a filtered view of the items in the Extensions dialog.

Note
In some cases, the Remove and Disable buttons may be unavailable, for example
when you have selected one of the extensions that was bundled with your
LibreOffice installation.

Figure 550: The Extensions dialog

534 |Calc Guide 24.8


Adding custom colors
The method for defining a custom color is as follows:
1) Insert any drawing object, such as a square, into any document.
2) Right-click on the object and choose Area in the context menu.
3) Click on the Color button on the Area tab (Figure 551). In the Palette drop-down in the
Colors area, choose which palette you wish to add the new color to. Under New, define
the new color using RGB or Hex notation, or click the Pick button to select the color on
the Pick a Color dialog (Figure 552).
4) Click Add in the lower left corner, enter a name for the new color in the pop-up dialog,
and click OK to save.
5) Delete the drawing object from the document, if it is not needed.

Figure 551: Defining a new color

Chapter 16 Setting up and Customizing | 535


Figure 552: Defining a color by picking it from a color chart

Setting up document themes


Document themes collect various format selections into a set that can be applied and changed
rapidly. Theme colors have been implemented in LibreOffice 7.6; font and format settings are
planned for later releases.
Calc supplies several sets of theme colors. To define your own set:
1) Choose Format > Theme on the Menu bar. In the Theme dialog (Figure 553), select a
theme to use as a starting point and click Add.
2) In the Theme Color Edit dialog (Figure 554), name the new theme and select colors from
any available palette.
3) Click OK to save the new theme, which will now appear in the Theme dialog.
See Chapter 4 (Using Styles and Templates), for instructions on using document themes.

Note
User-defined theme color sets are saved only in the document; to use them in other
documents, you need to make a template.
Themes enhance compatibility with Microsoft Word. However, they are not yet part of
the ODF (OpenDocument Format), so you need to save to ODF 1.3 Extended to use
them.

536 |Calc Guide 24.8


Figure 553: Theme dialog

Figure 554: Theme Color Edit dialog

Chapter 16 Setting up and Customizing | 537


Calc Guide 24.8

Chapter 17
User Interface Variants
Introduction
By default, LibreOffice’s commands are grouped in cascading menus and in toolbars filled with
icons. This is the classic user interface described in Chapter 1, Introduction, and assumed in the
task descriptions contained in many other chapters throughout this guide.
The classic interface is very flexible, allowing the user to: show, hide, or reposition many of the
user interface components; redefine the commands assigned to toolbars, menus, and context
menus; create new menus and toolbars; redefine the functions assigned to individual shortcuts;
and so on.
A further level of flexibility is provided through six alternative user interface variants which can be
selected to match an individual user’s work flows and preferences. The seven variants are:
Standard Toolbar
Standard user interface with menus, toolbars, and collapsed Sidebar. Intended for users
who are familiar with the classic LibreOffice interface.
Tabbed
The Tabbed user interface is the most similar to the ribbons used in Microsoft Office. It
organizes functions in tabs and makes the Menu bar obsolete.
Single Toolbar
Similar to the Standard Toolbar user interface but with a single-line toolbar, intended for
use on smaller screens.
Sidebar
Similar to the Standard Toolbar user interface but with an expanded Sidebar. Expert
users who want to quickly change many different properties are advised to use this
variant.
Tabbed Compact
The Tabbed Compact user interface is intended for those with are familiar with the
Microsoft Office user interface, and occupies less space for smaller screens.
Groupedbar Compact
The Groupedbar Compact user interface provides access to functions in groups, with
icons for the most-frequently used features, and drop-down menus for others. This
variant favors vertical space.
Contextual Single
The Contextual Single interface shows functions in a single-line toolbar with context-
dependent content.
Four of these options (Standard Toolbar, Single Toolbar, Sidebar, and Contextual Single) can be
considered as alternative configurations of the components used in the classic interface.
However the other three options (Tabbed, Tabbed Compact, and Groupedbar Compact) are
based on using the notebook bar. The notebook bar uses a different way to organize controls
and icons, displaying contextual groups of commands and contents for quicker use and
improved user experience.
It should be noted that the brief description of each variant above refers to the default setup for
that variant. There are many ways to adjust the configuration of any variant, and even create a
user interface that utilizes different aspects of multiple variants.

540 |Calc Guide 24.8


Selecting the user interface
When you set up Calc the default user interface is the Standard Toolbar, but you can choose one
of these user interfaces, and you can switch between them at any time.
1) Choose View > User Interface on the Menu bar.
2) On the Select Your Preferred User Interface dialog (Figure 555), choose one of the
variants on the left. An example of the variant is shown in the Preview box on the right,
along with a short description.
3) Choose the relevant button to apply your selection to all components of LibreOffice, or
only to Calc. The Calc window changes to match your selection.
4) Click Close to close the dialog.

Figure 555: Select Your Preferred User Interface dialog


If you have activated experimental features (Tools > Options > LibreOffice > Advanced >
Enable experimental features (may be unstable)), several more choices appear on the left-
hand side. These choices are not described here.

Standard interfaces
The Standard Toolbar, Single Toolbar, and Sidebar interfaces are closely related. The following
notes describe the initial default configuration for these options.
Standard Toolbar
This is the classic user interface, selected by default when LibreOffice is installed. It
provides two visible toolbars (Standard and Formatting) and the Sidebar is open,
showing its five tabs on the tab panel.
Single Toolbar
Provides one visible toolbar (Standard (Single Mode)) containing frequently used
features. The Sidebar shows only its Show/Hide button.
Sidebar
Provides one visible toolbar (Standard). The Sidebar is fully opened.
The visibility of elements on each of these three variants can be modified using the View menu
on the Menu bar. The configuration of menus, toolbars, and keyboard shortcuts can be modified
through the tabs on the Tools > Customize dialog. Because these variants are not based on the

Chapter 17 User Interface Variants | 541


notebook bar, there are no configuration options available in the Notebookbar tab of the Tools >
Customize dialog.

Contextual Single
The initial configuration for the Contextual Single interface variant is for the Menu bar to be
visible but for no toolbars to be displayed. Toolbars are automatically shown and hidden,
dependent on the user’s current context. For example, if an image is selected then the Image
toolbar is displayed, or if a drawing object is selected then the Drawing Object Properties toolbar
is displayed.
Figure 556 shows an example of the default Contextual Single interface when an image is
selected, with the context-sensitive Image toolbar shown and hidden automatically.

Figure 556: Contextual Single interface


The “x” symbol at the right end of the Menu bar is an icon for the Close Document command.
When switching to this user interface variant, Calc automatically opens the Sidebar if it is not
already open.
The visibility of elements on this variant can be modified using the View menu on the Menu bar.
The configuration of menus, toolbars, and keyboard shortcuts can be modified through the tabs
on the Tools > Customize dialog. Because this variant is not based on the notebook bar, there
are no configuration options available in the Notebookbar tab of the Tools > Customize dialog.

Tabbed interface
Introduction
The Tabbed interface (Figure 557) provides a familiar interface for users coming from proprietary
office suites such as Microsoft Office. It includes a Menu bar, an Icon bar, a Tab bar, icons for the
active tab, one or more tab-specific menus, and a Quick menu. On Windows and Linux, the
Menu bar can be hidden or displayed by clicking on the Menu Bar icon in the Icon bar (Figure
558).

1 Icon bar 2 Active tab 3 Tab bar 4 Icons on active tab 5 Tab menus 6 Quick menu
Figure 557: Tabbed interface with Menu bar hidden
In Calc, this user interface variant includes nine fixed tabs that are always visible, and six
additional tabs that are sometimes displayed. Each tab displays a set of icons grouped by
context. The context can change depending on the location of the cursor or the item selected.
Each tab also includes one or more tab-specific drop-down menus at the right-hand end. The
Quick menu is the same for all tabs.
The Tabbed interface can be customized using the Notebookbar tab of the Tools > Customize
dialog to show and hide the individual icons on the various tabs. See Chapter 15, Setting up and

542 |Calc Guide 24.8


Customizing, for more information. In addition, the size of icons used can be adjusted through
Tools > Options > LibreOffice > View > Icon Size > Notebookbar.
If the icons on a tab do not fit into the width of the Calc window, two right-pointing angle brackets
(>>) appear at the right end of the row. Press the >> button to view additional options that are
not currently visible (see, for example, Figure 561).

Icon bar
The Icon bar (Figure 558) is located at the top left of the tabs.

Figure 558: Icon bar


1 Menubar − Show / hide the Menu bar.
2 Open (Ctrl+O) − Open a file browser, where you can select the file to be opened.
3 Save (Ctrl+S) − Save the open file.
4 Undo (Ctrl+Z) − Undo the last action performed.
5 Redo (Ctrl+Y) − Redo the last undone action.
6 Print (Ctrl+P) − Open the Print dialog.

Quick menu
To the right of the tabs is a Quick menu (Figure 559) containing some commonly used
commands and links. Some of the Quick menu items have submenus, indicated by arrows on
the right.

Figure 559: Quick menu

Fixed tabs
The fixed tabs in Calc are File, Home, Insert, Layout, Data, Review, View, Extension, and Tools.
The nine fixed tabs are shown individually in the following subsections.

Chapter 17 User Interface Variants | 543


Each fixed tab has an associated menu, accessed through a button located at the right end of
the tab. This button is labeled with the same name as the tab. Some options available in the tab
menu may replicate options that are available on the tab; others may be extra options.
The appearance of a tab depends on both the configuration of your computer system and the
setup of your Calc installation. The following points should be noted about the illustrations that
follow:
• To increase readability of this chapter, the screen shots of tabs have been taken using a
relatively small Calc window. This means that the >> icon appears on most of the tabs,
indicating that some options are not visible.
• Left and right ends of the tabs are shown separately, making the illustrations large
enough to see the commands more easily.
• For each tab that shows a >> icon, a separate figure is included to show the additional
options that appear when the >> icon is pressed.
• A further figure is included to show the content of the menus at the right end of the tab.

File tab
Figure 560 shows the File tab and Figure 561 shows the additional options that are presented
when the >> icon is pressed.

Figure 560: File tab

Figure 561: File tab - additional options


The File tab has two menus, File and Help, and these are shown in Figure 562. Close and
LibreOffice Help icons are located adjacent to the File and Help menu buttons.

544 |Calc Guide 24.8


Figure 562: File tab menus

Home tab
Figure 563 shows the Home tab and Figure 564 shows the additional options that are presented
when the >> icon is pressed.

Figure 563: Home tab

Figure 564: Home tab - additional options


The Home tab has one menu, Home, as shown in Figure 565. Find and Replace (Ctrl+H), Sort
Ascending and AutoFilter (Ctrl+Shift+L) icons are located adjacent to the Home menu button.

Chapter 17 User Interface Variants | 545


Figure 565: Home tab menu

Insert tab
Figure 566 shows the Insert tab and Figure 567 shows the additional options that are presented
when the >> icon is pressed.

Figure 566: Insert tab

Figure 567: Insert tab - additional options


The Insert tab has one menu, Insert, as shown in Figure 568. Insert or Edit Pivot Table, Show
Draw Functions, and Function List icons are located adjacent to the Insert menu button.

546 |Calc Guide 24.8


Figure 568: Insert tab menu

Layout tab
Figure 569 shows the Layout tab and Figure 570 shows the additional options that are presented
when the >> icon is pressed.

Figure 569: Layout tab

Figure 570: Layout tab - additional options


The Layout tab has one menu, Layout, as shown in Figure 571. A Format Page icon is located
adjacent to the Layout menu button.

Chapter 17 User Interface Variants | 547


Figure 571: Layout tab menu

Data tab
Figure 572 shows the Data tab and Figure 573 shows the additional options that are presented
when the >> icon is pressed.

Figure 572: Data tab

Figure 573: Data tab - additional options


The Data tab has one menu, Data, as shown in (Figure 574). Find and Replace (Ctrl+H), Sort
Ascending, and AutoFilter (Ctrl+Shift+L) icons are located adjacent to the Data menu button.

548 |Calc Guide 24.8


Figure 574: Data tab menu

Review tab
Figure 575 shows the Review tab and Figure 576 shows the additional options that are
presented when the >> icon is pressed.

Figure 575: Review tab

Figure 576: Review tab - additional options


The Review tab has one menu, Review, as shown in Figure 577. A Manage Track Changes
icon is located adjacent to the Review menu button.

Chapter 17 User Interface Variants | 549


Figure 577: Review tab menu

View tab
Figure 578 shows the View tab and Figure 579 shows the additional options that are presented
when the >> icon is pressed.

Figure 578: View tab

Figure 579: View tab - additional options


The View tab has one menu, View, as shown in Figure 580. A Zoom icon is located adjacent to
the View menu button.

550 |Calc Guide 24.8


Figure 580: View tab menu

Extension tab
The Extension tab contains only the Extension tab menu, which contains the Extension
Manager (Ctrl+Alt+E) option (Figure 581).

Figure 581: Extension tab menu

Tools tab
Figure 582 shows the Tools tab and Figure 583 shows the additional options that are presented
when the >> icon is pressed.

Figure 582: Tools tab

Figure 583: Tools tab - additional options


The Tools tab has one menu, Tools, as shown in Figure 584. An Options icon is located
adjacent to the Tools menu button.

Chapter 17 User Interface Variants | 551


Figure 584: Tools tab menu

Additional tabs
Additional tabs appear when an item is selected; they are displayed between the View and
Extension tabs. The additional tabs in Calc are Draw, Form, Image, Media, Object, and Print.

Draw tab
Figure 585 shows the Draw tab and Figure 586 shows the additional options that are presented
when the >> icon is pressed. The Draw tab is displayed when a drawing object is selected.

Figure 585: Draw tab

Figure 586: Draw tab - additional options


The Draw tab has one menu, Draw, as shown in Figure 587. Area, Line, and Position and Size
icons are located adjacent to the Draw menu button.

552 |Calc Guide 24.8


Figure 587: Draw tab menu

Form tab
Figure 588 shows the Form tab, which is displayed when a form component is selected in design
mode.

Figure 588: Form tab


The Form tab has one menu, Form, as shown in Figure 589. A Form Properties icon is located
adjacent to the Form menu button.

Figure 589: Form tab menu

Image tab
Figure 590 shows the Image tab and Figure 591 shows the additional options that are presented
when the >> icon is pressed. The Image tab is displayed when an image is selected.

Chapter 17 User Interface Variants | 553


Figure 590: Image tab

Figure 591: Image tab - additional options


The Image tab has one menu, Image, as shown in Figure 592. Save, Area, Line, and Position
and Size icons are located adjacent to the Image menu button.

Figure 592: Image tab menu

Media tab
Figure 593 shows the Media tab, which is displayed a media object is selected.

Figure 593: Media tab


The Media tab has one menu, Media, as shown in Figure 594. Area, Line, and Position and
Size icons are located adjacent to the Media menu button.

554 |Calc Guide 24.8


Figure 594: Media tab menu

Object tab
Figure 595 shows the Object tab, which is displayed when an object (for example, an OLE
object) is selected.

Figure 595: Object tab


The Object tab has one menu, Object, as shown in Figure 596. Area, Line, and Position and
Size icons are located adjacent to the Object menu button.

Figure 596: Object tab menu

Print tab
Figure 597 shows the Print tab, which is displayed when a print preview is selected.

Figure 597: Print tab


The Print tab has one menu, Print, as shown in Figure 598. A Full Screen icon is located
adjacent to the Print menu button.

Chapter 17 User Interface Variants | 555


Figure 598: Print tab menu

Tabbed Compact interface


As its name suggests, the Tabbed Compact interface is a more compact version of the Tabbed
interface described in the previous section. The Tabbed Compact interface provides the same
nine fixed tabs (File, Home, Insert, Layout, Data, Review, View, Extension, and Tools) and six
additional tabs (Draw, Form, Image, Media, Object, and Print). However, in this case the
commands on each tab are displayed in a single row, using less vertical screen space.
Figure 599 shows an example of the Tabbed Compact interface for the File tab. Similar to the
behavior of the Tabbed interface, pressing the >> button provides access to additional options,
as shown in Figure 600 for this tab.

Figure 599: Tabbed Compact interface, File tab

Figure 600: Tabbed Compact interface, File tab, additional options


The content of individual tabs and tab menus is similar to the corresponding components of the
Tabbed interface and is not described further in this guide.
The Tabbed Compact interface can be customized using the Notebookbar tab of the Tools >
Customize dialog to show and hide the individual icons on the various tabs. See Chapter 15,
Setting up and Customizing, for more information. In addition, the size of icons used can be
adjusted through Tools > Options > LibreOffice > View > Icon Size > Notebookbar.

Groupedbar Compact interface


The Groupedbar Compact interface is a different type of user interface which does not utilize
toolbars or tabs to partition the available commands. Instead the commands are organized into
context-sensitive groups, visually separated by vertical lines. Each group contains icons, menus,
and other controls as appropriate. Figure 601 shows the default configuration of the Groupedbar
Compact commands (displayed, for example, when an empty cell is selected).

556 |Calc Guide 24.8


Figure 601: Groupedbar Compact interface
Similar to the behavior of the Tabbed interface, if the groups do not all fit into the width of the
Calc window, two right-pointing angle brackets (>>) appear toward the right (see Figure 601).
Press the >> button to access the additional groups that are not currently visible−see, for
example, Figure 602 which shows the hidden groups corresponding to Figure 601.

Figure 602: Groupedbar Compact - additional groups


As is evident from Figures 601 and 602, many groups provide several icons located above a
menu button. Press the menu button to access a menu of commands relating to the group, as
shown in Figure 603 for example.

Figure 603: Groupedbar Compact interface - Edit group and menu


The groups displayed in the Groupedbar Compact interface vary depending on context. For
example, if an image is currently selected then the groups shown in Figure 604 are displayed.

Chapter 17 User Interface Variants | 557


Figure 604: Groupedbar Compact interface with image selected
At the right end of the Groupedbar Compact interface is a small area containing Find and
Replace (Ctrl+H), LibreOffice Help, and Close icons, above a button labeled Menu. The
content of this menu is not context-sensitive and always contains the commands shown in
Figure 605.

Figure 605: Groupedbar Compact menu


The Groupedbar Compact interface can be customized using the Notebookbar tab of the Tools
> Customize dialog to show and hide the individual icons on the various groups. See Chapter
15, Setting up and Customizing, for more information. In addition, the size of icons used can be
adjusted through Tools > Options > LibreOffice > View > Icon Size > Notebookbar.

558 |Calc Guide 24.8


Calc Guide 24.8

Appendix A
Keyboard Shortcuts
Introduction
You can use Calc without a pointing device, such as a mouse or touchpad, by using keyboard
shortcuts. This appendix provides a comprehensive reference list of the available built-in
shortcuts, which you can browse to find ones that may be useful in your daily work.
When you first install LibreOffice, a default set of Calc keyboard shortcuts is available. These are
described in this chapter, assuming no customization. When using Calc, you can discover
shortcuts for common interactions by observing the key sequences identified on the menu
options and in the tooltips of toolbar icons. You can also explore a more comprehensive list of
shortcuts by viewing the Keyboard tab of the Customize dialog (Tools > Customize).
Further information about many individual key combinations can be found throughout the
chapters of this guide and in the Help system.
You can define your own shortcuts or change existing shortcuts by going to Tools > Customize
> Keyboard on the Menu bar. See Chapter 16, Setting up and Customizing, for further
instructions. Some shortcuts cannot be re-assigned; these are identified in the “Keyboard
shortcuts that cannot be modified” sections on pages 568 (Windows / Linux) and 576 (macOS).

Caution
Be careful when reassigning predefined shortcuts. Although you can reset shortcut
keys back to LibreOffice defaults, changing common hotkeys, such as F1 for Help,
can cause confusion and frustration, especially if other users share your computer.

Note
Different operating systems may allocate particular keys to operating system
functions and, in such cases, those keys may not perform the Calc functions
described in this appendix.
For example, the F1 function key may be used to put your Windows computer into a
sleep / hibernation mode and so cannot be used to access the Calc Help system.
For some macOS versions, the Cmd+F5 key sequence is used by macOS to display
its VoiceOver dialog and so cannot be used to control the display of Calc’s Sidebar.
Similarly the Shift+F11 key sequence may be used by macOS to show its desktop
and so cannot be used to access Calc’s Save as Template dialog.
Check your computer system’s documentation to determine which key presses are
used by the operating system and hence cannot carry out Calc functions.
The remainder of this chapter is in two main sections, one listing the keyboard shortcuts
available in the Windows and Linux environments, and the other listing the macOS keyboard
shortcuts.

Windows / Linux keyboard shortcuts

Note
Many of the keyboard shortcuts in this section use the Ctrl key. Some keyboards
have two Ctrl keys and in that case you may need to experiment to identify which of
the two keys to use.

560 |Calc Guide 24.8


Keyboard shortcuts for Menu bar options and toolbars
Tables 24 to 27 list Calc keyboard shortcuts that can be used instead of the options on the Menu
bar, the Standard toolbar, or the Formatting toolbar. The toolbars are assumed to contain the
initial default set of icons, without any user customization.
Table 24: Function key shortcuts for menu and toolbar options
Windows / Linux Equivalent Menu bar / toolbar option
F1 Help > LibreOffice Help.
F2 Edit > Cell Edit Mode.
Ctrl+F2 Insert > Function.
Ctrl+F3 Sheet > Named Ranges and Expressions > Manage.
Shift+F3 Format > Text > Cycle Case.
F4 Sheet > Cycle Cell Reference Types.
Ctrl+Shift+F4 View > Data Sources.
F5 View > Navigator.
Ctrl+F5 View > Sidebar.
Shift+F5 Tools > Detective > Trace Dependents.
Tools > Spelling.
F7
Spelling icon on the Standard toolbar.
Ctrl+F7 Tools > Thesaurus.
Tools > Language > Hangul/Hanja Conversion. The availability of
Ctrl+Shift+F7 this menu option depends on selections on Tools > Options >
Language Setting > Languages.
Shift+F7 Tools > Automatic Spell Checking.
Ctrl+F8 View > Value Highlighting.
F9 Data > Calculate > Recalculate.
Shift+F9 Tools > Detective > Trace Precedents.
Ctrl+Shift+F9 Data > Calculate > Recalculate Hard.
View > Styles.
F11
Styles > Manage Styles.
File > Templates > Save as Template.
Shift+F11
Via drop-down menu on Save icon on the Standard toolbar.
F12 Data > Group and Outline > Group.
Ctrl+F12 Data > Group and Outline > Ungroup.
Alt+F12 Tools > Options.

Table 25: Number key shortcuts for menu and toolbar options
Windows / Linux Equivalent Menu bar / toolbar option
Ctrl+1 Format > Cells.
Format > Number Format > Number (use the “1” key on the main
Ctrl+Shift+1 keyboard).
Format as Number icon on the Formatting toolbar.

Appendix A Keyboard Shortcuts | 561


Windows / Linux Equivalent Menu bar / toolbar option

Ctrl+Shift+2 Format > Number Format > Scientific (use the “2” key on the main
keyboard).
Format > Number Format > Date (use the “3” key on the main
Ctrl+Shift+3 keyboard).
Format as Date icon on the Formatting toolbar.
Format > Number Format > Currency (use the “4” key on the main
Ctrl+Shift+4 keyboard).
Format as Currency icon on the Formatting toolbar.
Format > Number Format > Percent (use the “5” key on the main
Ctrl+Shift+5 keyboard).
Format as Percent icon on the Formatting toolbar.

Ctrl+Shift+6 Format > Number Format > General (use the “6” key on the main
keyboard).

Table 26: Letter key shortcuts for menu and toolbar options
Windows / Linux Equivalent Menu bar / toolbar option
Format > Text > Bold.
Ctrl+B
Bold icon on the Formatting toolbar.
Ctrl+Shift+B Format > Text > Subscript.
Edit > Copy.
Ctrl+C
Copy icon on the Standard toolbar.
Insert > Comment.
Ctrl+Alt+C Sheet > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.
Sheet > Fill Cells > Fill Down.
Ctrl+D Via drop-down menus on Row or Column icons on the Standard
toolbar.
Format > Align > Centered.
Ctrl+E
Align Center icon on the Formatting toolbar.
Ctrl+Alt+E Tools > Extension Manager.
Ctrl+F Edit > Find.
Edit > Find and Replace.
Ctrl+H
Find and Replace icon on the Standard toolbar.
Format > Text > Italic.
Ctrl+I
Italic icon on the Formatting toolbar.
Ctrl+J Format > Align > Justified.
Ctrl+Shift+J View > Full Screen.
Insert > Hyperlink.
Ctrl+K
Insert Hyperlink icon on the Standard toolbar.
Format > Align > Left.
Ctrl+L
Align Left icon on the Formatting toolbar.
Data > AutoFilter.
Ctrl+Shift+L
AutoFilter icon on the Standard toolbar.

562 |Calc Guide 24.8


Windows / Linux Equivalent Menu bar / toolbar option
Format > Clear Direct Formatting.
Ctrl+M
Clear Direct Formatting icon on the Standard toolbar.
Ctrl+Shift+M Edit > Edit Mode.
File > New > Spreadsheet.
Ctrl+N
New icon on the Standard toolbar.
File > New > Templates.
Ctrl+Shift+N File > Templates > Manage Templates.
Via drop-down menu on New icon on the Standard toolbar.
File > Open.
Ctrl+O
Open icon on the Standard toolbar.
File > Print Preview.
Ctrl+Shift+O
Toggle Print Preview icon on the Standard toolbar.
File > Print.
Ctrl+P
Print icon on the Standard toolbar.
Ctrl+Shift+P Format > Text > Superscript.
Ctrl+Q File > Exit LibreOffice.
Format > Align > Right.
Ctrl+R
Align Right icon on the Formatting toolbar.
File > Save.
Ctrl+S
Save icon on the Standard toolbar.
File > Save As.
Ctrl+Shift+S
Via drop-down menu on Save icon on the Standard toolbar.
Ctrl+U Underline icon on the Formatting toolbar.
Edit > Paste.
Ctrl+V
Paste icon on the Standard toolbar.
Ctrl+Shift+V Edit > Paste Special > Paste Special.
Ctrl+Alt+Shift+V Edit > Paste Special > Paste Unformatted Text.
Ctrl+W Window > Close Window.
Edit > Cut.
Ctrl+X
Cut icon on the Standard toolbar.
Edit > Redo.
Ctrl+Y
Redo icon on the Standard toolbar.
Ctrl+Shift+Y Edit > Repeat.
Edit > Undo.
Ctrl+Z
Undo icon on the Standard toolbar.

Table 27: Other shortcuts for menu and toolbar options


Windows / Linux Equivalent Menu bar / toolbar option
Ctrl+Shift+Pg up Edit > Select > Select to Previous Sheet.
Ctrl+Shift+Pg
Edit > Select > Select to Next Sheet.
down

Appendix A Keyboard Shortcuts | 563


Windows / Linux Equivalent Menu bar / toolbar option
Backspace Sheet > Clear Cells.
Ctrl+Tab Sheet > Navigate > To Next Sheet.
Ctrl+Shift+Tab Sheet > Navigate > To Previous Sheet.
Ctrl+Space Edit > Select > Select Column.
Shift+Space Edit > Select > Select Row.
Ctrl+Shift+Space Edit > Select All.
Ctrl++ Sheet > Insert Cells (use the + key on the numeric keypad).
Ctrl+- Sheet > Delete Cells.

Ctrl+* Edit > Select > Select Data Area (use the * key on the numeric
keypad). The cursor must be inside the area.
Ctrl+; Insert > Date.
Ctrl+Shift+; Insert > Time.
Alt+ Shift + E Insert > OLE Object > Formula Object.

Ctrl+` View > Show Formula. The grave (`) character can be found to the
left of the “1” key on many English keyboards.
Shift+Esc Help > Search Commands.

Other Calc keyboard shortcuts


Tables 28 to 33 provide lists of additional Calc keyboard shortcuts that may be less obvious to
users because they are not indicated on Menu bar items or in tooltips associated with icons on
the Standard and Formatting toolbars.
Table 28: Other function key shortcuts
Windows / Linux Description
Shift+F1 Display context sensitive help.
Ctrl+F1 Display the comment attached to the current cell.

Ctrl+Shift+F2 Moves the cursor to the Input line where you can enter a formula for
the current cell.
Ctrl+Shift+F5
Moves the cursor to the Name Box field on the Formula bar.
Ctrl+Shift+T

Table 29: Other letter key shortcuts


Windows / Linux Description
Ctrl+A Selects all cells in the current sheet.
Ctrl+Shift+R Redraws the document view.
Ctrl+Shift+Z Reverses the action of the last undo command.

Table 30: Arrow key shortcuts


Windows / Linux Description
↑ Moves the cell focus up.

564 |Calc Guide 24.8


Windows / Linux Description
Moves the cursor in the up direction to the edge of the current data
Ctrl+↑ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+↑ Selects the adjacent cell or cells located in the up direction.
Selects in the up direction to the edge of the current data range (if the
Ctrl+Shift+↑ cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Alt+Shift+↑ Optimizes the row height based on the current cell.
→ Moves the cell focus right.
Moves the cursor in the right direction to the edge of the current data
Ctrl+→ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+→ Selects the adjacent cell or cells located in the right direction.
Selects in the right direction to the edge of the current data range (if
Ctrl+Shift+→ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Alt+→ Increases the width of the current column.
Alt+Shift+→ Optimizes the column width based on the current cell.
↓ Moves the cell focus down.
Moves the cursor in the down direction to the edge of the current data
Ctrl+↓ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).

Alt+↓ Opens a drop-down selection list of text items that have been
previously typed into other cells in the same column.
Shift+↓ Selects the adjacent cell or cells located in the down direction.
Selects in the down direction to the edge of the current data range (if
Ctrl+Shift+↓ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Alt+Shift+↓ Optimizes the row height based on the current cell.
← Moves the cell focus left.
Moves the cursor in the left direction to the edge of the current data
Ctrl+← range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+← Selects the adjacent cell or cells located in the left direction.
Selects in the left direction to the edge of the current data range (if the
Ctrl+Shift+← cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Alt+← Decreases the width of the current column.
Alt+Shift+← Optimizes the column width based on the current cell.

Table 31: Home and End key shortcuts


Windows / Linux Description
Home Moves the cursor to the first cell of the current row.
Ctrl+Home Moves the cursor to the first cell (A1) in the current sheet.

Appendix A Keyboard Shortcuts | 565


Windows / Linux Description
Shift+Home Selects cells from the cursor to the first cell of the current row.

Ctrl+Shift+Home Selects all cells from the cursor to the first cell (A1) in the current
sheet.

End Moves the cursor along the current row to the cell in the last column
containing data in the sheet.

Ctrl+End Moves the cursor to the cell in the last column and row that contain
data in the current sheet.

Shift+End Selects cells along the current row from the cursor to the cell in the
last column containing data in the sheet.

Ctrl+Shift+End Selects all cells from the cursor to the cell in the last column and row
that contain data in the current sheet.

Table 32: Other Page Up and Down key shortcuts


Windows / Linux Description
Pg up Moves up one screen page.
Ctrl+Pg up Moves to the previous sheet.
Shift+Pg up Selects cells from the cursor to the row one page up.
Alt+Pg up Moves one screen page to the left.
Alt+Shift+Pg up Selects cells from the cursor to the column one page to the left.
Pg down Moves down one screen page.
Ctrl+Pg down Moves to the next sheet.
Shift+Pg down Selects cells from the cursor to the row one page down.
Alt+Pg down Moves one screen page to the right.
Alt+Shift+Pg down Selects cells from the cursor to the column one page to the right.

Table 33: Other miscellaneous key shortcuts


Windows / Linux Description
Escape Cancels the current cell edit.
Insert After making a selection, opens the Paste Special dialog.

Ctrl+Insert Copies the selected cell or cell range to the clipboard in preparation
for a later paste operation.
Shift+Insert Pastes the contents of the clipboard into the selected cells.
Delete Deletes cell contents without a dialog (does not remove formatting).
Shift+Delete Removes and copies the selection to the clipboard.
Ctrl+Backspace Refocuses the view back on the cursor if it is not currently in view.
Shift+Backspace Deselects the current cell selection without deleting contents.
Alt+Backspace Reverses the last command or the last entry you typed.
Ctrl+[ Selects the cells on which the current cell is dependent.
Ctrl+] Selects the cells that are dependent on the current cell.
Ctrl+/ Selects the cells in the matrix formula range that contains the cursor.

566 |Calc Guide 24.8


Windows / Linux Description
Copies the contents of the cell above the cursor into the current cell,
Ctrl+’ but remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.
Moves the cursor to the next cell in the selected range, from top to
Enter bottom, then left to right. To specify in which direction the cursor
moves, go to Tools > Options > LibreOffice Calc > General on the
Menu bar.
Ctrl+Enter Inserts a manual line break in the current cell while editing a cell.

Ctrl+Shift+Enter Creates a matrix in the current range using the information entered on
the input line.

Alt+Enter Fills the selected cell range with the formula that you entered on the
input line.
Alt+= Equivalent to selecting Select Function > Sum on the Formula bar.

Chart keyboard shortcuts


Table 34 lists some shortcuts that are available within a Calc chart.

Tip
You can use the Alt key with the arrow keys and plus (+) and minus (-) keys to
move elements with a finer degree of movement for more accuracy.
Table 34: Chart shortcuts
Windows / Linux Effect
Tab Selects the next chart element.
Shift+Tab Selects the previous chart element.
Home Selects the first chart element.
End Selects the last chart element.
Esc Cancels selection.
Arrow keys Moves the element in the direction of the arrow.
Arrow keys in pie
Moves the selected pie segment in the direction of the arrow.
charts
F2 in titles Enters text input mode.
F3 in legends and
Opens groups so that you can edit the individual components.
data series
Ctrl+F3 in legends
Exits groups.
and data series

+/- Enlarges or shrinks the chart (use the + / - keys in the numeric
keypad).

+/- in pie charts Moves the selected pie segment off or into the pie chart (use the + / -
keys in the numeric keypad).

Outline keyboard shortcuts


Table 35 lists shortcuts that are available in an outline window. To use these shortcuts, press F6
or Shift+F6 until the vertical or horizontal outline window has the focus.

Appendix A Keyboard Shortcuts | 567


Table 35: Outline shortcuts
Windows / Linux Effect

Tab Cycles through each outline indicator from top to bottom or left to
right.
Shift+Tab Cycles through each outline indicator in the opposite direction.

Ctrl+1 to Ctrl+8 Show all levels up to the specified number while hiding all higher-
numbered levels in the outline.

+/- Shows (+) or hides (-) the focused outline group (use the + / - keys
in the numeric keypad).
Enter Activates the focused indicator button.
Arrow keys Cycles through indicator buttons in the direction of the arrow.

Keyboard shortcuts that cannot be modified


Table 36 identifies the key combinations that are grayed out (not available for modification) in the
Shortcut Keys list on the Keyboard tab of the Tools > Customize dialog with Calc selected.
Table 36: Grayed key combinations in Tools > Customize > Keyboard
Operating system Key combinations grayed in Customize dialog
F1, Ctrl+F1, Shift+F1
Shift+F2
Windows 10 Ctrl+F4, Alt+F4, Ctrl+Alt+F4
F6, Ctrl+F6, Shift+F6, Ctrl+Shift+F6
F10
F1, Ctrl+F1, Shift+F1
Shift+F2
Ctrl+F4, Alt+F4, Ctrl+Alt+F4
F6, Ctrl+F6, Shift+F6, Ctrl+Shift+F6
Linux
F10
Ctrl+Shift+0, Ctrl+Shift+1, Ctrl+Shift+2, Ctrl+Shift+3,
Ctrl+Shift+4, Ctrl+Shift+5, Ctrl+Shift+6, Ctrl+Shift+7,
Ctrl+Shift+8, Ctrl+Shift+9

macOS keyboard shortcuts


macOS keyboard symbols
Keys on many macOS keyboards use symbols rather than text labels. Table 37 identifies some
common macOS keyboard symbols with their meanings. In the tables that follow, the key names
are used rather than symbols, since the latter may not appear on all macOS keyboards.
Table 37: Common macOS keyboard symbols
Key name Symbol
Command (shortened to “Cmd” in the tables that follow) ⌘
Control (shorted to “Ctrl” in the tables that follow) ^
Option ⌥

568 |Calc Guide 24.8


Key name Symbol
Shift ⇑
Page Up (shortened to “Pg Up” in the tables that follow) ⇞
Page Down (shortened to “Pg Dn” in the tables that follow) ⇟
Home ↖
End ↘
Delete ⌫
Forward Delete (shortened to “Fwd Del” in the tables that follow) ⌦

Keyboard shortcuts for Menu bar options and toolbars


Tables 38 to 41 list Calc keyboard shortcuts that can be used instead of the options on the Menu
bar, the Standard toolbar, or the Formatting toolbar. The toolbars are assumed to contain the
initial default set of icons, without any user customizations.
Table 38: Function key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
F1 Help > LibreOffice Help.
F2 Edit > Cell Edit Mode.
Cmd+F2 Insert > Function.
Cmd+F3 Sheet > Named Ranges and Expressions > Manage.
Shift+F3 Format > Text > Cycle Case.
F4 Sheet > Cycle Cell Reference Types.
Shift+Cmd+F4 View > Data Sources.
F5 View > Navigator.
Cmd+F5 View > Sidebar.
Shift+F5 Tools > Detective > Trace Dependents.
Cmd+F7 Tools > Thesaurus.
Tools > Language > Hangul/Hanja Conversion. The availability of
Shift+Cmd+F7 this menu option depends on selections in LibreOffice > Preferences
> Language Setting > Languages.
Shift+F7 Tools > Automatic Spell Checking.
Cmd+F8 View > Value Highlighting.
F9 Data > Calculate > Recalculate.
Shift+F9 Tools > Detective > Trace Precedents.
Shift+Cmd+F9 Data > Calculate > Recalculate Hard.
File > Templates > Save as Template.
Shift+F11
Via drop-down menu on Save icon on Standard toolbar.
F12 Data > Group and Outline > Group.
Cmd+F12 Data > Group and Outline > Ungroup.

Appendix A Keyboard Shortcuts | 569


Table 39: Number key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Cmd+1 Format > Cells.
Format > Number Format > Number (use the “1” key on the main
Ctrl+Shift+1 keyboard).
Format as Number icon on Formatting toolbar.

Ctrl+Shift+2 Format > Number Format > Scientific (use the “2” key on the main
keyboard).
Format > Number Format > Date (use the “3” key on the main
Ctrl+Shift+3 keyboard).
Format as Date icon on Formatting toolbar.
Format > Number Format > Currency (use the “4” key on the main
Ctrl+Shift+4 keyboard).
Format as Currency icon on Formatting toolbar.
Format > Number Format > Percent (use the “5” key on the main
Ctrl+Shift+5 keyboard).
Format as Percent icon on Formatting toolbar.

Ctrl+Shift+6 Format > Number Format > General (use the “6” key on the main
keyboard).

Table 40: Letter key shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Format > Text > Bold.
Cmd+B
Bold icon on the Formatting toolbar.
Shift+Cmd+B Format > Text > Subscript.
Edit > Copy.
Cmd+C
Copy icon on the Standard toolbar.
Insert > Comment.
Option+Cmd+C Sheets > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.
Cmd+D Sheet > Fill Cells > Fill Down.
Format > Align > Centered.
Cmd+E
Align Center icon on the Formatting toolbar.
Option+Cmd+E Tools > Extension Manager.
Cmd+F Edit > Find.
Edit > Find and Replace.
Option+Cmd+F
Find and Replace icon on the Standard toolbar.
Ctrl+Cmd+F View > Full Screen.
Cmd+H LibreOffice > Hide LibreOffice.
Format > Text > Italic.
Cmd+I
Italic icon on the Formatting toolbar.
Cmd+J Format > Align > Justified.
Insert > Hyperlink.
Cmd+K
Insert Hyperlink icon on the Standard toolbar.

570 |Calc Guide 24.8


macOS Equivalent Menu bar / toolbar option
Format > Align > Left.
Cmd+L
Align Left icon on the Formatting toolbar.
Data > AutoFilter.
Shift+Cmd+L
AutoFilter icon on the Standard toolbar.
Format > Clear Direct Formatting.
Ctrl+M
Clear Direct Formatting icon on the Standard toolbar.
Shift+Cmd+M Edit > Edit Mode.
File > New > Spreadsheet.
Cmd+N
New icon on the Standard toolbar.
File > New > Templates.
Shift+Cmd+N File > Templates > Manage Templates.
Via drop-down menu on New icon on the Standard toolbar.
File > Open.
Cmd+O
Open icon on the Standard toolbar.
File > Print Preview.
Shift+Cmd+O
Toggle Print Preview icon on the Standard toolbar.
File > Print.
Cmd+P
Print icon on the Standard toolbar.
Shift+Cmd+P Format > Text > Superscript.
Cmd+Q LibreOffice > Quit LibreOffice.
Format > Align > Right.
Cmd+R
Align Right icon on the Formatting toolbar.
File > Save.
Cmd+S
Save icon on the Standard toolbar.
Shift+Cmd+S File > Save As.
View > Styles.
Cmd+T
Styles > Manage Styles.
Cmd+U Underline icon on the Formatting toolbar.
Edit > Paste.
Cmd+V
Paste icon on the Standard toolbar.
Shift+Cmd+V Edit > Paste Special > Paste Special.
Option+Shift+Cmd+
Edit > Paste Special > Paste Unformatted Text.
V
Cmd+W Window > Close Window.
Edit > Cut.
Cmd+X
Cut icon on the Standard toolbar.
Edit > Redo.
Cmd+Y
Redo icon on the Standard toolbar.
Shift+Cmd+Y Edit > Repeat.
Edit > Undo.
Cmd+Z
Undo icon on the Standard toolbar.

Appendix A Keyboard Shortcuts | 571


Table 41: Other shortcuts for menu and toolbar options
macOS Equivalent Menu bar / toolbar option
Shift+Cmd+Pg Up Edit > Select > Select to Previous Sheet.
Shift+Cmd+Pg Dn Edit > Select > Select to Next Sheet.
Delete Sheet > Clear Cells.
Ctrl+Space Edit > Select > Select Column.
Shift+Space Edit > Select > Select Row.
Ctrl+Shift+Space
Edit > Select All.
Cmd+A
Cmd++ Sheet > Insert Cells (use the + key on the numeric keypad).
Cmd+- Sheet > Delete Cells.
Cmd+* Edit > Select > Select Data Area.
Cmd+; Insert > Date.
Option+Cmd+= Insert > Object > Formula Object.
Tools > Spelling.
Shift+Cmd+;
Spelling icon on the Standard toolbar.
Cmd+, LibreOffice > Preferences.

Other Calc keyboard shortcuts


Tables 42 to 47 provide lists of additional Calc keyboard shortcuts that may be less obvious to
users because they are not indicated on Menu bar items or in tooltips associated with icons on
the Standard and Formatting toolbars.
Table 42: Other function key shortcuts
macOS Description
Shift+F1 Display context sensitive help.
Cmd+F1 Display the comment attached to the current cell.

Shift+Cmd+F2 Moves the cursor to the Input line where you can enter a formula for
the current cell.
Shift+Cmd+F5
Moves the cursor to the Name Box field on the Formula bar.
Shift+Cmd+T
F8 Toggles between the standard and extending selection modes.
Shift+F8 Toggles between the standard and adding selection modes.

Table 43: Other letter key shortcuts


macOS Description
Cmd+G Repeat search forwards.
Shift+Cmd+R Redraws the document view.
Shift+Cmd+Z Reverses the action of the last undo command.

572 |Calc Guide 24.8


Table 44: Arrow key shortcuts
macOS Description
↑ Moves the cell focus up.
Moves the cursor in the up direction to the edge of the current data
Cmd+↑ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+↑ Selects the adjacent cell or cells located in the up direction.
Selects in the up direction to the edge of the current data range (if the
Shift+Cmd+↑ cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Option+Shift+↑ Optimizes the row height based on the current cell.
→ Moves the cell focus right.
Moves the cursor in the right direction to the edge of the current data
Cmd+→ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+→ Selects the adjacent cell or cells located in the right direction.
Selects in the right direction to the edge of the current data range (if
Shift+Cmd+→ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Option+→ Increases the width of the current column.
Option+Shift+→ Optimizes the column width based on the current cell.
↓ Moves the cell focus down.
Moves the cursor in the down direction to the edge of the current data
Cmd+↓ range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).

Option+↓ Opens a drop-down selection list of text items that have been
previously typed into other cells in the same column.
Shift+↓ Selects the adjacent cell or cells located in the down direction.
Selects in the down direction to the edge of the current data range (if
Shift+Cmd+↓ the cell adjacent to the cursor is empty, the cursor moves to the next
cell that contains data).
Option+Shift+↓ Optimizes the row height based on the current cell.
← Moves the cell focus left.
Moves the cursor in the left direction the edge of the current data
Cmd+← range (if the cell adjacent to the cursor is empty, the cursor moves to
the next cell that contains data).
Shift+← Selects the adjacent cell or cells located in the left direction.
Selects in the left direction to the edge of the current data range (if the
Shift+Cmd+← cell adjacent to the cursor is empty, the cursor moves to the next cell
that contains data).
Option+← Decreases the width of the current column.
Option+Shift+← Optimizes the column width based on the current cell.

Appendix A Keyboard Shortcuts | 573


Table 45: Home and End key shortcuts
macOS Description
Home Moves the cursor to the first cell of the current row.
Cmd+Home Moves the cursor to the first cell in the current sheet (A1).
Shift+Home Selects cells from the cursor to the first cell of the current row.

Shift+Cmd+Home Selects all cells from the cursor to the first cell in the current sheet
(A1).

End Moves the cursor along the current row to the cell in the last column
containing data in the sheet.

Cmd+End Moves the cursor to the cell in the last column and row that contain
data in the current sheet.

Shift+End Selects cells along the current row from the cursor to the cell in the
last column containing data in the sheet.

Shift+Cmd+End Selects all cells from the cursor to the cell in the last column and row
that contain data in the current sheet.

Table 46: Other Page Up and Down key shortcuts


macOS Description
Pg Up Moves up one screen page.
Cmd+Pg Up Moves to the previous sheet.
Shift+Pg Dn Selects cells from the cursor to the row one page up.
Option+Pg Dn Moves one screen page to the left.
Option+Shift+Pg
Selects cells from the cursor to the column one page to the left.
Dn
Pg Dn Moves down one screen page.
Cmd+Pg Dn Moves to the next sheet.
Shift+Pg Dn Selects cells from the cursor to the row one page down.
Option+Pg Up Moves one screen page to the right.
Option+Shift+Pg
Selects cells from the cursor to the column one page to the right.
Up

Table 47: Other miscellaneous key shortcuts


macOS Description
Esc Cancels the current cell edit.
Fwd Del Deletes cell contents without a dialog (does not remove formatting).
Cmd+Delete Refocuses the view back on the cursor if it is not currently in view.
Option+Delete Reverses the last command or the last entry you typed.
Cmd+[ Selects the cells on which the current cell is dependent.
Cmd+] Selects the cells that are dependent on the current cell.
Selects the cells in the matrix formula range that contains the cursor.
Cmd+/ Use the forward slash key on the main keyboard or the numeric
keypad.

574 |Calc Guide 24.8


macOS Description
Copies the contents of the cell above the cursor into the current cell,
Cmd+’ but remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.
Moves the cursor to the next cell in the selected range, from top to
Enter bottom, then left to right. To specify in which direction the cursor
moves, go to LibreOffice > Preferences > LibreOffice Calc >
General on the Menu bar.
Cmd+Enter Inserts a manual line break in the current cell while editing a cell.

Shift+Cmd+Enter Creates a matrix in the current range using the information entered on
the input line.

Option+Enter Fills the selected cell range with the formula that you entered on the
input line.

Chart keyboard shortcuts


Table 48 lists some shortcuts that are available within a Calc chart.

Tip
You can use the Option key with the arrow keys and plus (+) and minus (-) keys to
move elements with a finer degree of movement for more accuracy.
Table 48: Chart shortcuts
macOS Effect
⇥ Selects the next chart element.
Shift+⇥ Selects the previous chart element.
Home Selects the first chart element.
End Selects the last chart element.
Esc Cancels selection.
Arrow keys Moves the element in the direction of the arrow.
Arrow keys in pie
Moves the selected pie segment in the direction of the arrow.
charts
F2 in titles Enters text input mode.
F3 in legends and
Opens groups so that you can edit the individual components.
data series
Cmd+F3 in legends
Exits groups.
and data series

Outline keyboard shortcuts


Table 49 lists shortcuts that are available in an outline window. To use these shortcuts, press F6
or Shift+F6 until the vertical or horizontal outline window has the focus.
Table 49: Outline shortcuts
macOS Effect

⇥ Cycles through each outline indicator from top to bottom or left to


right.

Appendix A Keyboard Shortcuts | 575


macOS Effect
Shift+⇥ Cycles through each outline indicator in the opposite direction.

Cmd+1 to Cmd+8 Show all levels up to the specified number while hiding all higher-
numbered levels in the outline.

+/- Shows (+) or hides (-) the focused outline group (use the + / - keys in
the numeric keypad).
Enter Activates the focused indicator button.
Arrow keys Cycles through indicator buttons in the direction of the arrow.

Keyboard shortcuts that cannot be modified


Table 50 identifies the key combinations that are grayed out (not available for modification) in the
Shortcut Keys list on the Tools > Customize > Keyboard dialog with Calc selected.
Table 50: Grayed key combinations in Tools > Customize > Keyboard
Operating system Key combinations grayed in Customize dialog
F1, Cmd+F1, Shift+F1
Shift+F2
Cmd+F4, Option+F4, Cmd+Option+F4
F6, Cmd+F6, Shift+F6, Shift+Cmd+F6
macOS
F10
Shift+Cmd+0, Shift+Cmd+1, Shift+Cmd+2, Shift+Cmd+3,
Shift+Cmd+4, Shift+Cmd+5, Shift+Cmd+6, Shift+Cmd+7,
Shift+Cmd+8, Shift+Cmd+9

576 |Calc Guide 24.8


Calc Guide 24.8

Appendix B
Error Codes
Introduction to Calc error codes
Calc provides feedback for errors of miscalculation, incorrect use of functions, invalid cell
references and values, and other user initiated mistakes. The feedback may be displayed within
the cell that contains the error (Figure 606), or on the Status bar (Figure 607), or in both,
depending on the type of error. Generally speaking, if the error occurs in the cell that is selected
(or contains the cursor), the error message is displayed on the Status bar.
As an example, Figure 606 shows the error code returned when a column is too narrow to
display the entire formatted date. The date displayed within the input line, 11/06/2023, would fit
within the cell without a problem, but the format used by the cell produces the date value
Monday, November 6, 2023.

Figure 606: Error codes displayed within cells


When the cell displaying the #REF! error code in Figure 606 is selected, the Status bar displays
the error message as shown in Figure 607. This message is more descriptive than the message
displayed in the cell, but it still may not provide enough information to correctly diagnose the
problem. For fuller explanations, consult the following tables and the Help topic, Error Codes in
LibreOffice Calc.

Figure 607: An error message displayed in the Status bar


This appendix presents error codes in two tables.
5) Table 51 lists error strings which are displayed within the cell that actually contains the
error. Except in the cases of the ###, #FMT, and #N/A errors, they all correspond to a
Calc error code number. Alphanumeric codes such as Err:502 and Err:511 can also
appear in cells; these are not separately identified in the Table 51 but their meanings are
given in Table 52.
6) Table 52 explains all of the error codes, listed by code number, including those error
codes in the first table.
7) Table 53 contains a list of Calc error functions, used to handle errors in calculations.

Tip
You can use the ERRORTYPE() function to find the code number for an error
occurring in a different cell. See Calc Error Functions below.

578 |Calc Guide 24.8


Error codes displayed within cells
Table 51: Error codes in cells
Cell ‍ tatus bar
S
Code Explanation of the error
display message
The column is too narrow to display the complete
formatted contents of the cell. This is not really an
error value, so there is no corresponding numerical
error code. The solutions to this problem are to
‍- ### - increase the width of the column, or select Format >
Cells > Alignment and click either Wrap text
automatically or Shrink to fit cell size in the
Properties area so as to make the text match the
current column width.
This value is outside of the valid limits for this
‍- #FMT - number format. This is not really an error value, so
there is no corresponding numerical error code.
A result for the formula expression is not available.
Error: Value not The formula cannot find what it has been asked to
- #N/A
available look for. This is not really an error value, so there is
no corresponding numerical error code.
Invalid floating point operation. Calculation result
Error: Invalid outside of the defined value range. A calculation that
503 #NUM!
numeric value‍ results in an overflow of the defined value range – a
value too big or too small.
No valid result is possible. A function cannot supply
a value corresponding to its definition; or a cell
519 #VALUE! ‍ rror: No value
E
referenced in the formula contains text instead of an
expected number.
Error: No code No code or no intersection. The intersection of
‍521 #NULL!
or intersection ranges produced zero cells.
Compiler: a row or column heading could not be
detected. Interpreter: the formula refers to a cell
whose column, row, or table/sheet has been deleted
or which is outside the table/sheet. The formula
Error: Not a
524 #REF! within the cell uses a reference that does not exist.
valid reference ‍
Either a column or a row description name could not
be resolved, or the column, row, or sheet that
contains a referenced cell is missing or it is outside
the sheet.
An identifier could not be evaluated: no valid
‍ rror: Invalid
E reference, no valid function name, no column/row
525 #NAME?
name label, no macro, incorrect decimal separator, add-in
not found.
‍ rror: Division
E The denominator of a division operation ("/") is 0
532 #DIV/0!
by zero (zero). Several functions can also return this error.

Appendix B Error Codes | 579


General error codes
The following table is an overview of the most common error messages for LibreOffice Calc.

Note
Errors described as Internal errors should not be encountered by users under normal
conditions.
Table 52: List of error codes
Code Status bar message Explanation of the error
Error: Invalid Invalid character in formula. Similar to the Invalid Name
501
character error (525) except that it occurs within a formula.
An argument of a function has an invalid value. This
Error: Invalid
502 error also occurs if more than one matching cell is
argument
found by the DGET() function.
Invalid floating point operation. Calculation result
503 Error: Invalid numeric outside of the defined value range. A calculation that
(#NUM!) value results in an overflow of the defined value range – a
value too big or too small.
The type of a parameter of a function is invalid. For
504 Error in parameter list instance, a parameter of a function is text instead of a
number.
‍507 Error: in bracketing Missing bracket or parenthesis
Missing bracket or parenthesis. For instance, closing
508 Error: in bracketing parenthesis without an opening parenthesis, or a
missing closing parenthesis in the middle of a formula.
Error: Operator
509 An operator is missing.
missing
Error: Variable Two operators, where the second is not a unitary
510
missing operator, follow each other.
Error: Variable The function requires more variables than those
511
missing provided.
Formula too long / complex. For example, the total
Error: Formula
512 number of internal tokens (that is, operators, variables,
overflow
brackets) in the formula exceeds 8192.
513 Error: String overflow Character string too long.
Error: Internal Internal capacity exceeded. An internal calculation
514
overflow stack overflow occurred.
Internal syntactical
515 Unknown error.
error
Matrix is expected on the calculation stack, but it is not
Internal syntactical
516 available. The calculation stack should contain a matrix
error
but it is not there.
Unknown operation code. A document containing a
Internal syntactical
517 newer feature is loaded in an older version of Calc that
error
did not support that feature.
Variable not available. A variable was supposed to be
Internal syntactical
518 popped from the calculation stack but it is not
error
available / not there.

580 |Calc Guide 24.8


Code Status bar message Explanation of the error
No valid result is possible. A function cannot supply a
519 value corresponding to its definition; or a cell
Error: No value
(#VALUE!) referenced in the formula contains text instead of an
expected number.
Internal syntactical The compiler has generated a code which it cannot
520
error interpret.
521 Error: No code or No code or no intersection. The intersection of ranges
(#NULL!) intersection produced zero cells.
A formula refers directly or indirectly to itself and the
Error: Circular
522 Iterations option is not activated under Tools >
reference
Options > LibreOffice Calc > Calculate.
The calculation procedure does not converge. A
function missed a targeted value (tends towards a
Error: Calculation
523 given value but does not reach it), or iterative
does not converge
references do not reach the minimum change within the
defined maximum steps (increments) that are set.
Compiler: a row or column heading could not be
detected.
Interpreter: the formula refers to a cell whose column,
524 Error: Not a valid row, or table/sheet has been deleted or which is
reference outside the table/sheet. The formula within the cell uses
(#REF!)
a reference that does not exist. Either a column or a
row description name could not be resolved, or the
column, row, or sheet that contains a referenced cell is
missing or it is outside the sheet.

525 An identifier could not be evaluated: no valid reference,


Error: Invalid name no valid function name, no column/row label, no macro,
(#NAME?) incorrect decimal separator, add-in not found.
‍ 30
5 Error: Add-in not
Add-in not found.
(#ADDIN?) found
‍ 31
5
Error: Macro not found Macro not available / not found.
(#MACRO?)
532 The denominator of a division operation ("/") is 0 (zero).
Error: Division by zero
(#DIV/0!) Several functions can also return this error.
Nested arrays are not
533 Nested arrays are not supported.
supported
Invalid size of array. The maximum limit for sorting has
been exceeded. The limit is twice the maximum
Error: Array or matrix number of rows, so for 1,048,576 rows the limit is
538
size 2,097,152 entries. Also obtained whenever a temporary
matrix could not be allocated due to its size
requirement.
Unsupported inline
539 Bad inline array content, non-value/non-string.
array content
A function that requires (re)loading of external sources
External content
540 is encountered and the user has not confirmed
disabled
reloading of external sources yet.

Appendix B Error Codes | 581


Calc Error Functions
The following table is an overview of the most common error functions of LibreOffice Calc. Error
functions are used to handle error conditions in calculations. For example, if a lookup calculation
returns the #N/A error, you can handle the situation with one of the “NA” error functions.
Table 53: Calc functions for handling errors
Function Description
Tests for error conditions, except the #N/A error value, and
returns TRUE or FALSE.
ISERR()
If an error occurs, the function returns a logical or numerical
value.
ISERROR() Returns TRUE if the cell has an error.
Returns TRUE if a cell contains the #N/A error value.(value not
ISNA() available)
If any other error occurs, the function returns FALSE.
NA() Returns the error value #N/A.
Returns a number representing a specific Error type, or the error
ERROR.TYPE()
value #N/A, if there is no error.
Returns the number corresponding to an error value occurring in
a different cell. With the aid of this number, you can generate a
ERRORTYPE() custom error message text.
If an error occurs, the function returns a logical or numerical
value.
Returns the value if the cell does not contain an error value, or
IFERROR()
the alternative value if it does.

582 |Calc Guide 24.8


Calc Guide
Working With Spreadsheets
About this book:

This book is for beginners to advanced users of Calc, the spreadsheet component
of LibreOffice. It covers the main features of Calc, including:
Entering, editing, and formatting data
Functions and formulas to perform complex calculations on data
Statistic analysis, pivot tables and goal seek for decision making
Database functions to arrange, store, and filter data
A wide range of 2D and 3D charts
Macros
And much more

About the authors:

This book was written by volunteers from the LibreOffice community. Profits from
sales of the printed edition will be used to benefit the community.
A PDF version of this book can be downloaded free from: https://documentation.lib
reoffice.org
About LibreOffice:

LibreOffice is the free, libre, and open source personal productivity suite from The
Document Foundation. It runs on Windows, macOS, and GNU/Linux. Support and
documentation is free from our large, dedicated community of users, contributors
and developers.
You too can get involved with volunteer work in many areas: development, quality
assurance, documentation, translation, user support, and more.
You can download LibreOffice Community from:
https://libreoffice.org/download/

For commercial/enterprise use:

The LibreOffice Enterprise class of applications may look and behave differently
from the Community edition described in this book. For guides to Enterprise
editions of LibreOffice, please refer to the professional partners that produced
them.

You might also like