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

Contributors
To this edition
Steve FanningJean Hollis Weber

Felipe Viggiano
Vasudev Narayanan

Kees Kriek

Jean Hollis Weber
Simon Brydon
Gabriel Godoy
Christian Chenal
Pierre-Yves Samyn
Andy Brown
Hazel Russman
Martin Saffron
Cathy Crumbley
Steve Fanning
Leo Moons
Samantha Hamilton
Stefan Weigel

Martin J Fox
Gabriel Godoy
Peter Schofield
Laurent Balland-Poirier
Shelagh Manton
Stephen Buck
Barbara M. Tobias
Dave Barton
Kees Kriek
Zachary Parliman
Randolph Gamo
Annie Nguyen

To previous editions
John A Smith
Andrew Pitonyak
Barbara Duprey
John A Smith
Philippe Clément
Peter Kupfer
Iain Roberts
Jared Kobos
Olivier Hallot
Claire Wood
Gordon Bates
Drew Jensen
Felipe Viggiano

Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
mailing list: documentation@global.libreoffice.org.

Note
Everything you send to a mailing list, including your email address and any otherpersonal information that is written in the message, is publicly archived and cannot
be deleted.

Publication date and software version
Published May 2021. Based on LibreOffice 7.1 Community.
Other versions of LibreOffice may differ in appearance and functionality.

Documentation for LibreOffice is available at http://documentation.libreoffice.org/en/Contents
Copyright................................................................................................................................... 2

Preface................................................................................................................................8
Who is this book for?................................................................................................................. 9
What’s in this book?..................................................................................................................9
Where to get more help.............................................................................................................9
What you see may be different................................................................................................11
Using LibreOffice on macOS...................................................................................................12
What are all these things called?............................................................................................12
Frequently asked questions....................................................................................................13
What’s new in LibreOffice Calc 7.1 Community?.....................................................................14

Chapter 1 Introduction....................................................................................................15
What is Calc?.......................................................................................................................... 16
Spreadsheets, sheets, and cells.............................................................................................16
Calc main window................................................................................................................... 16
Creating, opening, and saving spreadsheets..........................................................................23
Password protection................................................................................................................ 27
Navigating within spreadsheets...............................................................................................27
Selecting items in a spreadsheet............................................................................................31
Working with columns and rows..............................................................................................33
Working with sheets................................................................................................................ 35
Viewing a spreadsheet............................................................................................................ 37
Using the Navigator................................................................................................................. 39
Using document properties.....................................................................................................41
Regular expressions............................................................................................................... 44

Chapter 2 Entering, Editing, and Formatting Data.......................................................48
Introduction............................................................................................................................. 49
Entering data........................................................................................................................... 49
Speeding up data entry........................................................................................................... 55
Merging and splitting cells.......................................................................................................59
Sharing content between sheets.............................................................................................59
Validating cell contents............................................................................................................ 60
Editing data............................................................................................................................. 64
Formatting data....................................................................................................................... 69
AutoFormat of cells and sheets...............................................................................................77
Using themes.......................................................................................................................... 78
Value highlighting.................................................................................................................... 78
Using conditional formatting....................................................................................................79
Hiding and showing data.........................................................................................................85
Sorting records........................................................................................................................ 93
Find and replace..................................................................................................................... 96

Chapter 3 Creating Charts and Graphs.......................................................................101
Introduction........................................................................................................................... 102
LibreOffice 7.1 Calc Guide | 3

Chart Wizard......................................................................................................................... 102
Using the Sidebar to change chart settings...........................................................................109
Modifying charts.................................................................................................................... 111
Selecting and moving chart elements....................................................................................115
Changing chart type.............................................................................................................. 116
Titles, subtitles, and axis names............................................................................................117
Legends................................................................................................................................ 118
Formatting chart backgrounds...............................................................................................120
Data range and series........................................................................................................... 121
Axes...................................................................................................................................... 129
Data labels............................................................................................................................ 136
Grids..................................................................................................................................... 141
3D charts............................................................................................................................... 143
Trend and mean value lines..................................................................................................146
Error bars.............................................................................................................................. 152
Adding drawing objects to charts..........................................................................................155
Resizing, moving, and positioning charts..............................................................................156
Selecting multiple charts.......................................................................................................160
Changing overall appearance of charts.................................................................................161
Copying, exporting, and deleting charts................................................................................162
Gallery of chart types............................................................................................................ 164
Create box plots with whiskers in Calc..................................................................................181

Chapter 4 Using Styles and Templates.......................................................................183
What are styles? Why use them?..........................................................................................184
Calc style types..................................................................................................................... 184
Applying cell styles................................................................................................................185
Applying page styles.............................................................................................................188
Creating new styles...............................................................................................................188
Managing styles.................................................................................................................... 199
What is a template? Why use one?.......................................................................................201
Using a template to create a spreadsheet.............................................................................201
Creating a template...............................................................................................................202
Editing a template................................................................................................................. 203
Changing the template assigned to a document...................................................................204
Adding templates obtained from other sources.....................................................................205
Setting the default template...................................................................................................206
Organizing templates............................................................................................................ 207

Chapter 5 Using Images and Graphics.......................................................................210
Introduction........................................................................................................................... 211
Adding graphics (images) to a spreadsheet..........................................................................211
Modifying images..................................................................................................................215
Positioning, resizing, and arranging images..........................................................................217
Using LibreOffice’s drawing tools..........................................................................................220
Additional tools...................................................................................................................... 223
4 | LibreOffice 7.1 Calc Guide

Using Fontwork..................................................................................................................... 223

Chapter 6 Printing, Exporting, Emailing, and Signing..............................................225
Printing.................................................................................................................................. 226
Using print ranges................................................................................................................. 230
Page breaks.......................................................................................................................... 235
Printing options for page styles.............................................................................................236
Headers and footers.............................................................................................................. 238
Exporting to PDF................................................................................................................... 241
Exporting to other formats.....................................................................................................249
Emailing spreadsheets.......................................................................................................... 249
Digital signing of documents.................................................................................................249
Removing personal data.......................................................................................................252

Chapter 7 Using Formulas and Functions..................................................................253
Introduction........................................................................................................................... 254
Setting up a spreadsheet......................................................................................................254
Creating formulas.................................................................................................................. 255
Understanding functions....................................................................................................... 269
Strategies for creating formulas and functions......................................................................275
Finding and fixing errors........................................................................................................278
Examples of functions........................................................................................................... 281
Volatile / non-volatile functions..............................................................................................283
Using wildcards and regular expressions in functions...........................................................284
Advanced functions............................................................................................................... 286

Chapter 8 Using Pivot Tables.......................................................................................288
Introduction........................................................................................................................... 289
The Pivot Table Layout dialog...............................................................................................291
Working with the results of the pivot table.............................................................................302
Using pivot table results elsewhere.......................................................................................314
Using pivot charts.................................................................................................................. 317

Chapter 9 Data Analysis...............................................................................................321
Introduction........................................................................................................................... 322
Consolidating data................................................................................................................ 322
Creating subtotals................................................................................................................. 325
Using scenarios..................................................................................................................... 331
Using the Multiple Operations tool........................................................................................335
Using Goal Seek................................................................................................................... 341
Using the Solver.................................................................................................................... 343
Using Statistics tools............................................................................................................. 347

Chapter 10 Linking Data...............................................................................................370
Using multiple sheets............................................................................................................ 371
Referencing other documents...............................................................................................378
Using hyperlinks and URLs...................................................................................................379
Linking to external data......................................................................................................... 385

LibreOffice 7.1 Calc Guide | 5

Linking to registered data sources........................................................................................392
Embedding spreadsheets......................................................................................................398
XML Source.......................................................................................................................... 404

Chapter 11 Sharing and Reviewing Spreadsheets....................................................408
Introduction........................................................................................................................... 409
Sharing spreadsheets...........................................................................................................409
Reviewing documents...........................................................................................................411
Merging documents...............................................................................................................417
Comparing documents.......................................................................................................... 417
Saving versions..................................................................................................................... 417

Chapter 12 Macros........................................................................................................420
Introduction........................................................................................................................... 421
On Visual Basic for Application (VBA) compatibility...............................................................421
Using the macro recorder......................................................................................................421
Write your own functions.......................................................................................................426
Accessing cells directly.........................................................................................................435
Sorting................................................................................................................................... 437
Overview of BeanShell, JavaScript, and Python macros.......................................................438
Working with VBA macros.....................................................................................................444
Conclusion............................................................................................................................ 446

Chapter 13 Calc as a Database....................................................................................447
Introduction........................................................................................................................... 448
Associating a range with a name..........................................................................................449
Sorting................................................................................................................................... 455
Filtering................................................................................................................................. 456
Useful database-like functions..............................................................................................460

Chapter 14 Setting up and Customizing.....................................................................468
Introduction........................................................................................................................... 469
LibreOffice options................................................................................................................469
Options for loading and saving documents...........................................................................473
Calc-specific options............................................................................................................. 476
Default colors for charts........................................................................................................ 486
Customizing the user interface..............................................................................................487
Assigning macros to events..................................................................................................496
Adding functionality with extensions......................................................................................496
Adding custom colors............................................................................................................ 498

Appendix A Keyboard Shortcuts.................................................................................500
Introduction........................................................................................................................... 501
Windows / Linux keyboard shortcuts.....................................................................................501
macOS keyboard shortcuts...................................................................................................510

Appendix B Error Codes...............................................................................................518
Introduction to Calc error codes............................................................................................519
Error codes displayed within cells.........................................................................................520
6 | LibreOffice 7.1 Calc Guide

General error codes.............................................................................................................. 520

Index...............................................................................................................................523

LibreOffice 7.1 Calc Guide | 7

Calc Guide

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 and 3D charts.

•

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 connectedto 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.

Where to get more help | 9

Figure 1: The Help menu

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

What’s This? – For quick tips when a toolbar is visible, place the mouse pointer over anyof 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 overthe 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 bit of information to help
expand your knowledge of LibreOffice.

•Get Help Online‡ – Opens your default browser at the Ask LibreOffice forum of questions
and answers from the LibreOffice community https://ask.libreoffice.org/en/questions/.

•

Send Feedback‡ – Opens your default browser at the Feedback page of the LibreOfficewebsite 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 thesoftware to its default settings.

•

Get Involved‡ – Opens your default browser at the Get Involved page of the LibreOfficewebsite 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 Donation page of the
LibreOffice website https://donate.libreoffice.org/.

•

License Information – Outlines the licenses under which LibreOffice is made available.

10 | Preface•Check for Updates‡ – Opens a dialog and checks the LibreOffice website for updates toyour 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 isprovided to enable you to copy this information to the clipboard so that you cansubsequently 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
FAQs

Answers to frequently asked questions
https://wiki.documentfoundation.org/Faq

Mailing lists

Free community support is provided by a network of experienced users
https://www.libreoffice.org/get-help/mailing-lists/

Questions & Answers
andKnowledge BaseFree community assistance is provided in a question and answer
formatted web service. Search similar topics or open a new one in
https://ask.libreoffice.org/en/questions.
The service is available in several other languages; just replace /en/ withde, es, fr, ja, ko, nl, pt, tr, and many others in the web address above.

Native language
supportThe LibreOffice website in various languages
https://www.libreoffice.org/community/nlc/
Mailing lists for native languages
https://wiki.documentfoundation.org/Local_Mailing_Lists
Information about social networking
https://wiki.documentfoundation.org/Website/Web_Sites_services

Accessibility options

Information about available 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.
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 toTools > Options > LibreOffice > General and select or deselect the option Use LibreOfficedialogs.

What you see may be different | 11

IconsThe LibreOffice community has created icons for several icon sets: Colibre, Breeze, Breeze
Dark, Elementary, Karasa Jaga, Sifr, Sifr Dark, and Sukapura. 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 thendiffer from the ones used in this guide.
To change the icon set used, go to Tools > Options > LibreOffice > View. Choose from thedrop-down list under Icon Style.

Note
The Galaxy, Oxygen, and Tango icon sets are no longer included as part of thestandard installation package. They can be added back by downloading andinstalling 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-libreofficeSome of the previously included gallery backgrounds are now only available as anextension 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 andLinux. Table 2 gives some common substitutions for the instructions in this book. For a moredetailed list, see the application Help and Appendix A, Keyboard Shortcuts, to this guide.
Table 2: Example keystrokes for different environments
Windows or LinuxmacOS equivalent

EffectTools > Options
menu selection

LibreOffice > Preferences

Access setup options

Right-click

Control+click and/or right-click
depending on computer setup

Open a context menu

Ctrl (Control)⌘ (Command)

Used with other keys

Ctrl+Q⌘+Q

Exit / quit LibreOffice

F11

⌘+T

Open the Sidebar’s Styles deck

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 technicalnames for common controls are shown in Figure 2. In most cases the technical terms are notused 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.
12 | Preface

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.

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.

Frequently asked questions | 13

Is LibreOffice available in my language?
LibreOffice has been translated (localized) into over 100 languages, so your language isprobably supported. Additionally, there are over 100 spelling, hyphenation, and thesaurus
dictionaries available for languages, and dialects that do not have a localized programinterface. 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.
I am writing a software application. May I use programming code from LibreOffice in myprogram?
You may, within the parameters set out in the licenses: https://www.mozilla.org/MPL/2.0/
https://www.libreoffice.org/about-us/licenses/.
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 ofseveral 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 isneeded to run some of the solver engines described in Chapter 9, 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://java.com/en/download/manual.jsp.

Note
If you want to use LibreOffice features that require Java it is important that thecorrect 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://www.libreoffice.org/community/get-involved/.
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 requestthat you share with the project some of the profits you make from sales of books, inconsideration of all the work we have put into producing them.
Donate to LibreOffice: https://www.libreoffice.org/donate/.

What’s new in LibreOffice Calc 7.1 Community?
The LibreOffice 7.1 Release Notes are here:
https://wiki.documentfoundation.org/ReleaseNotes/7.1
A link to this page is also provided on the About LibreOffice dialog, accessed by clicking Help >About LibreOffice.

14 | Preface

Calc Guide

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 ofthe 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, andData 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 Chapter 13, 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 1,024 columns.

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

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

16 | Chapter 1 Introduction

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 14, Setting up andCustomizing.
•

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 andReplace, 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, AutoFormat Styles, Align.

•

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.

Calc main window | 17

•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, andother miscellaneous functions; for example Restart in Safe Mode, License
Information, Check for Updates, About LibreOffice.

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 toa more convenient location on your workspace. Docked toolbars can be undocked and moved toa different docked location or become floating toolbars. Likewise, floating toolbars can bedocked.
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 Chapter 1, Introducing LibreOffice, of the Getting
Started Guide.
The default set of icons (sometimes called buttons) on toolbars provides a wide range ofcommon commands and functions. You can also remove or add icons to toolbars. See Chapter
14, Setting up and Customizing, for more information.
Placing the mouse cursor over an icon, text box, or menu command displays a small box called atooltip that shows the name of the item’s function. To close a tooltip, move away from theunderlying component or press the Esc key.
To see a more detailed explanation of an icon, text box, or menu command, do one of thefollowing to open extended tips:•

To activate extended tips just once: press Shift+F1.

•

To activate extended tips from the Menu bar: go to Help > What’s This? and hover themouse pointer over an icon.

•

To turn extended tips on or off: 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 thisposition and cannot be used as a floating toolbar. However, it can be hidden or made visible bygoing to View > Formula Bar on the Menu bar.

Figure 4: Formula Bar
From left to right in Figure 4, the Formula Bar consists of the following:•

Name Box – gives the current active cell reference using a combination of a letter andnumber, for example A1. The letter indicates the column and the number indicates therow 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 theName Box to jump to the referenced cell. If you type the name of a named range andpress the Enter key, the named range is selected and displayed.

18 | Chapter 1 Introduction•

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, thenthe 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, andCount. 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 aformula to be entered.

•

Input line – displays the contents of the selected cell (data, formula, or function) andallows you to edit the cell contents. To turn the Input line into a multiline input area forvery long formulas, click the Expand Formula Bar icon on the right. To edit inside theInput line area, click in the area, then type your changes.

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 7, Using Formulas and Functions, for more information.

Status Bar
The Status Bar at the bottom of the workspace (Figure 5) 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 Chapter 1, Introducing LibreOffice, in theGetting Started Guide for more information.

Figure 5: Status Bar
The fields on the Status Bar, from left to right, are as follows.
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 styleShows the page style of the current sheet. To edit the page style, double-click on this field
and the Page Style dialog opens.
LanguageShows current default language as selected at Tools > Options > Language Settings >Languages.
Calc main window | 19

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
Right-click to open a context menu and select Standard selection, Extending selection,
or Adding selection. You can also double-click the icon to switch to the next selection
mode in sequence. The icon does not change when different selection modes are selected.
See Chapter 1, Introducing LibreOffice, in the Getting Started Guide for more information.
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.
Digital signature
If the document has been digitally signed, an icon shows here. You can click the icon toview the certificate. See Chapter 6, 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 sum of the contents is displayed bydefault. Right-click in this field to select other functions, such as the average value,
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 theview magnification.
Zoom percentage
Indicates the magnification level of the document. Right-click on the percentage to open alist of magnification values from which to choose. Click on the percentage to open theZoom & View Layout dialog.

Sidebar
The Sidebar (Figure 6) is a mixture of toolbar and dialog. When opened (View > Sidebar or
Ctrl+F5), it appears on the right side of the window and consists of five decks: Properties, Styles,
Gallery, Navigator, and Functions. Each deck has a corresponding icon on the Tab panel to theright of the Sidebar, allowing you to switch between them. The decks are described below.

20 | Chapter 1 Introduction

Figure 6: Sidebar
Properties
The Properties deck includes five content panels. Each panel has a More Options button
that open a dialog with additional options. These dialogs lock the document for editing until
they are 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.
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 verticalalignment, wrapping, indenting, merging, text orientation, and vertical stacking.
Cell Appearance: Options include background color and border formats, including line
color and style.
StylesThe Styles deck enables you to apply existing styles, modify existing styles, or create newstyles. This deck can also be opened by selecting Styles > Manage Styles on the Menubar, selecting View > Styles on the Menu bar, or pressing F11.

Calc main window | 21

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 39.
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.
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 tops of the columns and the left ends of the rows are a series of header boxes containing
letters and numbers. The column headers use alpha 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 4). If the headers are not visible on the spreadsheet, go to View > Headerson the Menu bar.

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 cancreate a new sheet by clicking on the plus sign to the left of the sheet tabs or by clicking in theblank 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.
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 7).
2) Select a color and click OK when finished to apply the color and close the dialog.

22 | Chapter 1 Introduction

Figure 7: Tab Color dialog
To add new colors to this color palette, see “Adding custom colors” in Chapter 14, Setting up andCustomizing.

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 Chapter
1, Introducing LibreOffice, in the 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 areentered 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, orpress Ctrl+O and locate the CSV file that you want to open.
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 8) opens. Here you can select options for importing a CSV
file into a Calc spreadsheet.
Creating, opening, and saving spreadsheets | 23

4) Click OK to open and import the file.

Figure 8: 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 > Language Settings > Languages > Formats. If another language isselected, that language will determine how numbers are treated.

•

From row – specifies which row the import starts with. The initial rows are visible in thepreview window at the bottom of the dialog.

Separator Options• Fixed width – separates data into columns by a set number of characters. Click on theruler that appears in the preview window to set the width.
•

Separated by – separates data into columns based on the separator defined here. SelectOther 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.

24 | Chapter 1 Introduction

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, time, and scientificnotation. 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 decimal numbers. The
rest, including numbers formatted in scientific notation, 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 andregion.

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 USEnglish entries, the Standard format is applied.
– Hide – the data in the column are not imported.

Saving spreadsheets
For information on how to save files manually or automatically, see Chapter 1, Introducing
LibreOffice, in the Getting Started Guide. Calc can save spreadsheets in a range of formats andalso export spreadsheets to PDF and XHTML file formats; see Chapter 6, 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 inanother format.
1) Select File > Save As on the Menu bar, click the down arrow at the right of the Save iconon the Standard toolbar and select Save As from the drop-down menu, or press
Ctrl+Shift+S to open the Save As dialog (Figure 9).
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.

Creating, opening, and saving spreadsheets | 25

Figure 9: The Save As dialog
Each time a file is saved in a format other than ODF format, the Confirm File Format dialog
opens (Figure 10). 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 Warnwhen 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.

Figure 10: Confirm File Format dialog
If you select Text CSV format (*.csv), the Export Text File dialog (Figure 11) opens. Here you canselect 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 havechanged 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.

26 | Chapter 1 Introduction

Figure 11: 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 theavailable 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 Chapter 1, Introducing LibreOffice, in the Getting Started Guide.

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 groupof selected cells depends on the operating system being used and how you have set up
LibreOffice.
•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 celland 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 4 on page 18). Type the reference of the cell you want to moveto and press the Enter key. Cell references are case insensitive. Thus, typing a3 or A3 will
move the focus to cell A3.

Navigating within spreadsheets | 27

•Using the Navigator – to open the Navigator (Figure 21), go to View > Navigator on the
Menu bar, or press F5, or click the Navigator button on the Sidebar. Type the cellreferences 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 theEnter key” section on page 30.

•

Pressing Shift+Enter moves the focus one cell in the opposite direction to that associatedwith 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 thefirst 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 inthe 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 cellin 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 notcontain any data.
– Page Down moves the cell focus down one complete screen display.
– Page Up moves the cell focus up one complete screen display.

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 three ways to navigate between different sheets in a
spreadsheet.
•

Using the Navigator – when the Navigator is open (Figure 21), double-clicking on any ofthe listed sheets selects the sheet.

•

Using the keyboard – using key combinations Ctrl+Page Down moves one sheet to theright and Ctrl+Page Up moves one sheet to the left.

•

Using the mouse – clicking on one of the sheet tabs at the bottom of the spreadsheet
selects that sheet.

If there are many sheets in the spreadsheet, some of the sheet tabs may be hidden. If this is thecase, use the four buttons to the left of the sheet tabs to move the tabs into view (Figure 12).

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

28 | Chapter 1 Introduction

Figure 12: 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.

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 andkey combinations you can use for spreadsheet navigation in Calc.
Table 3. Keyboard cell navigation
Keyboard
Cell navigation
shortcut→/←Moves cell focus right/left one cell.

↑/↓

Moves cell focus up/down one cell.

Ctrl+→ /Ctrl+←

If focus is on a blank cell, Ctrl+→ moves focus along the current row to thefirst cell on the right that contains data. If there is no cell on the rightcontaining data, it moves focus along the current row to the last cell at theright of the sheet.
If focus is on a blank cell, Ctrl+← moves focus along the current row to thefirst 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 Aof the sheet.
If focus is on a cell containing data, Ctrl+→ normally moves focus along thecurrent 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 cellat the left edge of the next data region to the right. In this case, if there is nodata region to the right, focus is moved along the current row to the last cellat the right of the sheet.
If focus is on a cell containing data, Ctrl+← normally moves focus along thecurrent 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 cellat the right edge of the next data region to the left. In this case, if there is nodata region to the left, focus is moved along the current row to the cell incolumn A of the sheet.

Navigating within spreadsheets | 29

Keyboard
shortcut

Cell navigation

Ctrl+↑ /Ctrl+↓

If focus is on a blank cell, Ctrl+↑ moves focus up the current column to thefirst 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 tothe 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 thecurrent 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 tothe 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 thecell in row 1 of the sheet.
If focus is on a cell containing data, Ctrl+↓ normally moves focus down thecurrent 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 tothe cell at the top edge of the next data region below. In this case, if there isno data region below, focus is moved down the current column to thebottom of the sheet.

Ctrl+Home /Ctrl+EndA detailed description of these shortcuts is given on Page 28.

Alt+Page Down /Alt+Page Up

Moves focus one screen to the right/left (if possible).

Ctrl+Page Down /Ctrl+Page Up

Moves focus to the next sheet to the right/left in sheet tabs if there are more
sheets in that direction.

Tab /Shift+Tab

Moves focus to the next cell on the right/left.

Enter /
Shift+Enter

Moves focus down/up one cell (unless you have changed this 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 (Figure13) to change the Enter key settings. Select the direction cell focus moves from the drop-downlist. 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 inanother cell by pressing the Enter key; here you can disable this feature.

30 | Chapter 1 Introduction

Figure 13: 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 4).

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 cursor:
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 mousebutton.
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) Right-click in the Selection mode field on the Status Bar (Figure 5 on page 19) and selectExtending selection.
3) Click in the cell in the opposite corner of the range of cells.

Selecting items in a spreadsheet | 31

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 4 on page 18).
2) Enter the cell reference for the upper left-hand cell, followed by a colon (:), and then thelower right-hand cell reference, then press the Enter key. For example, to select the rangethat 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) Right-click in the Selection mode field on the Status Bar (Figure 5 on page 19) and selectAdding 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.

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

32 | Chapter 1 Introduction

Figure 14: 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.

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 thecolumn 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.

Working with columns and rows | 33

2) Go to Sheet on the Menu bar. For columns, select Sheet > Insert Columns and thenselect Columns Before or Columns After. For rows, select Sheet > Insert Rows andthen 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 buttonon 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.

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 thecontext menu, select Sheet > Delete Cells on the Menu bar, or press Ctrl+- to open the
Delete Cells dialog (Figure 15). 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 15: 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 andselect Delete in the context menu, select Sheet > Delete Cells on the Menu bar, orpress 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.

34 | Chapter 1 Introduction•Highlight the required columns or rows by holding down the left mouse button on theheader of the first one and then dragging across the required number of headers. Thenright-click on one of the selected column or row headers and select Delete Columns orDelete 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 andselect 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 16) 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 Sheeton 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 fromthe context menu.

Figure 16: 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 17). To move or copy a sheet into a different spreadsheet,
use the Move/Copy Sheet dialog.
Working with sheets | 35

Dragging and dropping
To move a sheet to a different position within the same spreadsheet, click on the sheet tab anddrag 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 thesame or a different spreadsheet, its position within the spreadsheet, and the sheet name when it
is moved or copied.

Figure 17: Move/Copy Sheet dialog
1) In the current document, right-click on the sheet tab you wish to move or copy and selectMove 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 alreadyopen, 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 soon).
6) Click OK to confirm the move or copy and close the dialog.

CautionWhen 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.

36 | Chapter 1 Introduction

Deleting sheets
To delete a single sheet, right-click on the sheet tab you want to delete and select Delete Sheetin the context menu, or go to Sheet > Delete Sheet on the Menu bar. Click Yes to confirm thedeletion.
To delete multiple sheets, select the sheets (see “Selecting sheets” on page 33), 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. 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 editingor 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 thecontext 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 Sheetdialog (Figure 16 on page 35).

•

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, thefollowing 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 characterof 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 Chapter 1, Introducing LibreOffice, in the Getting
Started Guide.

Viewing a spreadsheet | 37

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 18 shows some frozen rows and columns. The heavier horizontal line between rows 3 and23 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 andcolumns, select the cell (not a row or column) that is below the row and to the right of thecolumn that you want to freeze
2) 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 18: 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 thewindow). 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 19
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 isused by three formulas in other cells. Using the split-screen technique, the cell containing thenumber 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 eachof the formulas.

Figure 19: Split screen example

Splitting horizontally or vertically
There are two ways to split a screen horizontally or vertically:
38 | Chapter 1 Introduction

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 19.
Method Two:
For a horizontal split, click on the thick black line at the top of the vertical scroll bar (Figure 20)
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 20) and drag the split line to the right of the column where you want the vertical split
positioned.

Figure 20: 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 shownin Figure 20.
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 thescreen vertically.
2) Go to View on the Menu bar and select Split Window. Thick lines appear between therows 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 totoggle it off.

Using the Navigator
The Navigator (Figure 21) is available in all LibreOffice modules. It provides tools and methods tomove quickly through a spreadsheet and find specific items.

Using the Navigator | 39

Figure 21: Navigator dialog in Calc
The Navigator categorizes and groups spreadsheet objects which you can click on to movequickly 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 listof 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.

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 thespecified column in the same row.

•

Row – type a row number and press the Enter key to reposition the cell cursor to thespecified row in the same column.

•

Data Range – specifies the current data range denoted by the position of the cell cursor.

•

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 canhighlight using the Data Range icon.

•

Contents – toggles on / off the display of the contents view in the lower part of theNavigator dialog, to temporarily reduce its size. There is no equivalent control needed on
the Navigator deck of the Sidebar.

•

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 9, Data Analysis, for more
information about scenarios. Double-click a name to apply that scenario and the result is

40 | Chapter 1 Introduction

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 havegiven 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. Thesedefault 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 22 and its tabs are described below.

Figure 22: Properties dialog, General tab

Using document properties | 41

GeneralContains 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 apassword 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.

•

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 thename 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 bygoing 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.

•

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 alsodeleted.

Description
Contains optional editable descriptive information about the spreadsheet.
•

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 whitespace characters or semicolons.

•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, thispage 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 adjacent Remove Property button todelete a custom property.
42 | Chapter 1 Introduction

CMIS Properties
Only relevant for spreadsheets stored on remote servers. See the Help or the Getting Started
Guide for more information.

Security
Enables two password-protected security options.
•

Open file read-only – select to allow this document to be opened only in read-onlymode. 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 theoriginal.

•

Record changes – select to require that all changes be recorded. To protect therecording 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 thisdocument 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 beembedded 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 notembed 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.

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

Regular expressions
Support for regular expressions (often known as regex or regexp) is a hidden gem within Calc.
Regular expressions are very powerful and enable users to define complex search patterns forlocating data of interest within a spreadsheet. Some users may find the syntax used to define a
regular expression daunting and inexperienced users may make mistakes. However a small
investment in time to learn the basic concepts and some of the syntax will pay rich dividends inthe future. We recommend that you do not try to memorize the full syntax but just concentrate on
discovering a few aspects that will help you in your everyday work. As you see the benefits ofusing regular expressions, you will certainly be motivated to learn more.
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 utilises the open source Regular Expressions package from theInternational Components for Unicode (ICU), see http://userguide.icu-project.org/strings/regexp
for further details, including a full definition of the syntax for ICU Regular Expressions.
Regular expressions | 43

Regular expressions appear in three areas of Calc’s functionality, as follows:•

Searching with the Find and Replace dialog, accessed by selecting Edit > Find andReplace on the Menu bar, by clicking the Find and Replace icon on the Find toolbar, orby pressing Ctrl+H. See Chapter 2, Entering, Editing, and Formatting Data, for more
information.

•

Filtering using the Standard Filter and Advanced Filter dialogs, accessed by selecting
Data > More Filters > Standard Filter and Data > More Filters > Advanced Filter. See
Chapter 2, Entering, Editing, and Formatting Data, for more information.

•

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 checked. 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 ofthe cell contents. See Chapter 7, 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 23.

Figure 23: 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 theentire 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 Replacedialog (Figure 24).

44 | Chapter 1 Introduction

Figure 24: Using a regular expression on the Find and Replace dialog
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.
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.
Suppose we want to filter the same spreadsheet (Figure 23) to show only data relating to theTennis 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 25).

Regular expressions | 45

Figure 25: Using regular expressions on the Standard Filter dialog
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 Region from the second drop-down menu in the Field name column.
7) Select = from the second drop-down menu in the Condition column.
8) Type North|East in the second text box in the Value column.
9) If necessary, click the icon to expand the Options area of the dialog.
10) Make sure that the Regular expressions checkbox is checked.
11) Click OK and Calc updates the data displayed in accordance with the specified filter
criteria.
The data shown in Figure 26 can be used to show a simple example of a function call thatincorporates a regular expression. Suppose we wanted to calculate the revenue from the sale ofpencils, 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 thename of any product that starts with the characters “pen”. Alternatively we could calculate therevenue 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 thecharacters “book”.

Figure 26: Stationery sales andrevenue data

46 | Chapter 1 IntroductionIn Calc there are 26 functions that support the use of regular expressions and these are listed in
Chapter 7, Using Formulas and Functions. The REGEX function is particularly powerful,matching and extracting, or optionally replacing, text using regular expressions. For example theformula =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
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 7, Using Formulas and Functions, for more information
about wildcards.
There are numerous websites that include examples of regular expressions and these provide an
endless source of inspiration and ideas to help improve your data analysis skills.
Additional information about regular expressions in Calc can be found in the Help system and on
The Document Foundation’s wiki starting at
https://wiki.documentfoundation.org/Documentation/HowTo/Calc/Regular_Expressions.

Regular expressions | 47

Calc Guide

Chapter 2
Entering, Editing, andFormatting 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 sheetsof the same spreadsheet at the same time. After entering data, you can format and display it invarious ways.

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 thenumeric keypad.

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

Leading zeroes
By default, if a number is entered with leading zeroes, for example 01481, Calc will drop theleading zeroes. To retain both the number format and a minimum number of characters in a cellwhen 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 andselect Format Cells in the context menu, or use the keyboard shortcut Ctrl+1, to open theFormat Cells dialog (Figure 27).
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 ofcharacters required. For example, for four characters, enter 4. Any number less than fourcharacters 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.

Tip
To format numbers with only decimal places, but without a leading zero, follow steps
1 and 2 above, then in the Format code box type a . (period or full stop) followed
by ? (one or more question marks) to represent the number of decimal places
required. For example, for 3 decimal places, type .??? and click OK. Any number
with only decimal places will then have no zero before the decimal, for example
0.01856 becomes .019.

Entering data | 49

Figure 27: 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 28), select Number in the drop-down list, and enter
4 in the Leading zeroes field. Formatting is applied immediately.

Figure 28: Set leading zeroes in Sidebar

50 | Chapter 2 Entering, Editing, and Formatting Data

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 27).
2) Make sure the Numbers tab is selected, then select Text from the Category list.
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.
Method 2
1) Select the cell.
2) On the Sidebar, go to the Properties deck.
3) In the Number Format panel (Figure 28), select Text in the drop-down list. Formatting isapplied to the cell immediately.

Tip
If numerical characters do not need to be treated as numbers in calculations (forexample when entering zip codes), you can type an apostrophe (') before thenumber, for example '01481. When you move the cell focus, the apostrophe isremoved, the leading zeroes are retained, and the number is converted to leftaligned text.

Text
Click in a cell and type the text. The text is left-aligned by default. Cells can contain several linesof 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. Clickon the Expand / Collapse Formula Bar icon located on the right of the Formula Bar and theInput line becomes multi-line, as shown in Figure 29. 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 29: 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 ahyphen (–) or use text, for example 10 Oct 2020. The date format automatically changes to theselected format used by Calc.

Entering data | 51

NoteTools > Options > Language Settings > Languages > Formats > Dateacceptance patterns defines the date patterns that will be recognized by Calc. In
addition, every locale accepts input in an ISO 8601 Y-M-D 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 27).
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.

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 youwant the character to appear.
2) Go to Insert > Special Character on the Menu bar to open the Special Characters dialog(Figure 30).
3) From the grid of characters, select the required character. The last character selected isshown 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 beselected 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 andclick 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.

Tip
You can quickly insert one of your recent or favorite special characters by clicking theInsert Special Characters icon on the Standard toolbar and selecting the required
character from the drop-down. Click More Characters on this drop-down to open theSpecial Characters dialog (Figure 30).

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

52 | Chapter 2 Entering, Editing, and Formatting Data

Figure 30: Special Characters dialog

AutoCorrect options
Calc automatically applies many changes during data input using AutoCorrect, unless you havedeactivated any AutoCorrect changes. 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 thechange 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 toopen the AutoCorrect dialog (Figure 31).
•

Replace – edit the replacement table for automatically correcting or replacing words orabbreviations.

•

Exceptions – specify the abbreviations or letter combinations that you do not wantcorrected 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.

Entering data | 53

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

ResultA - 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)

54 | Chapter 2 Entering, Editing, and Formatting Data

Speeding up data entry
Entering data into a spreadsheet can be very labor-intensive, but Calc provides tools forremoving some of the drudgery from input. These tools include drag and drop (to move or copy
contents of one location to another using a mouse), an AutoInput tool, the Fill tool, and selection
lists.
The Fill tool and selection lists automate input of repetitive material into cells. Calc also has theability to input information into multiple sheets of the same spreadsheet at the same time.

AutoInput tool
The AutoInput function in Calc automatically completes entries, based on other entries in thesame column. The column is scanned up to a maximum of 2000 cells or 200 different strings.
When text is highlighted in a cell, AutoInput can be used as follows:•

To accept the completion, press Enter or F2, or click the mouse button.

•

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 58 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 deselectAutoInput.

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 cursor 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 tocopy 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

Speeding up data entry | 55

Tip
You can use the keyboard shortcut Ctrl+D as an alternative to selecting Sheet > FillCells > 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 cursor over the small selection handle in the bottom right corner of the selected
cell. The cursor will change shape.
3) Click and drag in the direction you want the cells to be filled, vertical or horizontal. If theoriginal 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 57), a
series will be created. To duplicate the number or text instead, hold Ctrl while dragging.

CautionWhen you are selecting cells so you can use the Fill tool, make sure that none of thecells contain data, except for the cell data you want to use. When you use the Filltool, 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 thedefined 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 thedefined increment to the end value.
– Left – creates a series running from right to left within the selected cell range using thedefined increment to the end value.

Figure 33: Fill Series dialog
56 | Chapter 2 Entering, Editing, and Formatting Data•

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 ofcustomized lists. For example, by entering January in the first cell, the series iscompleted 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, anumerical series using 1,3,5 is automatically completed with 7,9,11,13; a date andtime 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 theDate 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.

Speeding up data entry | 57

Figure 34: Sort Lists dialog

Figure 35: Creating a new sort list

Selection lists
Selection lists are available only for text and are limited to using only text that has already beenentered 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.

58 | Chapter 2 Entering, Editing, and Formatting Data

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 Menubar, or click on the Merge and Center Cells icon on the Formatting toolbar, or right-clickon the selected cells and select Merge Cells in the context menu. Using Merge andCenter Cells will center align any contents in the cells.
3) If the cells contain any data, the Merge Cells dialog (Figure 36) opens, showing choices
for moving or hiding data in the hidden cells.
4) Make your selection and click OK.

Figure 36: Merge choices for non-empty cells

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

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 andCenter Cells icon on the Formatting toolbar, or right-click and select Split Cells in thecontext 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 thecorrect cell.

Sharing content between sheets
You might want to enter the same information in the same cell on multiple sheets, for example toset 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.
Sharing content between sheets | 59

Figure 37: Select Sheets dialog
1) Go to Edit > Select > Select Sheets on the Menu bar to open the Select Sheets dialog(Figure 37).
2) Select the individual sheets where you want the information to be repeated.
3) Click OK to select the sheets and the sheet tabs will be highlighted.
4) 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.
5) Deselect the sheets when you have finished entering the information that you wantrepeated in the sheets.

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

CautionThis technique automatically overwrites, without any warning, any information that isalready 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 datathat is valid or appropriate for the cell. You can also use validation in your own work as a guide toentering 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.

60 | Chapter 2 Entering, Editing, and Formatting Data

Depending on how validation is set up, it can also define the range of contents that can beentered, 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 (Figure38).
2) Define the type of contents that can be entered in that cell using the options given on thetabbed pages for Criteria, Input Help, and Error Alert. The options are explained below.

Figure 38: Validity dialog – Criteria tab

Criteria options
Specify the validation rules for the selected cells using the Criteria tab of the Validity dialog asshown in Figure 38. For example, you can define criteria such as numbers between 1 and 10, or
texts that are no more than 20 characters.
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 thenext time the dialog is called up.
– Time – all numbers correspond to time format. The entered values are formatted thenext time the dialog is called up.

Validating cell contents | 61

– 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 androws, 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 ofcharacters 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, thisdefines 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 canbe opened either by clicking the down arrow at the right of the cell, or by selecting thecell and pressing Alt+↓.

•

Sort entries ascending – sorts the selection list in ascending order and filters duplicatesfrom 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 theValue box.

•

Value – enter the value for the data validation option that you selected in the Data dropdown 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 beentered in cell A4.

Input Help options
Enter the message to be displayed when the cell or cell range is selected in the spreadsheet(Figure 39).
•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 entertext 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.

62 | Chapter 2 Entering, Editing, and Formatting Data

Figure 39: Validity dialog – Input Help tab

Error Alert options
Define the error message that is displayed when invalid data is entered in a cell (Figure 40).
•Show error message when invalid values are entered – when selected, displays theerror 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 orCancel. 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 macrois executed after the error message is displayed.

•

Title – enter the title of the macro or the error message that you want to display wheninvalid data is entered in a cell.

•

Error message – enter the message that you want to display when invalid data isentered in a cell.

Validating cell contents | 63

Figure 40: 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 werepreviously 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 42), then it is removed. If you want to copy avalidity rule with the rest of the cell, use Edit > Paste Special > Paste Special toopen the Paste Special dialog (Figure 43), then select Paste all or Formats andclick OK.

Editing 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.

64 | Chapter 2 Entering, Editing, and Formatting Data

Deleting cells
This option completely deletes selected cells, columns, or rows. The cells below or to the right ofthe 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 andchoose Delete in the context menu, or press the Ctrl+– keys.

Figure 41: Delete Cells dialog
3) The Delete Cells dialog (Figure 41) 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 thedeleted 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 andchoose Clear Contents from the context menu, or press the Backspace key.
3) In the Delete Contents dialog (Figure 42), choose any of the options or choose Delete
All. Click OK.

Editing data | 65

Figure 42: Delete Contents dialog

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 originalformatting used in the cell.
Alternatively, click in the Input line on the Formula Bar, then double-click on the data to highlight itcompletely 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 thecell. For example, changing the phrase “Sales in Qtr. 2” to “Sales rose in Qtr” can be done asfollows.

Using 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 newdata.
4) Alternatively, use the keyboard arrow keys to reposition the cursor where you want tostart entering the new data in the cell, then press the Delete key or Backspace key todelete 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.
66 | Chapter 2 Entering, Editing, and Formatting Data

Paste Special function
You can use the Paste Special function to paste into another cell selected parts of the data in theoriginal 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, orright-click and select Copy in the context menu, or press Ctrl+C.
3) Select the target cell or cell range.
4) Go to Edit > Paste Special > Paste Special on the Menu bar, or right-click and selectPaste Special > Paste Special in the context menu, or use the keyboard shortcut
Ctrl+Shift+V, to open the Paste Special dialog (Figure 43).
5) Select the options for Selection, 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 43: Paste Special dialog

Tip
Instead of steps 5) and 6) above, you can press one of the three shortcut buttons at
the top of the dialog – Values Only, Values & Formats, or Transpose.

Editing data | 67

Paste Special options•

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

•

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.
– 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, theoperation is not applied to the target cell of an empty cell in the clipboard. If you selecta 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.
– 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.
– 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 thesource file are updated in the target file, ensure that Paste All is also selected. You
can also link sheets within the same spreadsheet. When you link to other files, a DDElink is automatically created. A DDE link is inserted as a matrix formula and can only
be modified as a whole.

•

Shift Cells – set the shift options for the target cells when the clipboard content isinserted.
– 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.
68 | Chapter 2 Entering, Editing, and Formatting 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 Number, or Paste Only Formulaoptions 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 thecontext menu.
3) Alternatively use the similar options in the Insert > Field menu on the Menu bar.

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.

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, either defined as part of a cell style so that it isautomatically applied, or applied manually to the cell. For more control and extra options, select acell or cell range and use the Format Cells dialog. 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 thecontext menu, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Alignment tab (Figure 44).
4) Under Properties, select Wrap text automatically and click OK.

Formatting data | 69

Figure 44: Format Cells dialog – Alignment tab
Method 2
1) Select the cell.
2) On the Properties deck of the Sidebar, open the Alignment panel (Figure 45).
3) Select the Wrap text option to apply the formatting immediately.

Figure 45: Wrap text formatting

70 | Chapter 2 Entering, Editing, and Formatting Data

Manual line breaks
To insert a manual line break while typing in a cell, press Ctrl+Enter. When editing text, doubleclick 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 notchange and the text may still overlap the end of the cell. You have to change the cell widthmanually 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 thecontext menu, or press Ctrl+1, to open the Format Cells dialog.
3) Click on the Alignment tab (Figure 44).
4) Under Properties, select Shrink to fit cell size and click OK.

Formatting numbers
Several number formats can be applied to cells by using icons on the Formatting toolbar(highlighted in Figure 46). Select the cell, then click the relevant icon to change the number
format.
For more control or to select other number formats, use the Numbers tab of the Format Cells
dialog (Figure 27 on page 50):•

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 dateformat and currency symbol.

Figure 46: Number icons on Formatting toolbar

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 47) and select a font in the drop-down list. The font can also bechanged using the Font tab on the Format Cells dialog.
3) Click on the down arrow on the right of the Font Size box on the Formatting toolbar andselect a font size from the drop-down list. The font size can also be changed using theFont tab on the Format Cells dialog.
4) To change the character format, click on the Bold, Italic, or Underline icons on theFormatting toolbar.

Formatting data | 71

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
with addition to the Justified alignment.

Figure 47: 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 thesame 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 14, 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 48).
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.
Any font effect changes are applied to the current selection, or to the entire word that contains
the cursor, or to any new text that you type.

72 | Chapter 2 Entering, Editing, and Formatting Data

Figure 48: 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 44 on page 70).
1) On the Alignment tab of the Format Cells dialog, select the Reference edge from which torotate the text as follows:– Text Extension From Lower Cell Border – writes the rotated text from the bottom celledge 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.
An Asian layout mode checkbox is available on the Alignment tab of the Format Cells dialog
when Asian language support is enabled and the text direction is set to vertical. This option 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
Formatting data | 73

characters in the converted text are rotated 90 degrees to the right. Asian characters are notrotated.

Using the icons on the Formatting toolbar
The icons 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.

•

To change text direction from vertical to horizontal (default), click on the Text direction
from left to right icon.

•

To change text direction from left to right, which is the default direction for Western fonts,
to a right to left direction used in some fonts, for example Arabic, then click on the RightTo-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 > Language Settings >Languages > Default Language for Documents. If it is necessary to make thebuttons visible, right-click on the toolbar and select Visible Buttons in the context
menu, then click on the icon you require and it will be placed on the Formatting
toolbar.

Asian typography
If Asian language support is enabled through Tools > Options > Language Settings >Languages > Default Languages for Documents > Asian, an Asian Typography tab isincluded on the Format Cells dialog (Figure 49). This tab enables setting of typographic options
for cells in Asian language documents.

Figure 49: Format Cells dialog - Asian Typography tab
The following options are provided:•

Apply list of forbidden characters to the beginning and end of lines – prevents thecharacters 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

74 | Chapter 2 Entering, Editing, and Formatting Datacharacters, go to Tools > Options > Language Settings > Asian Layout > First andLast Characters.
•

Allow hanging punctuation – prevents commas and periods from breaking the line.
Instead, these characters are added to the end of the line, even in the page margin.

•

Apply spacing between Asian and non-Asian text – 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 theFormatting toolbar to apply the default styles to borders, or the Format Cells dialog for greater
control. See Chapter 4, Using Styles and Templates, for more information on the options.

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 tobe 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 thecontext menu, or press Ctrl+1, to open the Format Cells dialog.
3) On the Borders tab (Figure 50), 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 downarrow 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: click the required icon to add a border to the present borders or Shift-click to
add a border and remove the present borders.

Formatting data | 75

Figure 50: Format Cells dialog – Borders tab

Formatting cell backgrounds
To format the background color for a cell or a group of cells (see Chapter 4, Using Styles andTemplates, 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 thecontext 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 mostrecently selected color. Click the down arrow to the right of the Background Color icon to selecta different color from the Background Color palette.

76 | Chapter 2 Entering, Editing, and Formatting Data

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 51).
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 51: 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 groupof cells.
2) Select a cell range of at least 4x4 cells.
3) Go to Format > AutoFormat Styles to open the AutoFormat dialog. The Add button is
now active (if a range smaller than 4x4 cells is selected, the Add button will be
unavailable).
4) Click Add.
5) In the Name box of the Add AutoFormat dialog that opens, type a meaningful name forthe new format and click OK.
6) The new AutoFormat is now available in the Format list on the AutoFormat dialog. Click
OK to close the AutoFormat dialog.

AutoFormat of cells and sheets | 77

Using 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 foruse for that spreadsheet.
To apply a theme to a spreadsheet:
1) Go to Format > Spreadsheet Theme on the Menu bar, or click the Spreadsheet Themeicon on the Tools toolbar, to open the Theme Selection dialog (Figure 52), which lists theavailable 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 52: Theme Selection dialog
If you wish, you can now use the Styles deck on the Sidebar to modify specific styles. These
modifications do not modify the theme; they only change the appearance of the style in the
spreadsheet you are creating. For more about modifying styles, see Chapter 4, Using Styles andTemplates.

Value highlighting
Value highlighting displays cell contents in different colors depending on the type of content. An
example of value highlighting is shown in Figure 53.
•

Text is shown in black.

•

Formulas are shown in green.

•

Numbers (including date and time) are shown in blue.

78 | Chapter 2 Entering, Editing, and Formatting Data

Figure 53: 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 forformatting are printed.
Go to View > Value Highlighting on the Menu bar, or use the keyboard shortcut Ctrl+F8, to turnthe function on or off. When value highlighting is switched off, the original formatting colors areused 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 modefor value highlighting may not be what you want if you are going to format the cells for printing.

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. It is
recommended not to overuse conditional formatting as this could reduce the impact of data that
falls outside those specifications.
See “Conditional formatting example” on page 84 for an example of how to use conditional
formatting.

Note
Conditional formatting depends upon the use of styles and the AutoCalculate featuremust be enabled. If you are not familiar with styles, see Chapter 4, Using Styles andTemplates, for more information.

Setting up conditional formatting1) 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 54), Color Scale (Figure 55), Data Bar(Figure 56), Icon Set (Figure 57), or Date (Figure 58), on the Menu bar to open theConditional 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 59) and create a newcell style. Repeat this step as necessary.
7) Click OK to save the conditions and close the dialog. The selected cells are now set toapply a result using conditional formatting.

Using conditional formatting | 79

Figure 54: Conditional Formatting dialog – Condition

Figure 55: Conditional Formatting dialog – Color Scale80 | Chapter 2 Entering, Editing, and Formatting Data

Figure 56: Conditional Formatting dialog – Data Bar

Figure 57: Conditional Formatting dialog – Icon Set

Using conditional formatting | 81

Figure 58: Conditional Formatting dialog - Date

Figure 59: Cell Style dialog

Types of conditional formatting
Condition
Condition is the starting point when using conditional formatting. Here you can define what
formats to use to highlight any data in the spreadsheet that falls outside the specifications thatyou have defined.

Color scale
Use color scale to set the background color of cells depending on the values of the data in thosecells. 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.

82 | Chapter 2 Entering, Editing, and Formatting Data

Data bar
Data bars provide a graphical representation of data in the spreadsheet. The graphicalrepresentation is based on the values of data in a selected range. Click on More Options in theConditional 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.

Icon set
Icon sets display an icon next to the data in each selected cell to give a visual representation ofwhere the cell data falls within the defined range that you set. The icon sets available include
colored arrows, gray arrows, colored flags, colored signs, symbols, bar ratings, and quarters.
Icon sets can only be accessed when the Conditional Formatting dialog has been opened and All
Cells has been selected for the condition.

Date
Date applies a defined style depending on a data range that you choose in the drop-down menu.
Examples include Tomorrow, Last 7 days, This week, Next month, Last year.

Tip
Although each 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 54 to 58 are not distinct. Once the dialog is open you can create conditionsof 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 thenpress 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.

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 60).
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.

Using conditional formatting | 83

Figure 60: Manage Conditional Formatting 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 tothe 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 selectPaste Special > Paste Special in the context menu, or press Crtl+Shift+V, to open the
Paste Special dialog (Figure 43 on page 67).
4) Make sure that only Formats is selected and click OK to paste the conditional formatting
into the cell.

Conditional formatting example
One use case for conditional formatting is highlighting the totals that exceed the average value ofall totals. If the totals change, the formatting changes correspondingly, without having to apply
other styles manually. It is recommended that the Styles deck on the Sidebar is open and visible
before proceeding.

Defining conditions
1) Select the cells where you want to apply a conditional style.
2) Go to Format > Conditional > Condition, Color Scale, Data Bar, Icon Set, or Datefrom the Menu bar to open the Conditional Formatting dialog.
3) Enter the conditions you want to use for conditional formatting.

Generating number values
You may want to give certain values in your tables particular emphasis. For example, in a table ofturnovers, you can show all the values above the average in green and all those below theaverage in red. This is possible with conditional formatting.
1) Create a table in which a few different values occur. For your test, you can create tables
with any random numbers. In one of the cells, enter the formula =RAND(), and you willobtain a random number between 0 and 1. If you want integers of between 0 and 50,
enter the formula =INT(RAND()*50).
84 | Chapter 2 Entering, Editing, and Formatting Data

2) Copy the formula to create a row of random numbers.
3) Click the bottom right corner of the selected cell, and drag to the right and downward until
the desired cell range is selected.

Defining cell styles
The next step is to apply a cell style to all values that represent above-average turnover and one
to cells that are below the average.
1) Right-click in a blank cell and select Format Cells in the context menu to open theFormat Cells dialog.
2) Click the Background tab, press the Color button, and select a background color, thenclick OK.
3) In the Conditional Formatting dialog, select New Style in the Apply Style drop-down list to
open the Cell Style dialog.
4) Enter a name of the new style. For this example, name the style Above.
5) Define a second style, click again in a blank cell and proceed as described above. Assign
a different background color to the cell and assign a name. For this example, name thestyle Below.

Calculating average
In our particular example, we are calculating the average of the random values. The result is
placed in a cell:1) Click in a blank cell, for example, J14, and go to Insert > Function on the Menu bar, or
click the Function Wizard icon on the Formula Bar, or press Ctrl+F2, to open the
Function Wizard dialog.
2) Select AVERAGE in the Functions list.
3) Use the cursor to select all your random numbers.
4) Click OK to close the Function Wizard.

Applying cell styles
Now you can apply the conditional formatting to the sheet:
1) Select all cells containing the random numbers.
2) Go to the Format > Conditional > Condition on the Menu bar to open the Conditional
Formatting dialog.
3) Define the condition for each cell as follows: if cell value is less than J14, format with cellstyle Below OR if cell value is greater than or equal to J14, format with cell style Above.

Hiding and showing data
In Calc you can hide elements so that they are neither visible on a computer display nor printed
when a spreadsheet is 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 selectto copy columns A to C. When you require a hidden element again, you can reverse the process
and show the element.

Hiding and showing data | 85

Hiding data
SheetsSelect 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.
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 HideColumns in the context menu.

Cells
Hiding individual cells is more complicated. First, you need to define the cells as protected andhidden; 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 thecontext menu, or press Ctrl+1, to open the Format Cells dialog (Figure 61).
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 selectProtect Sheet in the context menu, to open the Protect Sheet dialog (Figure 62).
6) Select Protect this sheet and the contents of protected cells.
7) Create a password and then confirm the password.
8) Select or deselect the options in the Allow all users of this sheet to area so that users canselect protected or unprotected cells.
9) Click OK to save the changes and close the dialog.

86 | Chapter 2 Entering, Editing, and Formatting Data

Figure 61: Format Cells dialog – Cell Protection tab

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 inthe spreadsheet.

Figure 62: Protect Sheet dialog

Hiding and showing data | 87Showing data
SheetsSelect 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 Sheetdialog. 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.

Cells1) Go to Tools > Protect Sheet on the Menu bar, or right-click on the sheet tab and selectProtect Sheet in the context menu, to open the Protect Sheet dialog (Figure 62).
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 61).
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.

Group and outline
If you are continually hiding and showing the same cells, you can create an outline of your dataand group rows or columns together so that you can collapse a group to hide it or expand agroup to show it using a single click.
The basic controls for grouping and outlining show plus (+) or minus (-) signs on the groupindicator 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 groupindicator appears to the left of any rows grouped or above any columns grouped. Figure
63 shows a group indicator on the left of the first two rows of the spreadsheet showingthat they have been grouped.

88 | Chapter 2 Entering, Editing, and Formatting Data

Figure 63: 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 thegroup 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 andOutline > Show Details on the Menu bar.
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 thegroup.
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.

CautionAny hidden groups of rows or columns must be displayed. If they are hidden, thenthe 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 theselection. For example, in Figure 64 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 aregrouped 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 thecells as necessary.

Hiding and showing data | 89

Figure 64: 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.

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 theselected cell range and creates one-row list boxes where you can choose the items thatyou 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 asa 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 65).
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 thefilter criteria and options that you specified are shown.

90 | Chapter 2 Entering, Editing, and Formatting Data

Figure 65: 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 nameof 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 theargument. You will see the column identifiers if no text is available for the field names.

•

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 andNot Empty entries.

•

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 cellrange.

•

Copy results to – select the check box and then select the cell range where you want todisplay 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 “Regular expressions” in Chapter 1,
Introduction.

•

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
Hiding and showing data | 91

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 timeby 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 oflexical 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 thesame sheet, you must first define database ranges, then apply the AutoFilters to the
database ranges.
2) Go to Data > AutoFilter on the Menu bar, or click the AutoFilter icon on the Standard
toolbar. An arrow button is added to the head of each column in the database range.
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 66).
4) Select the value or string that you want to use as the filter criteria. The records that match
the filter criteria that you selected are then shown.

Figure 66: AutoFilter example

92 | Chapter 2 Entering, Editing, and Formatting Data

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 67).
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 thefilter criteria and options that you specified are shown.

Note
The options for advanced filtering are the same as those used for standard filtering,see “Applying a standard filter” on page 90 for more information.

Figure 67: Advanced Filter dialog
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 aresearching 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 islong, 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.

Sorting records | 93

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, toopen the Sort dialog.
3) On the Options tab (Figure 68), choose options including whether to sort on rows orcolumns. See “Sort options” on page 95 for details.
4) On the Sort Criteria tab (Figure 69), 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) 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 areprotected, since these are not modified by the sort.

Figure 68: Sort dialog – Options tab

94 | Chapter 2 Entering, Editing, and Formatting Data

Figure 69: Sort dialog – Sort Criteria tab

Sort options
On the Options tab of the Sort dialog (Figure 68), 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 multilevel collation, entries are first compared in their primitive forms with their cases anddiacritics ignored. If they evaluate as the same, their diacritics are taken into accountfor the second-level comparison. If they still evaluate as the same, their cases,character widths, and Japanese Kana difference are considered for the third-levelcomparison.
•

Range contains column/row labels – omits the first column/row in the selection fromthe sort. The Direction setting at the bottom of the dialog defines the name and functionof this check box: if top to bottom, then column labels; if left to right, then row labels.

•

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 aseries of values such as, A1, A2, A3, A4, A5, A6, ..., A19, A20, A21. When you put thesevalues 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 aresorted correctly.

Sorting records | 95

•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 associatedwith 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 57.

•

Language – select the language for the sorting rules.

•

Options – select a sorting option for the language. For many languages this selection isgrayed out but for some languages options are available. For example, for German thedefault choice is Alphanumeric, but you can also select the Phone book option to
include the umlaut special character in the sorting.

•

Top to bottom (sort rows) – sorts rows by the values in the active columns of theselected range.

•

Left to right (sort columns) – sorts columns by the values in the active rows of theselected range.

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.

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

Find toolbar

Figure 70: Find toolbar
1) 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 70). By default this toolbar is docked in
the lower left of the Calc window. You can undock the toolbar and move it.
2) Type a search term in the Find text box.
3) To refine the search, you can select the Match Case option. For example, if Owner is thesearch term, selecting Match Case will find Owner but not owner. You can also select the
Find All or Formatted Display options.
4) Click the Find Next or Find Previous icon. To find other occurrences of the same term,
continue clicking the icon.

96 | Chapter 2 Entering, Editing, and Formatting Data

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

Finding
1) In the Find and Replace dialog (Figure 71), 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 asneeded.
6) Or, click Find All to locate all cells containing the search criteria. These cells will behighlighted in the spreadsheet. A Search Results dialog will pop up, listing the cell
locations.

Replacing1) In the Find and Replace dialog (Figure 71), 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:
6) Click Find Next to locate the first instance of the search criteria.
7) If necessary, click Replace to replace the search criteria with the contents of the Replacebox.
8) Repeat as required.
9) 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.

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

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

Find and replace | 97

Figure 71: Find and Replace dialog

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 acell 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 thedefault-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 file.

•

Replace – enter the replacement text, or select a recent replacement text or style fromthe 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 file.

•

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”.

98 | Chapter 2 Entering, Editing, and Formatting Data–* (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. Regularexpressions offer the most powerful method of searching for text strings. For more
information about regular expressions, see the “Regular expressions” section in Chapter
1, Introduction.

•

Similarity search – find terms that are similar to the Find text. Select this option, andthen 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. Selectthis 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.

•

Direction – determines the Rows or Columns order for searching the cells.

•

Search in – select either Formulas, Values, or Comments to search for the charactersthat 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 >Language Settings > Languages 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 Replacedialog, Calc’s initial default behavior is to display the Search Results dialog (Figure 72) after it
has completed the operation. This dialog summarizes the results. In addition, affected cells arehighlighted 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.

Find and replace | 99

Figure 72: Search Results dialog

100 | Chapter 2 Entering, Editing, and Formatting Data

Calc Guide

Chapter 3
Creating Charts and Graphs
Presenting information visually

Introduction
Charts and graphs can be powerful tools for conveying information and Calc offers a variety ofways 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, 2ndedition, 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 73: Example data for creating a chart
To demonstrate the process of using the Chart Wizard to create charts, the data shown in Figure
73 is used in the following sections. Here is an overview of the basic steps:10) 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 ofcells (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.
11) Do one of the following. This will cause a chart to be placed on the spreadsheet as an
object (Figure 74) and the Chart Wizard dialog will be opened (Figure 75).
– Go to Insert > Chart on the Menu bar.
– Click the Insert Chart icon on the Standard toolbar.
12) Choose the chart type and make any other selections desired. The options are explained
below.
13) Click Finish to save the selections and close the Chart Wizard.
The following sections provide further details about using the Chart Wizard.

102 | Chapter 3 Creating Charts and Graphs

60
50
40
CanoesBoats
Motors

30
20
10
0
Jan

Feb

Mar

Apr

May

Jun

Figure 74: 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 “Gallery of chart types” onpage 164.

Figure 75: Chart Wizard dialog – selecting chart typeThe initial chart created using the Chart Wizard is a 2D column chart. A small preview of theselected variant is highlighted with a surrounding border, as shown in Figure 75. The name of thevariant (Normal in Figure 75) 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.
3) 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.

Chart Wizard | 103

4) Click Next to make changes to data range, data series, and chart elements, explained ingreater detail below.
5) 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 76), manually correct
any mistakes in data selection for the chart.

Figure 76: 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 cellreferences 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 thecursor 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 73, 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 77).
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 toindicate 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 adelimiter between individual ranges. For example, the English (USA) locale uses a comma as adelimiter and “$Sheet1.A1:A5,$Sheet1.D1:D5” is a valid data range. A semi-colon is anothercommonly used delimiter.

104 | Chapter 3 Creating Charts and Graphs

The appropriate delimiter depends on the option selected in the Locale setting menu on theFormats section at Tools > Options > Language Settings > Languages. See or change thedefault 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. Clickthe 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 cursor by first clicking the Select data range button to the rightof the Data range box. Place the cursor 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 dragthe cursor 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 chartusing the data) to automatically update when the external data changes. The following types offiles can be linked: HTML, Calc, Base, CSV, Excel, and registered data sources. For further
information, refer to Chapter 10, Linking Data.

Selecting data series
The Data Series page of the Chart Wizard (Figure 77) 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 73. Use the Data Series page to change the source range of eachdata 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 firstthing 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 inrows or columns and whether the first row or first column should be consideredlabels.
The names of each data series appear in the Data series list box (the middle box in Figure 77).
To organize the data series, select an entry in the Data series list and do one or more of thefollowing:• 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.
Chart Wizard | 105

• To change the cell references for data series categories, edit the cell references in theCategories 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 thearrangement in the chart.

Note
Different data series must be in separate columns or rows. Otherwise Calc willassume 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 forthe chart data referred to in Figure 77 and the chart shown in Figure 74 are months of the year.
Most Calc charts require both value and category data, with values plotted along the Y axis andcategories plotted along the X axis. The exceptions are XY (scatter) charts and bubble charts,
which use value data along both axes.

Figure 77: Chart Wizard dialog - selecting data series
Data ranges that may be defined for a specific chart type appear in the Data ranges box on theright side of the Data Series page, shown in Figure 77. Not all data ranges may need to be filledin.

106 | Chapter 3 Creating Charts and Graphs

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 127.
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 73 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 77). 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 notalways 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
73, 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 charttypes, the Data Series page of the Chart Wizard includes a Data labels box insteadof 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 canthen be displayed on the chart by selecting the Show category option on the Data
Labels dialog (see Figures 107 and 108).
Depending on the type of chart, other data ranges may need to be defined in addition to thoseshown in Figure 77.

Chart Wizard | 107

Selecting chart elements

Figure 78: Chart Wizard dialog – selecting and changing chart elements
On the Chart Elements page of the Chart Wizard dialog (Figure 78), add or change the title,
subtitle, axes names, and grids. Use titles that draw the attention of viewers to the purpose of thechart and describe what they should focus on.
The chart elements for 2D and 3D charts are illustrated in Figure 79.
•

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.

Figure 79: Chart elements

108 | Chapter 3 Creating Charts and Graphs

To add elements to a chart, do one or more of the following on the Chart Elements page (Figure
78):•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 orvertical grid lines. For some charts, the axis grids are displayed by default. Grids are notavailable 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 141.

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 80) makes some basic options readily available for
specifying the appearance of charts. To open the Sidebar, first click outside the chart to deselectit, 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.
The contents of the Sidebar depend on whether the chart is selected or is in edit mode. The
Sidebar on the left in Figure 80 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 rightin Figure 80 appears.

Tip
If you follow the directions above and the Properties deck of the Sidebar does notappear, click the Properties icon on the upper right of the Sidebar.
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 rightclicking a chart element).

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

Using the Sidebar to change chart settings | 109

Figure 80: Properties deck of the Sidebar when chart is selected (left) and when chart is inedit mode (right)

110 | Chapter 3 Creating Charts and Graphs

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 finetuning 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 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 156 for more information.
Use edit modeUse 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 detailin 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 themonce. The cursor changes to a move icon (appearance depends on the system). Dragthe 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 81) or from the Format menu
(Figure 82) on the Menu bar.
– Click the element once, then click on the Format Selection icon on the Formatting
toolbar (Figure 83).
– Select the element from the Select Chart Element drop-down list, then click theFormat 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 othertext, such as categories, data labels, and legend entries, change the text in the data on
the spreadsheet.

•

Click once on a data point (such as a column or bar) to select and edit the associateddata series.
– With a data series selected, double-click a single data point to edit its properties (forexample, 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.

Modifying charts | 111

Note
The next several sections (until “Resizing, moving, and positioning charts” on page156) 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 81.

Figure 81: Insert menu
when chart is in editmode
TitlesProvides text boxes for entering chart title and subtitle as well as titles for X-, Y-, and Zaxes, including secondary axes. For more information, see “Titles, subtitles, and axis
names” on page 117.
LegendSpecifies if a legend should be included and if so, where. For more information, see“Legends” on page 118.
Axes
Provides options for showing or not showing axis labels. The Chart Wizard shows thelabels by default. For more information, see “Axes” on page 129.
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 141.
Data Labels
Provides options for text attributes, whether to show categories, and the position androtation of the labels. These labels appear on each data point. For more information, see“Data labels” on page 136.
Trend LineSpecifies 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 146.

112 | Chapter 3 Creating Charts and Graphs

Mean Value Lines
Displays mean value lines for selected or all data series. For more information, see “Meanvalue lines” on page 150.
X Error Bars and Y Error Bars
Specifies the error category to be used, parameters, and display options for positive andnegative indicators. For more information, see “Error bars” on page 152.
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,
Editing, and Formatting Data, for more information about inserting special characters.

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

Figure 82: 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 beentered on the Chart Elements page of the Chart Wizard or by going to Insert > Titles.
LegendFormats the appearance and position of the legend. The legend must first be turned on byusing the Chart Elements page of the Chart Wizard or by going to Insert > Legend.
Axis
Formats properties such as where the axes cross each other, the scale of units, andformatting 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.

Modifying charts | 113

Chart Wall, Chart Floor, or Chart Area
Formats borders, area, and transparency of these elements. Note that the chart floor isavailable only for 3D charts. See “Formatting chart backgrounds” on page 120 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 “Gallery of chart types” starting on page 164.
Data Ranges
Sets ranges for all data in the chart and for individual data series, as explained in“Selecting data range” on page 104 and “Selecting data series” on page 105.
3D View
Formats 3D charts and is only available for 3D charts. Note that only column, bar, pie, andarea charts can be displayed as 3D charts. See “3D charts” on page 143 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 isdefined in relationship to the chart. See “Position and Size dialog” on page 157 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 83. 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 isotherwise difficult to select elements using the cursor. 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.

114 | Chapter 3 Creating Charts and Graphs

1. Select Chart Element

7. Data Ranges

13. Vertical Grids

2. Format Selection

8. Data Table

14. X Axis

3. Chart Type9. 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

Figure 83: Formatting toolbar when chart is in edit mode

Selecting and moving chart elements
Selecting chart elements
After double-clicking on the chart to enter edit mode, select chart elements using one of thefollowing 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 leftof the Formatting toolbar, as shown in Figure 83.

When selected, the chart element will be highlighted with square selection handles.

Tip
When you hover the cursor 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.

Selecting and moving chart elements | 115

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 cursor changes to the move icon (appearance
depends on computer setup).
3) Drag the cursor 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 157.
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 166
for information.
To move axis labels, see “Positioning axis, labels, and interval marks” on page 132. To movedata labels, see “Adding and formatting data labels for a data series” on page 136.

Tip
For some chart elements (such as title, subtitle, axis name, and legend), press thearrow 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 theelement 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 besurrounded 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 76 on
page 104.
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 “Gallery of chart types” onpage 164.

116 | Chapter 3 Creating Charts and Graphs

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 besurrounded by a gray border.
2) Use one of these methods to open the Titles dialog (Figure 84):
– Go to Insert > Titles on the Menu bar.
– 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 theline to create an additional line that splits the text.

Figure 84: 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 besurrounded by a gray border.
2) Do one of the following to open the Titles dialog for formatting (Figure 85):
– Click Format > Title and select the desired type of title or the All Titles option.

Titles, subtitles, and axis names | 117

– Click on the element in the chart, right-click, and select Format Title (or appropriateelement) from the context menu.
– Click on the element in the chart or select it in the Select Chart Element drop-down liston 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.

Figure 85: Titles formatting dialog (after selecting All Titles option)

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

Figure 86: 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 agray 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.

118 | Chapter 3 Creating Charts and Graphs

– Right-click in the chart area and select Insert Legend or Delete Legend in thecontext 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 Namedata range, discussed in “Selecting data series” on page 105. Change a legend
name by changing the text in the spreadsheet.

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

Figure 87: Legend insertion dialog
3) Select or deselect the Display legend checkbox to either display or not display thelegend.
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 116.

Formatting legends
For advanced editing of a legend’s appearance, a more extensive Legend dialog (Figure 88) 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 agray border.
2) Do one of the following to open the Legend dialog (Figure 88):
– Click on the Legend icon on the Formatting toolbar.
– Select Format > Format Legend on the Menu bar.
Legends | 119

– 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.

Figure 88: 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 79 on page 108. 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 besurrounded by a gray border.
2) Do one of the following to open the appropriate dialog (such as Figure 89):
– Go to Format on the Menu bar and select Chart Area, Chart Wall, or Chart Floor.
– 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 withselecting these areas, see “Selecting chart elements” on page 115.)– 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, or Chart in the Select Chart Element drop-down liston the Formatting toolbar. Then click the adjacent Format Selection icon or selectFormat > 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.

120 | Chapter 3 Creating Charts and Graphs

4) Click OK to save the changes and close the dialog. If desired, click outside the chart toleave edit mode.
In the steps above, references to the chart floor are only applicable for 3D charts.

Figure 89: 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 anumber 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 theappearance 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.

Data range and series | 121

Replacing data by dragging
It is easy to manually replace one set of data with another set of data. Do this in the followingway: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 90.
3) Specify whether or not the first column or row contains labels, then click OK.

Figure 90: 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 besurrounded 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 76 on page 104.
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 77 on page 106.
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 achart, try this: Select only limited data for each data series to initially organize thechart. Adjust the settings until the chart looks as desired, then select all of the data.
For further information, see “Selecting data range” on page 104 and “Selecting data series” onpage 105.

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 91):
1) Select the chart by double-clicking on it to enter edit mode. The chart should now besurrounded by a gray border.
122 | Chapter 3 Creating Charts and Graphs

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 theFormatting toolbar.
3) Do one of the following to open the Data Series dialog:– 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 foreach 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 91: 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 ofchart.

Data range and series | 123

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 92. In this case,there are significantly more numbers of one data series (kayaks). To plot all three data series on
the same chart, 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.

Figure 92: 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 achart. This is described in “Add or remove axis labels” on page 129. It is also possible to show
different units or scales on the secondary axis (with or without aligning data to it), as describedunder “Defining scales” on page 131.

Spacing and plot options
The Options tab of the Data Series dialog (Figure 91) 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%.

124 | Chapter 3 Creating Charts and Graphs

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 thecolumn layers that belong together with lines.
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.
Two additional options (not shown in Figure 91) appear for pie or donut charts:
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 firstsection at 12 o’clock.

Area, transparency, and borders
For chart types other than line and scatter, the Data Series dialog (Figure 93) contains tabs forformatting the fill and borders of graphical representations such as columns and bars. The Areatab offers options for selecting color by clicking directly on a color in a palette, adding a custom
palette, or by specifying the RGB or Hex color codes. Other pages contain options for gradient,
bitmap, pattern, hatch, transparency, and borders. The options are self-explanatory or can bereadily 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.

Data range and series | 125

Figure 93: Data Series dialog – Area tab, Gradient pageLines, 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 94).
Specify style, color, width, and transparency of the line 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, Fromfile, 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 thedesired width and height of the symbol. Select Keep ratio if the ratio of width to height of thesymbol should be maintained.

126 | Chapter 3 Creating Charts and Graphs

Figure 94: 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 forany future chart.

Using Data Series dialog
As discussed in the previous section, the Data Series dialog has options for assigning colors forlines, 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 7, Using Formulas andFunctions) to specify colors with numbers based on combined RGB values. Then assign thenumbers to data ranges for border and fill colors in the Data Series page of the Chart Wizard(see “Selecting data series” on page 105) or in the Data Series tab of the Data Ranges dialog(see “Changing data ranges” on page 121).
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).

Data range and series | 127

Note
Data ranges for border color and fill can only be specified for column, bar, pie,
bubble, and column and line charts.
In addition to directly assigning colors, you can use conditional formatting to define criteria forwhen specific colors will be used. (Conditional formatting is described in Chapter 2, Entering,
Editing, and Formatting Data.)
Figure 95 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 tocolor 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 95: Using the COLOR function and a conditional formula to specify colors
The chart on the right in Figure 95 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 93 on page 126. 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 94 on page 127.
To format data points:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by agray border.
2) Click two times (but not too quickly) on the data point to be formatted. The data point willshow 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.

128 | Chapter 3 Creating Charts and Graphs

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

Figure 96: Tooltip showing information about adata point

Axes
Add or remove axis labels
Use the Axes dialog shown in Figure 97 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 117).
To use the Axes dialog:
1) Enter edit mode by double-clicking the chart. The chart should now be surrounded by agray 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 a 3D chart has been created.
4) Click OK to close the dialog. If desired, click outside the chart to leave edit mode.

Figure 97: 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 98. To specify different units or intervals for thesecondary axis, use the Scale tab of the more extensive Axis dialog described in the following
section.

Axes | 129

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 124.

Figure 98: Both secondary axes enabled

Edit and format axes
In addition to the simple dialog above, a more extensive Axis dialog contains options for gridintervals, 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 agray border.
2) Open a specific axis dialog (Figure 99) by doing one of the following (some options do notallow 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 selectFormat 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 selectFormat > 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 eachpage are explained below.
4) Click OK to save changes and close the dialog. If desired, click outside the chart to leave
edit mode.

130 | Chapter 3 Creating Charts and Graphs

Figure 99: 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 primaryaxes. This can be quite useful for showing Celsius and Fahrenheit scales on the same chart, forexample, or for when data are aligned to a secondary Y axis (see “Aligning data to secondary Yaxis” on page 124).
The contents of the Scale tab (Figure 99) 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 in Figure 100.
Logarithmic scale
Specifies that the axis is to be subdivided logarithmically. Logarithmic scaling makes thegrid lines of the axis equidistant from each other, but the values between the lines are notequal. Use this option when working with values that differ sharply from each other.

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

Axes | 131

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 forinterval marks (specified on the Positioning tab of the Axis dialog) and gridlines. Automaticmust be deselected to set this option manually.
Minor interval countDefines the number of intervals (not the values between intervals) that subdivide the majorintervals. The same as for major intervals, the interval count defined here will be used forinterval marks (specified on the Positioning tab of the Axis dialog) and gridlines. Automaticmust 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 andmaximum times on the Scale tab may solve the problem.

Positioning axis, labels, and interval marks
The Positioning tab (Figure 101) controls the position of axis labels and interval marks.

Figure 101: Axis formatting dialog – Positioning tab
Axis Line
Sets where the axis crosses the other axis, as shown in Figure 102. The options on thedrop-down list are Start, End, or Category. If Category is selected, a further drop-downmenu is displayed enabling selection of the value required.

132 | Chapter 3 Creating Charts and Graphs

Figure 102: 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 103.
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 sideof the axis. The interval marks in Figure 103 are on both sides.
– Place marks – specifies where to place the marks: At labels, At axis, or At axis andlabels. (The top two charts in Figure 103 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 thelabels.)Figure 103: 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 94 on page 127 but
excluding the Icon section.

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

Axes | 133

Figure 104: 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 (oddnumbers 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.

134 | Chapter 3 Creating Charts and Graphs

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 manuallyentering 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 > Language Settings > Languages > Default Languages
for Documents > Complex text layout is enabled.

Numbers
Use the Numbers tab (Figure 105) 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 areformatted on the spreadsheet. Deselect this option to change number formatting. For information
about formatting numbers, see Chapter 2, Entering, Editing, and Formatting Data, as well as theonline Help.

Figure 105: Axis formatting dialog – Numbers tab

Axes | 135

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 2, Entering,
Editing, and 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 2, Entering, Editing, and Formatting Data, formore information.

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 isshown in Figure 106. In this case, Calc automatically defines the data range for categories as thefirst two columns in the spreadsheet. This is reflected in the chart, which shows the hierarchicalrelationship between quarters and months.

Figure 106: Example of hierarchical axes labels

Data labels
Data labels display information next to data points on the chart. They can be quite useful forhighlighting specific data when presenting detailed information, but be careful not to create achart 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 besurrounded 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.

136 | Chapter 3 Creating Charts and Graphs

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 108), 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 107). The controls on this
dialog are similar to those on the Data Labels tab of the Data Labels dialog, which aredescribed below.
–

First right-click on the selected data series in the chart and select Insert Data Labelsin 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 107: 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.

Data labels | 137

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 108), whichcontains the following options:Show 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 2, Entering, Editing, and Formatting Data. DeselectSource format to activate options on the Format Number dialog.

Figure 108: Data Labels tab of the Data Labels dialog
Show value as percentage
Displays the percentage value of the data points in each data series. When selected, thisoption activates the Percentage format button. Note that the percentage referred to is a
138 | Chapter 3 Creating Charts and Graphs

data point’s Y value as a percent of total Y values for a specific X category or value. Thus,
in Figure 109, the February canoe value 9 is 10% of the total February value of 94 (the sumof 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 2, Entering, Editing, and Formatting
Data. Deselect Source format to activate options on the Number Format for Percentage
Value dialog.
Show category
Displays the category next to each data point. This option is activated for all data labels in
Figure 109. Thus, all data labels show the month. The text for data labels comes from thecategory data series and cannot be changed in the chart. It can only be changed in the
spreadsheet data.

Figure 109: Examples of data label optionsShow legend key
Displays the legend icon for the data series next to each data point. Figure 109 shows thelegend 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 109, the separator is Semicolon for the canoes data labels, Newline 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
109, 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 indegrees.
Text Direction
Specifies the text direction for a paragraph that uses complex text layout (CTL).

Data labels | 139

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 besurrounded 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 step3), do the following to open the Label for Data Series dialog (similar to Figure 108): right-click on
the data point and select Format Single Data Label from the context menu.
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, andthen 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 themethods 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 thechart 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 108):– 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 datalabels 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.

140 | Chapter 3 Creating Charts and Graphs

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 datalabels to be removed, then click OK.

Grids
Grid lines or grids divide the intervals along axes to help estimate data point values. Major andminor grid lines are shown in Figure 110. 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 isactivated by default.

Figure 110: Major and minor gridlines 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 besurrounded by a gray border.
2) Do one of the following:– Go to Insert > Grids on the Menu bar to open the Grids dialog (Figure 111).
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 111: Basic Grids dialog– Click the Horizontal Grids icon or the Vertical Grids icon, both located on theFormatting 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.
3)

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

Grids | 141

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 ofchart. Thus, for a bar chart, click the Horizontal Grids icon to control the verticalgrids.

Formatting grids
In addition to the Grids dialog shown in Figure 111, 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 besurrounded 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 112).

Figure 112: 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. Thisis described in “Defining scales” on page 131.

142 | Chapter 3 Creating Charts and Graphs

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 togive it a 3D look:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now besurrounded by a gray border.
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 viewTo make changes to a 3D chart, use the 3D View dialog (Figure 113).

Figure 113: 3D View dialog – Perspective tab
Use the 3D View dialog to change the 3D settings, including perspective, appearance, andillumination. 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 besurrounded 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.
3D charts | 143

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 113) 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 areshown as circles.
• 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 acamera lens (as opposed to using a parallel projection). Set the focal length with the spinbox 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 thefollowing way:
1) Select the chart by double-clicking on it to enter edit mode. The chart should now besurrounded by a gray border.
2) Click once on the chart wall to select it, causing round selection handles to appear. The
cursor changes to a rotation icon.
3) Press and hold the left mouse button while dragging in the desired direction. A dashedoutline 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 114) to modify some aspects of theappearance 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.

144 | Chapter 3 Creating Charts and Graphs•

Select Object borders to draw lines along the edges.

•

Select Rounded edges to smooth the edges of box shapes.

Figure 114: 3D View dialog – Appearance tab

Illumination
Use the Illumination tab (Figure 115) of the 3D View dialog to control light sources for the 3D
view.
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.

•

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.

•

Each light source always points at the middle of the object initially. Move the verticalslider 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 auniform intensity from all directions. Alternatively press the adjacent button to select acolor using the Pick a Color dialog.

See the Draw Guide for more information on setting the illumination.

3D charts | 145

Figure 115: 3D View dialog – Illumination tab

Trend and mean value lines
Trend lines help show the relationships among scattered data points of a data series. Calc has agood 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 chartlegend.

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 agray 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.

146 | Chapter 3 Creating Charts and Graphs

3) Do one of the following to open the Trend Lines dialog (Figure 116):– 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.

Regression types
By default, x is used for the abscissa variable and f(x) for the ordinate variable. Change thenames under X Variable Name and Y Variable Name on the Trend Line dialog.
Linear trend line
Regression through equation y = a ∙ x+b. Intercept b can be forced.
Polynomial trend line
Regression through equation y = Σi (ai ∙ xi). Intercept a0 can be forced. Degree ofpolynomial must be given (at least 2).
Logarithmic trend line
Regression through equation y = a ∙ ln(x) + b. Only positive x values are used.
Exponential trend line
Regression through equation y = b ∙ exp(a ∙ x).This equation is equivalent to y = b ∙ mx, withm = exp(a). Intercept b can be forced. Only positive y values are considered, except if all yvalues are negative. In that case, the equation used is y = -b∙exp(a ∙ x).
Power trend line
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.
Moving Average trend line
Simple moving average for n previous y-values, with n being the period. No equation isavailable for this trend line.
Search for the term “Trend Lines” in the index of the Help system for more information about
these regression types.

Trend and mean value lines | 147

Trend line options

Figure 116: Trend Line dialog – Type tab
Trendline Name
Specifies the name to be used for labeling the equation in the legend; see Figure 117.
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 117.
Show Coefficient of Determination (R2)
Displays the coefficient of determination in the chart. Shown with the polynomial equation in
Figure 117.
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.

148 | Chapter 3 Creating Charts and Graphs

Figure 117: Trend lines showing various equations
Select a trend line to display information about it in the Status bar, as shown in Figure 118. The
Status bar is normally located at the bottom of the spreadsheet.

Figure 118: 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. Tochange the style, color, width, or transparency of a trend line, use the Line tab of the Trend Linedialog (Figure 119). The options are easily understood or researched.

Figure 119: Trend Line dialog – Line tab

Trend and mean value lines | 149

Formatting trend line equations
Display the equation in the chart by selecting Show Equation on the Type tab of the Trend Linedialog (Figure 116). Options for the trend line equation include formatting the border around theequation, 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 besurrounded 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 theFormat 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 theFormatting 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 105 on page 135.
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 besurrounded 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.

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

Figure 120: Mean value lines
150 | Chapter 3 Creating Charts and Graphs

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 besurrounded 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 besurrounded 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 agray 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 119):– 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 theSelect 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 besurrounded 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 theSelect Chart Element drop-down list on the Formatting toolbar and then press theDelete 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.

Trend and mean value lines | 151

Error bars

Figure 121: Error bars showing variance (Canoes), standard
deviation (Boats), and standard error (Motors)
Error bars, shown in Figure 121, can be useful for presenting data that has a known possibility oferror, such as social surveys using a particular sampling method, or for showing the measuring
accuracy of the tool used. They 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 besurrounded 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 122). The Line tab is not present if you are inserting error bars for alldata series; in this circumstance, an extra None option appears in the Error Categoryarea.
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.

152 | Chapter 3 Creating Charts and Graphs

Figure 122: 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 besurrounded 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 122):– 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 Barsin 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.
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.

Error bars | 153

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 (Figure122). 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 besurrounded 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 dropdown 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 besurrounded 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 122). When no data series has been selected, the dialog also
includes the option None under Error Category.
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.
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.

154 | Chapter 3 Creating Charts and Graphs

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 anddrawing shapes, see Chapter 5, Using Graphics, as well as the Draw Guide.
The Drawing toolbar (Figure 123) 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 inedit mode. Otherwise, an object will not be connected to the chart and will not be
moved with it.

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 andBanners

5. Insert Ellipse

10. Symbol Shapes

Figure 123: Drawing toolbar when chart is placed in edit mode
Most of these options are self-evident or can be readily researched, especially by referring to theDraw Guide. Clicking on the icon for an option changes the cursor’s appearance, depending on
the option. Click and drag the cursor to create the desired drawing object in the chart. Informationthat 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 Shiftwhile 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.

Adding drawing objects to charts | 155

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
123, Callouts option 8 creates a default callout while option 13 opens a tool palette ofcallout styles.
Clicking the down arrows next to the six options on the right in Figure 123 opens tool palettes
similar to those shown in Figure 124.
Basic Shapes

Symbol Shapes

Block Arrows

Flowcharts

Callouts

Stars and Banners

Figure 124: Tool palettes that can be opened from the Drawing toolbar

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 Sizedialog 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 ofthe chart.
2) Click and drag one of the selection handles. The cursor indicates the direction to increaseor decrease the chart size. Clicking and dragging a corner handle preserves thehorizontal to vertical size ratio.
3) When finished, click outside the chart to leave selection mode.

156 | Chapter 3 Creating Charts and Graphs

MovingMove 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 ofthe 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 ofthe chart.
2) Hover the cursor anywhere over the chart until it changes to a move cursor (shapedepends 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 andposition 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 125).
2) Select the desired options on the Position and Size, Rotation, and Slant & Corner Radiustabs 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.
Click one of the points in the Base point graphic corresponding to the location to use foranchoring 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 theappropriate 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.

Resizing, moving, and positioning charts | 157

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

Position and Size
The options available on the Position and Size tab (Figure 125) are as follows:
Position
Determines the location of the chart on the page. The position of a chart is coordinatedrelative 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 temporarilychanged.
– 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 selectedbase 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.

158 | Chapter 3 Creating Charts and Graphs

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.
Adapt
Specifies if the size should be adjusted to fit the size of entered text. Availability of these
options depends on the context.
– Fit width to text – expands the width of the object to the width of the text, if the object
is smaller than the text.
– Fit height to text – expands the height of the object to the height of the text, if theobject is smaller than the text.

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

Figure 126: Position and size dialog – Rotation tab
Pivot Point
The chart can be rotated around a pivot point. The default pivot point is at the center of thechart. Note that if there is not enough room to rotate the chart, it could be rotated off of thepage.
– Position X – specifies the horizontal distance from the left edge of the page to thepivot 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. The pivot point can be
temporarily changed. But when the dialog is opened again, the pivot point will be thedefault location at the center of the chart and the X and Y positions will reflect thedefault location.
Resizing, moving, and positioning charts | 159

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 byclicking and dragging the indicator. The number of degrees rotated is shown in theAngle box.

Slant & Corner Radius
The options for the Slant & Corner Radius tab (Figure 127) are as follows:
Corner RadiusThis option is not available for charts.
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 127: Position and Size dialog – Slant and Corner Radiustab

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 treatedas 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 outerborders, or anchor the charts to the same cell or page.
160 | Chapter 3 Creating Charts and Graphs

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 128) usually appears below the Standard toolbar (but thelocation 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
Graphics, and the Draw Guide for further information. Following are a few tips for using thesetools with charts.
AnchorConnects 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 orsmaller.
Align
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 (orother objects) are selected.
Bring to Front/Forward One/Back One/Send to Back
Stacks charts or other objects in front of or behind other objects.

1. Anchor

7. To Foreground

13. Fill Color

2. Align

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

Figure 128: Drawing Object Properties toolbar that appears when chart is selected
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 theSelect tool (arrow icon) on the Drawing toolbar (Figure 123) 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 123 and 124.
RotateRotates 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

Changing overall appearance of charts | 161

to change the base point. Move the handles midway between the corners to slant the chartor other object.
PointsChanges the shape of curved objects. Move the points to shape curves created with theCurve 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 areGroup, Enter Group, Exit Group, and Ungroup.

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 thechart.
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 iconin 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 adata range. Figure 129 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 10, 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 129.
3) Modify the data as desired. In addition to changing numbers in the data, use options toinsert, move, or delete columns and rows.
4) Click OK to close the dialog.
5) If desired, click outside the chart to leave edit mode.

162 | Chapter 3 Creating Charts and Graphs

Figure 129: Data Table dialog when a chart is copied into anotherdocument

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 122.

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 andpaste 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 newchart 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, andselect 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 thechart. Then press Delete.

Copying, exporting, and deleting charts | 163

Gallery of chart types
While data can be presented using a variety of charts, focus on the message of the chart todetermine 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 130.

Figure 130: Chart Type dialog – Column
When a preview is clicked, its borders are highlighted and the name appears below. The 2D
variants are:NormalShows all data values belonging to a category next to each other. The main focus is on theindividual absolute values, compared to every other value.
StackedShows 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.

164 | Chapter 3 Creating Charts and Graphs

Additional options for creating column charts are:
3D Look
When this box is checked, two options become available in the drop-down list:– 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 acolumn 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 — forexample, 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 numberof categories.
In the examples in Figure 131 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 eachmean 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 thelegend. 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 under “Rotation and perspective” on page 144).
• 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 131: Bar chart examples

Gallery of chart types | 165

Pie charts
A pie chart shows values as circular sections of a circle. The area of each section is proportional
to its value.
Pie charts are excellent for comparing proportions — comparisons of departmental spending, forexample. 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 132: Chart Type dialog - Pie
Pie variant options, shown in Figure 132, are:NormalShows 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 holeinside, 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 DonutShows the outer sections already separated from the remaining donut. Click and drag anouter section to move it along radial lines from the center.
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 somuch that the message is lost, and be careful that tilting does not distort the relative sizes of thesegments.
166 | Chapter 3 Creating Charts and Graphs

You can choose in the Chart Wizard to use the exploded pie variant, but this option explodes allof the pieces (contrary to the preview graphic in Figure 132). If the aim is to accentuate just one
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 133: Pie chart examples
The effects achieved in Figure 133 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 theedge of the section (the section will have highlight squares to mark it), and drag it out fromthe rest of the sections. The sections will decrease in size. If needed, highlight the chartwall 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 133 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 134, 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 134: Donut chart examples

Gallery of chart types | 167

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 135: Chart Type dialog - 2D and 3D Area
Area chart variants, shown in Figure 135 are:NormalWhen 3D Look is deselected, plots all data as absolute Y values. It first plots the area ofthe 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.
StackedStacks cumulative values on top of each other. This ensures that all values are visible, andno data set is hidden by others. However, the Y values no longer represent absolutevalues, 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 thecategory total.

Figure 136: Area chart examples

Normal area charts
Area charts are sometimes tricky to create. Using transparency values may be helpful. To create
the charts in Figure 136, 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.

168 | Chapter 3 Creating Charts and Graphs

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 137). In the first example, each point in a data series is added to theother 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 137: 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 timeseries 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.
As shown in Figure 138, 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.

Gallery of chart types | 169

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 138: 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.
SmoothConnects the points with curves instead of lines. When this option is selected, click
Properties to open the Smooth Lines dialog (Figure 139) and further specify the curves.
For smooth lines, there are two line type options: Cubic spline or B-spline. These aremathematical 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.

Figure 139: Smooth Lines dialog

170 | Chapter 3 Creating Charts and Graphs

Stepped
Connects points with horizontal and vertical lines only. Click Properties to further specify
the formatting of the lines (Figure 140). The options are self-explanatory.

Figure 140: 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
141 shows some examples of line charts.

Figure 141: Line chart examples

Scatter or XY charts
In contrast to line, column, and bar charts, which contain numeric values on the Y axis andcategories 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.

Tip
When plotting time on the X axis, make sure that it is not text and is written in thecorrect format for your locale. For example, instead of January, use a format such as
1/1/2022. Check locale formats at Tools > Options> Language Settings >Languages > 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.

Gallery of chart types | 171

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

XY chart variants

Figure 142: Chart Type dialog – XY (Scatter)As shown in Figure 142, when the XY (Scatter) chart type is selected, the following variants areavailable:
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 “Lines, areas, and data point icons”
on page 126.
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 byicons. By default, the drawing order is the same as the order in the data series, but note theoption to sort by X values.
3D Lines
Makes the lines look like tapes. The data points are not shown by icons. In the finishedchart, use the 3D View dialog to set properties like illumination and angle of view.
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.

172 | Chapter 3 Creating Charts and Graphs

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 andcurvature.
– Resolution determines how many line segments are calculated to draw a piece ofpolynomial between two data points. A value in the range 1 to 100. Click any data
point to see the intermediate points.
– B-spline uses parametric, interpolating B-spline curves. The curves are built frompolynomials. Degree of polynomials sets the degree of these polynomials. A value inthe 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 ordata 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 “Lines, areas, and data point icons” on page 126 for further
information.

•

Error bars – For 2D charts, select Insert > Y Error Bars or X Error Bars to enable thedisplay of error bars. See “Error bars” on page 152 for further information.

•

Mean Value Lines and Trend Lines – Enable the display of mean value lines and trendlines with commands on the Insert menu. See “Trend and mean value lines” on page146 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 thefirst row of data.
Scatter charts may surprise those unfamiliar with how they work. This can be seen in examples
using the following data (Figure 143), which is organized with data series in rows.

Gallery of chart types | 173

Figure 143: XY (Scatter) chart examples
The data range for the chart on the left in Figure 143 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 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 theother 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.

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 144 shows how the data ranges can be set for a bubble chart.

Figure 144: Data series entries for a bubble chart
The chart in Figure 145 is based on the data in Figure 144. To format the chart, the data series
are 50% transparent with a radial gradient. The data labels are formatted to be numbers in thecenter of the data points (bubbles).
174 | Chapter 3 Creating Charts and Graphs

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 foraxis labels.

Figure 145: Bubble chart example

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

Figure 146: 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 andreal results, so that differences can be compared.
Figure 147 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 thedata. 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.
Gallery of chart types | 175

Figure 147: Chart Type dialog - Net
Figure 148 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 aretaken from the Gallery and have a 3D look.

Figure 148: 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 149. It specifies which columns should be the opening, low, high, and closing prices of thestock as well as the transaction volume. However, manual adjustments may still be needed whendefining the data series.

Figure 149: Example data arrangement for stock charts

176 | Chapter 3 Creating Charts and Graphs

A stock chart organizes data series in two basic ways. The first way is not used in other charttypes. In this case, the open, low, high, and closing values of a row create one data unit in thechart 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 thefamiliar way used in other chart types.
Figure 149 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 150. Note that some ofthem do not use all of the data columns.

Figure 150: Chart Type dialog - Stock
The data table in Figure 149 is used to illustrate the variants, which are as follows.

Gallery of chart types | 177

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 151), it shows an additional horizontal mark for the closing
price.

Figure 151: Stock chart variant 1 showing low, high, and closing prices
Stock Chart 2
Based on the open, low, high, and close columns, this variant generates the traditional
candlestick chart (Figure 152). 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 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.

Figure 152: Stock chart variant 2 showing low and high prices as well as therange between opening and closing prices

178 | Chapter 3 Creating Charts and Graphs

Stock Chart 3
Using the low, high, and close columns, draws a chart similar to Stock Chart 1 but withadditional columns for transaction volume. As shown in Figure 153, a secondary Y axis
enables both transaction volume and price to be shown on vertical axes.

Figure 153: Stock chart variant 3 showing low, high, and closing prices as wellas transaction volumes

Note
Variants 3 and 4 automatically align data to the secondary Y axis. For more
information about a secondary Y axis, see “Aligning data to secondary Y axis” onpage 124.
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 154).

Figure 154: Stock chart variant 4 showing opening, low, high, and closing prices aswell as transaction volumes.

Gallery of chart types | 179

Column and line charts
A column and line chart is useful for displaying two or more distinct but related data series, suchas 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 155, the columns are drawn side by side to easily compare their values.

Figure 155: 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 sumof the data values.
The charts in Figures 155 and 156 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 aline, right-clicking, selecting Format Data Series, and formatting the line color and size on theLine 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“Aligning data to secondary Y axis” on page 124.

Figure 156: Column and line chart with stacked columns

180 | Chapter 3 Creating Charts and Graphs

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 theStandard toolbar, after left-clicking a cell inside a pivot table. Pivot charts inherit many propertiesof the other chart types described in this chapter but also have other characteristics that aredescribed in Chapter 8, Using Pivot Tables.

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 ispossible 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 thestacks 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 to use thefunction QUARTILE.INC (range, parameter) (Figure 157).
The MIN (range), MEDIAN (range), and MAX (range) functions can be used to calculate theminimum, median, and maximum, respectively.

1 Minimum of the data series
2 The first quartile of the data series
3 Bottom of the box to be formed
4 The median of the data series
5 The third quartile of the data series is also the top of the shapes box
6 The maximum of the data series

Figure 157: Stacked column chart in rows of minimum, 1st quartile,
median, 3rd quartile, maximum with no legend and box plot withwhiskers constructed from that column chart

Create box plots with whiskers in Calc | 181

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 in the context
menu.
2) While in edit mode, Right-click on the chart and Select Insert Y Error Bars from thecontext 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 choose Negative. In
the now opened Negative (-) box insert the difference between the 1st quartile and theminimum.
5) Remove or apply the colour white to the top stack with Format Data in the context menu.
6) Set the configuration of the top whisker by performing steps similar to the describedabove.
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 thecontext menu. On the Borders tab of the dialog, the Style should be set to Continuous and thethickness 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.

182 | Chapter 3 Creating Charts and Graphs

Calc Guide

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 and pages without paying any attention to styles
and are accustomed to formatting documents according to physical attributes. For example, forthe 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 astyle, which has been defined to include the attributes and characteristics you want, will save youtime and give greater consistency in formatting.
Styles also make major formatting changes easy. For example, you may decide to change theappearance 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 theproperties of that style.
In addition, Calc also provides 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 text, and then do one of the following:•

Right-click and choose Clear Direct Formatting in the context menu.

•

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
While some components of LibreOffice offer many style types, Calc offers only two: cell 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 inthe 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 newcell style, it will be shown in the Sidebar. To add it to the Styles menu, see Chapter 14, Setting
up and Customizing, for instructions.
Initially, the basic styles are configured so that if you change the characteristics of the Default
Cell Style cell style, then all of the other styles, inheriting from it, will change to match.
184 | Chapter 4 Using Styles and Templates

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 Page Style and Report. Page styles allow you to
set page size and orientation, page margins, headers and footers, borders and backgrounds, andthe 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 in the
Sidebar, Fill Format mode, the Apply Style list on the Formatting toolbar, and keyboard shortcuts.

Styles menu
By default, the Styles menu (Figure 158) 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.

Figure 158: The Styles
menu

Styles deck in Sidebar
The Styles deck in 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 theright of the Sidebar.

Applying cell styles | 185

2) Click the Cell Styles icon on top of the Styles deck to open the list of cell styles. Figure
159 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 thatstyle are applied to the data contained in the highlighted cells.

Figure 159: 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 in the Sidebar (Figure 159).
2) Select the style you want to apply.
3) Click the Fill Format Mode icon in the top right of the Styles deck. The cursor 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 themode.

186 | Chapter 4 Using Styles and TemplatesCaution
When Fill Format mode is active, a right-click anywhere in the document cancels thelast 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 in the Formatting toolbar and select Visible Buttons in thecontext menu (Figure 160).
2) Click Apply Style. The context menu closes and the Apply Style list appears at the left
end of the Formatting toolbar.

Figure 160: 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 161).
3) Select the required style. The formatting attributes of that style are applied to the selected
cells.

Figure 161: 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 or page styles, including any
custom styles that you have created. See Chapter 14, Setting up and Customizing, for more
information.

Applying cell styles | 187

Applying page styles
The page style applied to a sheet within a spreadsheet is indicated on the Status Bar, as shownin Figure 162.

Figure 162: 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 159).
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 inuse. To save new styles in a template, see “Creating a template” on page 202 formore information.
1) Go to the Styles deck on the Sidebar (Figure 159).
2) To create a new cell style, click the Cell Styles icon, or to create a new page style, click
the Page Styles icon.
3) Right-click in the Styles deck and select New in the context menu to open either the Cell
Style dialog or the Page Style dialog.
4) Use the various tabbed pages on the dialogs to set the attributes for the new style. See“Cell style attributes” below and “Page style attributes” on page 197 for more information.
5) 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 andanother style called Red. Make sure all style names are sufficiently different toprevent any confusion.

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

Organizer tab•

Name – displays the name of the selected style. If you are creating or modifying acustom style, enter a name for the style. You cannot change the name of a predefinedstyle.

•

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 affect188 | Chapter 4 Using Styles and Templates

the new style. For example, you could make the styles identical except for the font color;
if you later change the font family of the parent style, the new style’s family will alsochange.
•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 apredefined 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 163: 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 youroperating 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 systemdefault language. The language setting ensures that date and currency formats arepreserved 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 thedecimal 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.

Creating new styles | 189

•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.

•

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 164: Cell Style dialog – Numbers tab

Font tabDepending 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, orKorean character sets), and Complex text layout font (right-to-left text direction). Figure 165
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 > Language
Settings > Languages page. The layout of the Font and Font Effects tabs are modified if eitherof 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 canalso 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).
190 | Chapter 4 Using Styles and Templates•

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 andHorizontal Kerning. Click this button to access the Font Features dialog (not shown) to
select those features.

•

Preview – displays a preview of the current selection.

Figure 165: Cell Style dialog – Font tab

Font Effects tab•

Font color – sets the color for the text. If you select Automatic, the text color is set toblack 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 towords 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.

•

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.
Creating new styles | 191

If you apply underlining to a superscript text, the underlining is raised to the level of thesuperscript. 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 Overlining 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 thecharacters appear as if they are raised above the page. The Engraved relief makes thecharacters 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 theselected text.

•

Position – specify where to display the emphasis marks.

•

Preview – displays a preview of the current selection.

Figure 166: Cell Style dialog – Font Effects tab

192 | Chapter 4 Using Styles and Templates

Alignment tab

Figure 167: Cell Style dialog – Alignment tab•

Text Alignment – sets the alignment options for the contents of the current cell, or theselected 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.

– Indent – indents from the left edge of the cell by the amount that you enter.
– 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.

Creating new styles | 193

–•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 lastline 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 selectedcell(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:•–

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 celledge 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 numberof 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 thecell 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

Figure 168: Cell Style dialog - 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 thecorresponding tab of the Format Cell dialog in Chapter 2, Entering, Editing, and Formatting Data.
194 | Chapter 4 Using Styles and Templates

Borders tab
Sets the border attributes for the selected cells.
•

Line Arrangement – select a preset border style or define your own combination byclicking in the diagram.

•Line – select the line style, width, and color that you want to apply. The style is applied tothe borders selected in the preview.

•

Padding – specify the amount of space that you want to leave between the border andthe 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 newvalue.

•

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, andits color.

Figure 169: Cell Style dialog – Borders tab

Creating new styles | 195

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

Figure 170: Cell Style dialog – Background tab

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.

196 | Chapter 4 Using Styles and TemplatesFigure 171: 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).

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

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 acustom style, you can enter or change the name of the style. You cannot change thename 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 apredefined 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 thedimensions 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.
Creating new styles | 197

– 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 > Language Settings > Languages.
– 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 firstpage 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 thepaper and the spreadsheet.
– Top – enter the space between the upper edge of the paper and the spreadsheet.
– Bottom – enter the space between the lower edge of the paper and the spreadsheet.

•

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 areshown as blank pages.

–

Only left – the current page style shows only even (left) pages. Odd pages areshown as blank pages.

– Page numbers – select the page numbering format to use for the page style. Typicallythis 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 willchange according to the selected in this option)..

198 | Chapter 4 Using Styles and TemplatesFigure 172: Page Style dialog – Page tab

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 6,
Printing, Exporting, Emailing, and Signing for details.

Sheet tabSpecifies 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 6, Printing,Exporting, E-mailing, and Signing for details.

Managing styles
Modifying styles
1) Go to the Styles deck on the Sidebar and click the icon for the type of style you want tomodify.
2) Right-click on the name of the style and select Modify in the context menu to open either
the Cell Style dialog (Figure 163) or the Page Style dialog (Figure 172).
Managing styles | 199

3) Make the necessary changes to the style attributes. For more information on styleattributes, see “Cell style attributes” on page 188 and “Page style attributes” on page 197.
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 thecell 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 in the Sidebar (Figure 159) 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 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 theDefault Page Style.
1) Go to the Styles deck in the Sidebar (Figure 159) and click the icon for the type of style
you want to delete.
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 usedin 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 thenmoved 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 from thelist.
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.
200 | Chapter 4 Using Styles and Templates– 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 thepage. This means that any new spreadsheets (invoices) created from this template will have thecompany logo and address on the first page of the spreadsheet.
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; andtoolbar 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,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” on page 202) or install templates
obtained from other sources (see “Adding templates obtained from other sources” on page 205).
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 173) opens.
2) In the Filter lists at the top of the Templates dialog, select Spreadsheets and thecategory of template you want to use. All the templates in that category are then listed on
the page, as shown in Figure 173.
3) Select the required template and click Open, or double-click the required template, orright-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.

Using a template to create a spreadsheet | 201

Figure 173: Templates dialog, showing a selected template

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 isvisible 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. The button also offers a drop-down list to select the templates ofa given type of document. If you select the Calc Templates 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 eachtime 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 thetemplate.
3) Create or modify the cell 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 arrowat the right of the Save button on the Standard toolbar and select Save as Template, orpress Shift+F11. The Save As Template dialog (Figure 174) 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 canalso choose to make this the default template (see “Setting the default template” on page
206 for more information).
202 | Chapter 4 Using Styles and Templates6) Click Save to save the new template.

Figure 174: Save As Template dialog

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, inthis case) when you return to the Templates dialog. It is unnecessary to save or doanything further with the spreadsheet file you have been using to create the newtemplate. It can be safely closed without saving.

Note
You can also save a template through the Save As dialog, accessed by a variety ofinteractions including selecting File > Save As on the Menu bar or pressing
Ctrl+Shift+S. Select the ODF Spreadsheet Template option in the Save as typemenu.

Editing a template
You can edit a template’s styles and content. If you wish, you can then apply the new styles tospreadsheets 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.
2) Navigate to the spreadsheet template that you want to edit. Right-click to open thecontext menu and choose Edit (Figure 175). The template opens in Calc.
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 equivalentaction.

Editing a template | 203

Figure 175: Templates dialog – Editing templates

Updating styles from a changed template
If you make any changes to a template and its styles, the next time you open a spreadsheet thatwas 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.

CautionIf you select Keep Old Styles, the confirmation message will not appear again thenext time you open the spreadsheet using the same changed template. Although thetemplate is still listed under File > Properties > General, the spreadsheet is nolonger 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, youneed to use one of the procedures described in “Changing the template assigned toa 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 on page 201. 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) from the Menu bar.
The Template Changer extension works with Writer, Calc, Draw, and Impress.

204 | Chapter 4 Using Styles and Templates

Adding templates obtained from other sources
LibreOffice refers to sources of templates as repositories. A repository can be local (a directoryon 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 inyour browser’s address bar. This opens the Extensions web page (Figure 176). In the Searchsection, 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.

Figure 176: Searching for templates in the repository
You can also use the Extensions button in the lower left of the Templates dialog, as shown in
Figure 177, to open an Extensions: Templates dialog, where you can scroll through a list ofextensions. In this version of LibreOffice, there is no easy way to filter this list, so you may preferto go directly to the web page, as described above.

Figure 177: 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 icon near the bottom right.
3) In the pop-up dialog, select the category where you want to store the template. (You canchange this later, as described in “Moving a template” on page 208.)
4) A file browser opens. Navigate to the location of the downloaded template on yourcomputer.
5) Select the template and click Open. After import, the template becomes available in the
Templates dialog.
Adding templates obtained from other sources | 205

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 14, Setting up and Customizing, for more about the Extension Manager.

Tip
Some extensions are packaged as .ZIP files.

Setting the default template
If you create a new spreadsheet using File > New > Spreadsheet on the Menu bar or anequivalent 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 175). 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 theStandard 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 Settings icon on the bottom left (Figure 179).
206 | Chapter 4 Using Styles and Templates

2) Point to Reset Default Template in the drop-down menu, and click Spreadsheet. 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 describedin the previous section.

Figure 178: 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 timethat you create a new spreadsheet, it will be created using the Calc default template.

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 newtemplate folders and use them to organize your templates and import templates into thesefolders. 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 ofyour computer. If you want to know where the template folders are located, go toTools > 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 Settings button in the lower left of the Templates dialog.
2) Click New Category in the context menu (Figure 180).
3) 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.

Organizing templates | 207

Figure 179: 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 Settings button on the Templates dialog and select Delete Category in thecontext menu (Figure 179).
2) Select the category to be deleted in the Delete Category dialog (not shown) and click OK.
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) Click the Move icon near the bottom of the dialog, select the destination category fromthe popup dialog (Figure 180), and click OK. The selected template is moved to thefolder. You can also create a new category into which to move the template.

Figure 180: Moving a template to another category
208 | Chapter 4 Using Styles and Templates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 175).
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 fromthat template. The spreadsheet will retain the style definitions that it inherited fromthe 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.

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) Select the template and click the Export icon.
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.

Organizing templates | 209

Calc Guide

Chapter 5
Using Images and Graphics

Introduction
Calc is used to present and analyze data and to make forecasts and predictions. Graphics canturn 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 moredetailed 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 ofgraphics added to a spreadsheet. They may be downloaded from the Internet, scanned, createdwith 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 oneof the following methods.

Drag and drop1) 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 ofembedding it, hold down the Ctrl+Shift keys while dragging the image. See “Linking or embedding
an image file” on page 212 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 181), 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” on page 219 for more information about these options.
6) Click Open. The image is inserted into the spreadsheet.

Adding graphics (images) to a spreadsheet | 211

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 181: 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; theoriginal 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 isdisplayed in the document, but when the document is saved, it contains only a reference to theimage file, not the image itself. The document and the image remain as two separate files, andthey 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
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.

212 | Chapter 5 Using Images and Graphics

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 182), which shows all the linked files.

Figure 182: 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 thenbecomes embedded into the spreadsheet.

Note
Going from embedded to linked images is not so easy. You must replace them one ata 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 varyfrom 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, orright-click and select Paste in the context menu, or press Ctrl+V.

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

Adding graphics (images) to a spreadsheet | 213

Inserting an image using a scanner
If a scanner is connected to your computer, Calc can call the scanning application and insert thescanned 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 thecorrect size. You may get better results by passing scanned material into a graphics program andcleaning it up there, before inserting the resulting image into Calc.

Inserting an image from the Gallery
The Gallery (Figure 183) 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 ofLibreOffice. You can add your own images as well as using the ones supplied with LibreOffice.
For more information, see the Getting Started Guide Chapter 11, Images and Graphics.

Figure 183: 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.

214 | Chapter 5 Using Images and Graphics

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

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 mostrequirements. However, for professional results it is generally better to use Draw or othersoftware 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 184) 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 184: 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” on page 219.

•

Align Objects – if two or more images are selected, you can adjust the horizontal andvertical alignment of the images in relation to each other. See “Aligning images” on page219.

•

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” on page 218.

•

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 thetransparency 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.
Modifying images | 215

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

Figure 185:
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 on the Properties deck include the Color, Line,
Transparency, and Position and Size settings.

Adding text
You can add text to an image or drawing object. That text will move with the image when theimage is repositioned. 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 186: Text Formatting toolbar for images
2) Type your text and use the tools on the Text Formatting toolbar to format it. Most of thetools 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 187).
4) Make any necessary changes and click OK to close the dialog.

216 | Chapter 5 Using Images and Graphics

Figure 187: 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 newposition. 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 cursor over one of the selection handles. The cursor changes shape, giving agraphical 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 righthandles 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 toFormat > Object > Position and Size on the Menu bar, or right-click on the image and selectPosition and Size in the context menu.
On the Position and Size tab (Figure 188) of the Position and Size dialog, you can set thesevalues:•Position – the location of the selected image on the spreadsheet.

Positioning, resizing, and arranging images | 217

– 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.
•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.

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

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.

218 | Chapter 5 Using Images and Graphics

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 thestacking order.

•

Back One – moves the selected image down one level, so that it is closer to the bottomof the stacking order.

•

Send to Back – moves the selected image to the bottom of the stacking order, so that itis 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 thepage where it is placed.

•

To Cell – anchor an image to a cell to ensure that the image always stays with thecontent it is originally anchored to. If an image is anchored to cell B10, and a new row isinserted above row 10, the image will then be anchored to cell B11.

•

To Cell (resize with cell) – similar to To Cell but with the additional property that theimage 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.

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 on the Menu bar, or click the down arrow at the right of the Alignicon on the Image toolbar, or right-click on one of the images and select Align in thecontext menu.
3) Select one of the options available for alignment.

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

Positioning, resizing, and arranging images | 219

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.
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.
2) Go to Format > Group > Enter Group on the Menu bar, or right-click on one of theselected 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 theselected 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 otherillustrations 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 189. Hoverthe 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 in the context menu.
Figure 189: Drawing toolbar
To use a drawing tool:
1) Click on the tool in the Drawing toolbar (Figure 189). The mouse pointer changes to a
drawing-functions pointer and the normal Formatting toolbar changes to the Drawing
Object Properties toolbar (Figure 191).
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.

220 | Chapter 5 Using Images and Graphics

The selected drawing function remains active, so that you can draw another object of thesame 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 191), theProperties 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.
You can set some default properties for a drawing object before you draw an object. Thesedefault 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 189).
2) On the Drawing Object Properties toolbar (Figure 190), 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 190: Drawing Object Properties toolbar – some controls are available
for setting default properties
3) After you draw an object or group it with another object, more properties become active.
These appear on the toolbar (Figure 191) and some are shown in the Properties deck of
the Sidebar (Figure 192).
Figure 191: 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 190), the Properties
deck on the Sidebar, or the context menu when you right-click on the drawing object.

Using LibreOffice’s drawing tools | 221

Figure 192: 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 whiledragging the handle. For more information, see “Positioning, resizing, and arranging images” onpage 217.

222 | Chapter 5 Using Images and Graphics

Grouping and ungrouping drawing objects
For grouping, ungrouping, and editing grouped drawing objects, see “Grouping and ungrouping
images” on page 220.

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 isused 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 tofind in the Navigator. Also, assigning names to images helps identify them when teams ofpeople 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 12, Macros.
Edit Hyperlink
You can define a hyperlink from an image to another location in your spreadsheet, anotherdocument, or a web page. Select Edit Hyperlink in the context menu to open the Hyperlink
dialog. See Chapter 10, Linking Data, for more information on hyperlinks.
Compress
You can compress images to reduce the file size of the spreadsheet. Select Compress inthe 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 yourcomputer 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 193) or the Drawing
toolbar (View > Toolbars > Drawing), click the Insert Fontwork Text icon.
Figure 193: Fontwork toolbar

Using Fontwork | 223

2) In the Fontwork Gallery (Figure 194), select a Fontwork style, then click OK. The
Fontwork object will appear in the document.
3) Double-click the object to edit the Fontwork text (Figure 195). Select the text and typeyour 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 194: The Fontwork Gallery

Figure 195: 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
Chapter 11, Images and Graphics, in the Getting Started Guide.

224 | Chapter 5 Using Images and Graphics

Calc Guide

Chapter 6
Printing, Exporting, Emailing,
and SigningPrinting
Quick printing
To quickly print a spreadsheet, click on the Print Directly icon (not visible by default) on theStandard toolbar to send the entire spreadsheet to the default printer that is defined for yourcomputer.

Note
You can change the action of the Print Directly icon to send a document to theprinter 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 withthe document option.

Controlling printing
For more control over printing, select File > Print on the Menu bar, or click the Print icon on theStandard toolbar, or press Ctrl+P, to open the Print dialog (Figure 196).

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 14, Setting up and Customizing.
The Print dialog has multiple tabs where you can choose a range of options, as described in thefollowing sections. Depending on your computer’s operating system, the number of tabs and thelayout of each tab may be different from the illustrations shown in this chapter. On someinstallations, a More Options button is provided in the Print dialog.
The Print dialog includes a Preview checkbox which 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 196), you can choose from the following options:•

Printer– Select the printer to use, from the list of those available.
– 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 ofcopies to print; whether to collate multiple copies; and the page order for printing.
(See “Selecting what to print” on page 228.)•

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.

226 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 196: Print dialog – General tab

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

Figure 197: Print dialog – LibreOffice Calc tab

More Printing Options dialog
Click the More Options button to access the More Printing Options dialog (Figure 198). In this
dialog, you can choose whether to create separate print jobs for collated output.

Printing | 227

Figure 198: More Printing Options dialog

Printing multiple pages on a single piece of paper
To print multiple pages of a spreadsheet on one piece of paper:
5) Use File > Print on the Menu bar, or click the Print icon on the Standard toolbar, or press
Ctrl+P, to open the Print dialog.
6) In the Page Layout section of the General tab, select the number of spreadsheet pages toprint per sheet of paper in the Pages per sheet drop-down list. The preview panel on theright shows how the pages will look in the printed document.
7) When printing more than two pages per sheet, select the order in which the pages are
printed on a sheet in the Order drop-down list (Figure 199).
8) To distinguish each page on a sheet, select the Draw a border around each page
option.
9) Click Print.

Figure 199: 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 needto 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 forprinting.
To print an individual sheet:1) In the spreadsheet, click on the sheet tab to select the sheet you want to print.

228 | Chapter 6 Printing, Exporting, Emailing, and Signing

2) Choose File > Print on the Menu bar, or click the Print icon on the Standard toolbar, orpress Ctrl+P, 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, orpress Ctrl+P, 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 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, orpress Ctrl+P, 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 printerYou 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, orpress Ctrl+P, to open the Print dialog.
2) Click Properties to open the Properties dialog for the printer. The available choices varyfrom one printer to another, but you should find options for the color settings. See yourprinter’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) Select Convert colors to grayscale. Click OK to save the change.

CautionThis changes the print settings for all components of LibreOffice, not just Calc

Printing | 229

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 200: Print Preview toolbar
3) To print the document from this view, select File > Print on the Menu bar, or click thePrint icon on the Standard toolbar, or press Ctrl+P, 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 righthand 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, oropen 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” on page 231.

Editing a print range
At any time, you can edit the print range, For example to add or remove cells, or define rows andcolumns to repeat (such as column or row headings). For more details on how to define repeatedrows and/or columns, see “Repeat printing of rows or columns” on page 234.
1) Go to Format > Print Ranges > Edit on the Menu bar to open the Edit Print Ranges
dialog (Figure 201).

230 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 201: Edit Print Ranges dialog
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 202.

Figure 202: Single print
range marked by abounding box3) 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 acomma 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 thepage breaks, go to View > Page Break on the Menu bar to open the preview (Figure 203).
The print ranges are outlined by default with a blue border and contain a pale gray page numberin the center of each page. The non-printing area of the spreadsheet normally has a graybackground.
To exit the page break preview, go to View > Normal on the Menu bar.

Using print ranges | 231

Figure 203: Page break preview

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 204: 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 204). The selected cells are displayed in the Range or formula expression box.
Alternatively, open the Define Name dialog, then select the cells you want to define andname. The selected cells are then displayed in the Range or formula expression box.
2) Type a name for the range in the Name box. Use only letters, numbers, and underscoresin the name; no spaces, hyphens, or other characters are allowed.
232 | Chapter 6 Printing, Exporting, Emailing, and Signing3) 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” on page 230 for more
information.
4) Make sure Document (Global) is selected in the Scope drop-down list.
5) Select Print range from Range Options to define the settings as a print range.
6) 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 205).
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.

Figure 205: 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 206).
2) Select the named print range you want to delete and confirm it is a print range bychecking the options from the Range Options.
3) Click Delete and then click OK to close the dialog.

Using print ranges | 233

Figure 206: Manage Names dialog

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 (forexample, headings) to repeat print on each printed page.

234 | Chapter 6 Printing, Exporting, Emailing, and Signing

Using print ranges

Figure 207: Repeat printing of rows and columns
1) Go to Format > Print Ranges > Edit to open the Edit Print Ranges dialog (Figure 207).
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 -.
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 thewhole row.
3) 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 -.
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.
4) 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” on page 232 for more information. Similar to user defined print ranges, it issufficient to select one cell from the row or column you want to be repeat printed.
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 204 on page 232).
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 207).
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:

Page breaks | 235

• 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 orcolumns 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 acolumn 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 thecontext 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
The Column Break or Row Break options are grayed if an appropriate cell has notbeen selected, either to the right of a column break or below a row break.

Deleting multiple page breaks
Multiple manual row and column breaks can exist in the same spreadsheet. If you want toremove 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 pagestyle. 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 4, Using Styles and Templates, for more information about page styles.

236 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 208: 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 on the Menu bar to open the Page Style dialog, then click on the
Sheet tab (Figure 208) to set the printing options for a page style. The dialog indicates which
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.
• 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 208.
– 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 rightcolumn.
– First page number – select this option if you want the first page to start with anumber 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.

Printing options for page styles | 237

– 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 theprinted 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 thecell.
•

Scale – defines a page scale for the printed spreadsheet.
– Scaling mode – select a scaling mode in the drop-down list. Appropriate controls forthe scaling mode selected will be shown below the drop-down list box.
i) 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.
ii) Fit 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 ofpages may be less than specified. You may clear one of the boxes; then theunspecified dimension will use as many pages as necessary. If you clear both
boxes, the scaling factor will be 100%.
iii) Fit print range(s) on number of pages – specifies the maximum number ofpages 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.

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 on the Menu bar.
– Go to the Styles deck of the Sidebar, right-click the relevant page style, and selectModify in the context menu.
– Double-click the name of the page style on the Status Bar.
3) Select the Header (or Footer) tab (Figure 209). The Header and Footer tabs on the Page
Style dialog are identical.
4) Select the Header on or Footer on option.

238 | Chapter 6 Printing, Exporting, Emailing, and Signing5) Enter the values for the other options according to your requirements. These options aredescribed below.
6) Click OK to save your changes and close the dialog.

Figure 209: 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 sameheader 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” on page 240 for
more information.

•

Left margin – enter the amount of space to leave between the left page margin and theleft edge of the header or footer.

•

Right margin – enter the amount of space to leave between the right page margin andthe 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 edgeof the spreadsheet.

•

Height – enter the height for the header or footer.

•

AutoFit height – automatically adjusts the height of the header or footer to fit thecontent.

•

Preview box – shown on the right side of Figure 209, this area displays a preview of thecurrent selection.

• More – opens the Border/Background dialog, where you can define the appearance ofborders and background colors or images for headers or footers. See Chapter 4, Using
Styles and Templates, for more information.
• Edit – opens the Header or Footer dialog where you can add, edit, or format text that isplaced in the header or footer. See “Header or footer contents” below for more
information.

Headers and footers | 239

Header or footer contents
The headers and footers in a Calc spreadsheet have three columns for text. Each column caneither 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 209), then select Header on or Footer on and theoptions for the header or footer. See “Setting headers and footers” above.
3) Click Edit to open the Header or Footer dialog (Figure 210). If Same content on left andright pages is deselected in the Page Style dialog, the Header or Footer dialog will havetabbed pages where you can set the header or footer contents for 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 andtype 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 fontposition.
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.

Figure 210: 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.

240 | Chapter 6 Printing, Exporting, Emailing, and Signing•

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 theselected 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 fileformat is ideal for sending a file to someone else, for viewing using Adobe Acrobat Reader or any
other PDF viewer.

CautionBy 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.

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 inyour 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). You are
asked to enter the file name and location for the PDF, but you do not get a chance to choose apage range, image compression, or other options.

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 Saveas type drop-down menu.

Exporting to PDF | 241

General tab of PDF Options dialog
On the General tab (Figure 207), you can choose which pages to include in the PDF, the type ofcompression to use for images (which affects the quality of images in the PDF), and otheroptions. For more information, see the Getting Started Guide or the Help. In most cases, thedefaults will be what you need.

Figure 211: PDF Options dialog – General tab
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 3to 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 material (one or more sheets or partof a sheet).

•

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 canlead 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 ofquality).

•

Reduce image resolution: Select the required value from the options in the drop-downmenu. Lower DPI (dots per inch) images have lower quality. Higher DPI settings cangreatly increase the size of the exported file.

242 | Chapter 6 Printing, Exporting, Emailing, and Signing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 filecontaining 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.

•

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, andwhen 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 ofsubmitting 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.
•

Comments as PDF annotations: Exports comments as PDF notes. You may not want
this!

•

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 causes Calc to disregard many of theother 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 section 8.10.4 of the PDF specification,
ISO 32000-2:2017 (https://www.iso.org/standard/63534.html). If you are not familiar withreference XObjects, leave this box unchecked.

Initial View tab of PDF Options dialog
On the Initial View tab (Figure 212), you can select how the PDF file opens by default in a PDF
viewer. The options should be self-explanatory.

Exporting to PDF | 243

Figure 212: PDF Options dialog – Initial View tabUser Interface tab of PDF Options dialog
On the User Interface tab (Figure 213), 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 apresentation or a kiosk-type display.

244 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 213: PDF Options dialog – User Interface tab
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.

Note
Outlines are generally not used in Calc.

Links tab of PDF Options dialog
On the Links tab (Figure 214) you can select how bookmarks and hyperlinks are exported to
PDF.
Exporting to PDF | 245

Figure 214: PDF options dialog - Links tab
General– Export outlines as named destinations: If you have defined Calc sheet names, thisoption 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 otherdocuments 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 adocument, 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.

Security tab of PDF Options dialog
Use the Security tab (Figure 215) to encrypt and set passwords when you export yourspreadsheet 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.

246 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 215: PDF Options dialog – Security tab
Click the Set Passwords button to open the Set Passwords dialog (Figure 216), 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 (forexample, 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 215. After you set a password for permissions, the otherchoices 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.

Exporting to PDF | 247

Figure 216: Set Passwords dialog

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 (thatis, 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 217: PDF Options dialog – Digital Signatures tab•

Use this certificate to digitally sign PDF documents: Click Select to open the SelectCertificate 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 asmartcard 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.

248 | Chapter 6 Printing, Exporting, Emailing, and Signing•Certificate password: Enter the password used for protecting the private key associatedwith the selected certificate. Usually this is the key store password. If the key store
password has already been entered in the Select 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 thatis then embedded in the signature. Anyone viewing the PDF can use this timestamp toverify when the document was signed.
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 send a document quickly and easily 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” on page 241.
2) In your email program, enter the recipient, subject, and any text you want to add, thensend the email.

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 apublic key, which you add to your documents when you sign them. You can get a certificate froma certification authority, which may be a private company or a governmental institution.

Digital signing of documents | 249

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 bothare 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 thepublic key with the public key that is published on the web site of the certificate authority.
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 thesignature. For a more detailed description of how to get and manage a certificate, and signaturevalidation, 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” on page 252), 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 andrestart 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 218). It lists existing signatures and their descriptions (if they have any).
3) On the Digital Signatures dialog, click Sign Document to open the Select Certificate
dialog (Figure 219).
Select the certificate you want to use and click Sign to close the Select Certificate dialog.
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 wasvalidated.
– 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.
4) 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 thecertificate. More than one signature can be added to a document.

Note
If you make any changes to the document after digitally signing, the digital signatureis removed automatically and you have to repeat the above procedure to digitally
sign it again.

250 | Chapter 6 Printing, Exporting, Emailing, and SigningFigure 218: Digital Signatures dialog

Figure 219: Select 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 sameauthor are allowed, because each signature can have a different meaning.
When you select File > Digital Signatures > Digital Signatures, the dialog (Figure 218) lists
existing signatures together with their description (if they have any).
When you click the Sign Document button, the dialog (Figure 219) for certificate selection now
also asks for an optional description.
Digital signing of documents | 251

Changing the value of an existing description invalidates the signature.

Digitally signing macros
Normally, macros are part of a document. If you sign a document, the macros inside thedocument 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 describedabove.

Removing personal data
You may wish to ensure that personal data, versions, notes, hidden information, or recordedchanges 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 automaticallyon 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 theversions from the list and click Delete, or go to File > Save As and save the file with adifferent name.

252 | Chapter 6 Printing, Exporting, Emailing, and Signing

Calc Guide

Chapter 7
Using Formulas andFunctionsIntroduction
In previous chapters, we have been entering one of two basic types of data into each cell:numbers and text. However, we will not always know what the contents should be. Often thecontents of one cell depends on the contents of other cells. To handle this situation, we use athird type of data: the formula. Formulas are equations using numbers and variables to get a
result. In a spreadsheet, the variables are cell locations that hold the data needed for theequation to be completed.
A function is a predefined calculation entered in a cell to help you analyze or manipulate data. All
you have to do is add the arguments, and the calculation is made automatically. Functions help
you create the formulas needed to get the results that you are looking for.

Setting up a spreadsheet
If you are setting up more than a simple one-sheet system in Calc, it is worth planning ahead alittle. Make sure to:•

Avoid typing fixed values into formulas•

Include documentation (notes and comments) describing what the system does,
including what input is required and where the formulas come from (if not created fromscratch)•Incorporate a system of error-checking of formulas to verify that the formulas do what is
intended

The trap of fixed values
Many users set up long and complex formulas with fixed values typed directly into the formula.
For example, conversion from one currency to another requires knowledge of the current
conversion rate. If you input a formula in cell C1 of =0.75*B1 (for example to calculate the value
in Euros of the USD dollar amount in cell B1), you will have to edit the formula when theexchange rate changes from 0.75 to some other value. It is much easier to set up an input cellwith the exchange rate and reference that cell in any formula needing the exchange rate. What-if
type calculations are also simplified: what if the exchange rate varies from 0.75 to 0.70 or 0.80?
No formula editing is needed and it is clear what rate is used in the calculations. Breaking
complex formulas down into more manageable parts, described below, also helps to minimize
errors and aid troubleshooting.

Lack of documentation
Lack of documentation is a very common point of failure. Many users prepare a simple sheet
which then develops into something much more complicated over time. Without documentation,
the original purpose and methodology is often unclear and difficult to decipher. In this case it isusually easier to start again from the beginning, wasting the work done previously. If you insert
comments in cells, and use labels and headings, a spreadsheet can later be easily modified by
you or others and much time and effort will be saved.

Error-checking formulas
Adding up columns of data or selections of cells from a sheet often results in errors due toomitting cells, wrongly specifying a range, or double-counting cells. It is useful to institute checks
in your spreadsheets. For example, set up a spreadsheet to calculate columns of figures, anduse the function SUM to calculate the individual column totals. You can check the result by
including (in a non-printing column) a set of row totals and adding these together. The two values—row total and column total—must agree. If they do not, you have an error somewhere.
254 | Chapter 7 Using Formulas and Functions

You can even set up a formula to calculate the difference between the two totals and report anerror in case a non-zero result is returned (see Figure 220).

Figure 220: Error checking of formulas

Creating formulas
You can enter formulas in two ways. One method is to use the Function Wizard or the equivalentfacilities in the Functions deck of the Sidebar. The second method is to type directly into the cellor into the Input line. A formula must begin with an = symbol. When typing directly, you normallyneed to start a formula with =. However, if your formula begins with a + or – (for example -2*A1),
then Calc automatically adds the = symbol. An = is not added if you simply enter a positive or
negative number (such as -2 or +3). Starting with anything else causes your intended formula to
be treated as if it were text.

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 221.
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 thiscase, 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 thecontents 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 5.
These cell references allow formulas to use data from anywhere in the sheet being worked on, orfrom 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 inthis 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.
Creating formulas | 255

Simple Calculation in 1 Cell

Calculation by Reference

Figure 221: A simple calculation
Table 5: Common ways to use formulas
FormulaDescription=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 suchas B3:B10.

256 | Chapter 7 Using Formulas and Functions

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 thecontents of C31 is greater than 140, then HIGH is displayed,otherwise OK is displayed.

Operator types
You can use the following operator types in Calc: arithmetic, comparative, text, and reference.

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, forexample -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 6: 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 thecontents 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 isreturned, otherwise FALSE is returned.
Table 7: Comparative operators
Operator
Name

ExampleResult (A=4, B=5)

=

Equal

A1=B1

FALSE

>

Greater than

A1>B1

FALSE

<

Less than

A1<B1

TRUE

>=

Greater than or equal to

A1>=B1FALSE<=

Less than or equal toA1<=B1TRUE<>

Inequality

A1<>B1TRUE

Creating formulas | 257

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
It is common for users to place text in spreadsheets. To provide for variability in what and how
this type of data is displayed, text can be joined together in pieces coming from different placeson the spreadsheet. Figure 222 shows an example.

Figure 222: Text concatenation
In this example, specific pieces of the text were found in three different cells. To join thesesegments together, the formula also adds required spaces and punctuation enclosed within
quotation marks, resulting in a formula of =B2 & “ ” & C2 & “, ” & D2. The result is theconcatenation into a date formatted in a particular sequence.
Calc has a CONCATENATE function which performs the same operation.

Reference operators
An individual cell is identified by the column identifier (letter) located along the top of the columns
and a row identifier (number) found along the left-hand side of the spreadsheet. On spreadsheets
read from left to right, the reference for the upper left cell is A1.
Thus in its simplest form a reference refers to a single cell, but references can also refer to arectangle or cuboid range, or a reference in a list of references. To build such references youneed reference operators.
Reference range operator
The range operator is written as a colon. An expression using the range operator has thefollowing 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 223 the reference A1:D12 is shown, corresponding to the cells
included in the drag operation with the mouse to highlight the range.

258 | Chapter 7 Using Formulas and Functions

Figure 223: Reference operator for a range
Table 8: Reference range operator examples
ExampleDescription

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, andSheet3 appear in that order on the Sheet tabs area.)

B:B

Reference to all cells of column B.

A:DReference 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.
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. Somefunctions 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 thesame 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.
Creating formulas | 259

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.
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 rightIf the references refer to single ranges, the result is a reference to a single range, containing allcells, 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.
ExamplesA2: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 224, 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 bothan orange background and a thick black border (B3:B4) form the intersection of the two ranges.

Figure 224: 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 areconcatenated, dropping empty parts. So the final result is the reference list B2:B4 ~ B2:C2 ~C1:C2.
A:B ! 10:10
Calculates the intersection of columns A and B with line 10, thus selecting A10 and B10.
You can use the intersection operator to refer 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 intersection operator (!) has a higher precedence than the concatenation operator (~), but do
not rely on precedence.

Tip
Always put in parentheses the part that is to be calculated first.

260 | Chapter 7 Using Formulas and Functions

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 andabsolute reference using the spreadsheet from Figure 225.
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 thesum 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 cellholding 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 andC4.

Figure 225: Relative references
You can think of a relative address as a pair of offsets to the current cell. Cell B1 is 1 column tothe left of cell C5 and 4 rows above. The address could be written as R[-4]C[-1]. In fact earlier
spreadsheets allowed this notation method to be used in formulas.
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 theformula.
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 mightshow amounts in US Dollars. To convert these amounts to Euros it is necessary to multiply eachdollar amount by the exchange rate. $US10.00 would be multiplied by 0.75 to convert to Euros, inthis 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.
Creating formulas | 261

2) In cell E2 type the formula =D2*D1. The result is 7.5, correctly shown.
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. Theinterpretation 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.

Enter the conversion formula into E2, which will show the correct result, then copy it to E3.

E3 result is clearly wrong; change the formula in E2 to use absolute reference.

Copy the correct formula from E2 to E3 to get the correct answer.
Figure 226: Absolute references
Cell references can be shown in four ways, listed in Table 9.
Table 9: 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

262 | Chapter 7 Using Formulas and Functions

Tip
To change references in formulas, highlight the cell and press F4 to cycle through thefour types of references. To cycle only part of the formula select the cells in theformula bar and cycle with F4. Selecting the menu option Sheet > Cycle Cell
Reference Types is equivalent to pressing the F4 shortcut.
Knowledge of the use of relative and absolute references is essential if you want to copy andpaste formulas and to link spreadsheets.

Named ranges
Cells and cell ranges can have a name assigned to them. Naming cells and ranges enhances
formula readability and document maintenance. A simple example would be naming a range ofcells B1:B10 as “Weight” and sum all weights. The formula is =SUM(B1:B10). When the range
B1:B10 is named as Weight, you can transform the formula to =SUM(Weight). The advantage isclear in terms of readability of the formulas.
Another advantage is that all formulas that have the named range as argument are updated
when the named range changes location or size. For example, if the range Weight is now in cells
P10:P30, you do not need to review all the formulas that have Weight as an argument; you only
need to update the named range Weight with the new size and location.
To define a named cell or range select the cell or range and use menu Sheet > Named Ranges
and Expressions > Define. The dialog in Figure 227 appears with the selected range and you
define the name and scope of the named range.

Figure 227: 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 228).

Creating formulas | 263

Figure 228: Inserting name in therange 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 229: Manage Names dialog

264 | Chapter 7 Using Formulas and Functions

To modify a named range, use the Manage Names dialog (Figure 229). This dialog is accessedby 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 Namedialog (Figure 227) and enter the formula expression in the Range or formula expression box.
Name the expression and click Add.
As an example, suppose you need to compute in cells C1 to C10 the circumference of a set ofcircles 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 andpaste 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 andrelative references.

Order of calculation
Order of calculation refers to the sequence in which numerical operations are performed and the
Wikipedia article at https://en.wikipedia.org/wiki/Order_of_operations provides useful generalbackground information. Division and multiplication are performed before addition or subtraction.
There is a common tendency to expect calculations to be made from left to right as the equation
would be read in English. Calc evaluates the entire formula, then based upon programming
precedence, breaks the formula down executing multiplication and division operations before
other operations. Therefore, when creating formulas you should test your formula to make surethat the expected and correct result is being obtained. Following is an example of the order ofcalculation in operation.
Table 10: Order of calculation
Left To Right Calculation

Ordered Calculation

1+3*2+3 = 11
1+3 = 4, then 4x2 = 8, then 8+3 = 11

=1+3*2+3 result 10
3*2 = 6, then 1+6+3 = 10

Another possible intention could be:
1+3*2+3 = 20
1+3 = 4, then 2+3 = 5, then 4x5=20

The program resolves the multiplication of 3 x 2
before dealing with the numbers being added.

If you intend for the result to be either of the two possible solutions on the left, order the formulaas:((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
Another powerful feature of Calc is the ability to link data through several sheets. The naming ofsheets can be helpful to identify where specific data may be found. A name such as Payroll or
Boise Sales is much more meaningful than Sheet1. The function named SHEET() returns the
sheet number (position) in the collection of sheets. There may be several sheets in eachCreating formulas | 265document and they may be numbered from the left: Sheet1, Sheet2, and so forth. If you drag the
sheets around to different locations among the tabs, the function returns the number referring to
the current position of this sheet. In a new instance of Calc, the default is a single sheet.
For example, if the formula =SHEET() is put into A1 on Sheet 1 it returns the value 1. If you dragSheet 1 to be positioned between sheets 2 and 3 then the value changes to 2; it is now thesecond 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 the four parts of Figure 230 below.
Sheet containing data
for Branch 1.

Sheet containing data
for Branch 2.

Sheet containing data
for Branch 3.

266 | Chapter 7 Using Formulas and Functions

Sheet containing
combined data for all
branches.

Figure 230: Combining data from several sheets into a single sheet
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
following: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 231), select the Copy option (automaticallyselected if there is only one sheet in the spreadsheet) and select -move to end positionin the Insert before area. Change the entry in New name to Branch2. Click OK. Repeat toproduce the Branch3 and Combined sheets.

Figure 231: Copying a sheet3) 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 aformula in cell K7 which adds the revenue from greenery sales for the three branches.
Creating formulas | 267

Figure 232: Combined sheet showing linking between branch sheets5) 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 thecontext menu, or press Ctrl+Shift+V. Uncheck the Paste all and Formats options in the
Selection area of the dialog, check all other options in that area, and click OK. You will
see the following message:

Figure 233: Linking sheets: pasting a formula to acell 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 234: Linking sheets: Copy / Paste Special from K7:N17
The Function Wizard can also be used to accomplish the linking. Use of this wizard is describedin detail in “Using the Function Wizard” on page 272.

268 | Chapter 7 Using Formulas and Functions

Understanding functions
Calc includes over 500 functions to help you analyze and reference data. Many of thesefunctions 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 abinary 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:+

This operator adds two numbers together for a result. SUM() on the other hand adds groupsof contiguous ranges of numbers together.

*

This operator multiplies two numbers together for a result. PRODUCT() does the same formultiplying 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,
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 theirname 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.

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 somefunctions within Calc that are not in accordance with OpenFormula but many of these areincluded specifically to improve the exchange of files between Calc and Microsoft Excel.)In order to improve interoperability, Calc is able to open spreadsheets created by many different
applications and to save them in many different formats. In the case of Microsoft Office, it isextremely straightforward to exchange spreadsheet files between the two applications. When
Calc opens a Microsoft Excel spreadsheet, it automatically takes steps to avoid incompatibilities
that might otherwise be encountered with certain functions. For example, when Calc opens an
Excel file that contains calls to Excel’s CEILING function, these are automatically converted toreference Calc’s CEILING.XCL function. Similarly when Calc saves a spreadsheet to Microsoft
Excel format, it automatically takes steps to avoid potential incompatibilities. An example of thisoccurs when Calc saves a spreadsheet containing calls to its FLOOR function, as these areautomatically converted to reference Excel’s FLOOR.MATH function.
The Document Foundation’s wiki provides a comparison of the features of LibreOffice andMicrosoft Office, see https://wiki.documentfoundation.org/Feature_Comparison:_LibreOffice__Microsoft_Office. This comparison shows that Calc currently provides 508 discrete functions,with only 30 of those being unique to Calc, and the remainder having counterparts in Microsoft
Excel. It is clear that there is a high level of commonality between the function sets of Calc and
Excel, and many functions can be used in both applications with no change, thus increasing
interoperability.
Understanding functions | 269

There are cases where a Calc function produces a result in accordance with international
standards but the result differs from that produced by the equivalent Excel function. In suchcases Calc often has a similarly named function but with a suitable modifier added to its name(such as “_ADD” or “_EXCEL2003”) which provides the same result as the Excel function.

Understanding the structure of functions
All functions have a similar structure. If you use the right tool for entering a function, you canescape learning this structure, but it is still worth knowing for troubleshooting.
As a typical example, the structure of a function to find cells that match entered search criteria is:=DCOUNT(Database, Database field, Search criteria)
A function cannot exist on its own; it must always be part of a formula. Consequently, even if thefunction represents the entire formula, there must be an = sign at the start of the formula.
Regardless of where in the formula a function is, the function will start with its name, such as
DCOUNT in the example above. After the name of the function comes its arguments. Allarguments are required, unless specifically listed as optional.
Arguments are added within the parentheses and are separated by commas. A Calc function cantake up to 255 arguments. An argument can be not only a number or a single cell, but also anarray or range of cells that contain several or even hundreds of cells.
Depending on the nature of the function, arguments may be entered as in Table 11.
Table 11: 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.

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 thequizzes with the formula =AVERAGE(A1:A3). The formula then uses the IF function to give thestudent 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 tothe 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.

270 | Chapter 7 Using Formulas and Functions

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 offunctions, 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.

Using the Functions deck
A more reliable method is to use the Functions deck on the Sidebar (Figure 235), 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.
The Functions deck includes a brief description of each function and its arguments. Highlight thefunction and look at the bottom of the pane to see the description. If necessary, hover the cursor
over the division between the list and the description; when the cursor becomes a two-headed
arrow, drag it upwards to increase the space for the description. Double-click on a function’sname 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 errorprone. In practice, though, some users may fumble when replacing the placeholders with values.
Another feature is the ability to display the last formulas used.

Figure 235: Functions deck in Sidebar

Understanding functions | 271

Using the Function Wizard
The most commonly used input method is the Function Wizard (Figure 236). 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 ofwhich it is part.
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 12. When you
select a function its description appears on the right-hand side of the dialog. Optionally you cantype the function name in the search box and the search narrows on each character inserted(Figure 236).
Table 12: Function categories in the Function Wizard
Category

Number of functions in
category

Add-in

48

Array

15

Database

12

Date&Time36

Financial

63

Information

21

Logical11

Mathematical82

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.

272 | Chapter 7 Using Formulas and Functions

Figure 236: Functions tab of Function Wizard

Figure 237: Function Wizard after shrinking
To select cells, either click directly on the cell or hold down the left mouse button and drag toselect 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 forthe 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 isadded 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 iteasier to manage. The price of this reliability is slower input, but precision is generally more
important than speed when creating a spreadsheet.
Understanding functions | 273

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 iscalculated by a simpler function call or arithmetic operation and then combined following the rulesof calculation. It is possible to visualize each parsed element of the formula and check if theintermediate 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 theEnter 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 238: 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 theresult will display. However, you can still see the formula in the Input line.

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 sizeof 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 239: Source array in yellow and resulting array in green. The array
formula is shown in the Formula Bar

274 | Chapter 7 Using Formulas and Functions

To multiply the values in the individual cells by 10 in the above array (Figure 239), you do notneed 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 inthe 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 ofcells containing TRUE.

When do you use array formulas?
Use array formulas if you have to repeat calculations using different values. If you decide tochange 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.
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 236). Otherwise, only the value inthe upper-left cell of the array being calculated is returned.
If you enter the array formula directly into the cell, you must use the key combination
Shift+Ctrl+Enter instead of the Enter key. Only then does the formula become an array formula.

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.

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 2
x=x i+ v i t + at
2
This equation models the position of an object undergoing linear, translational motion, withconstant 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).

Strategies for creating formulas and functions | 275

For ease of presentation, it is good practice to set up a spreadsheet in a manner similar to thatshown in Figure 240. In this example, the individual variables are input into cells on the sheet andno editing of the formula is required.

Figure 240: Setting up a formula with arguments
You can take several broad approaches when creating a formula. In deciding which approach totake, consider how many other people will need to use the sheets, the life of the sheets, and thevariations 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.
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.
You might be aware that you cannot use negative values or zero values for a particularargument, but if someone else inputs such a value, will your formula be robust or simply return astandard (and often not too helpful) error message? It is a good idea to trap errors using someform of logic statements or with conditional formatting.

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 can berecommended 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, but instead you break down longer formulas into
smaller parts and then combine the parts into the whole. Many examples of this type exist incomplex scientific and engineering calculations where interim results are used in a number ofplaces in the sheet. The result of calculating the flow velocity of water in a pipe may be used inestimating losses due to friction, whether the pipe is flowing full or partially empty, and in
optimizing the diameter for the given flow regime.
In all cases you should adopt the basic principles of formula creation described previously.

Speeding up calculations
Spreadsheets are often used to process raw data and produce meaningful summaries,
consolidation and display of information for the decision maker, or to be used as the source forreports. The raw data can be produced by physical measurements, business transactions, orvarious other means. Sheets with thousands or even hundreds of thousands of rows and several
columns are frequently found in finance departments or laboratories. Computations carried out
on these raw data sets can be time consuming and last for minutes, hours and perhaps, days.
276 | Chapter 7 Using Formulas and Functions

A common mistake is to insert formulas for each cell and perform thousands of formulainterpretations and calculations. Here are some recommendation for speeding up calculations.

Use array formulas on massive data
Array formulas have one formula applied to the mass of data. Computation saving can besignificant 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 billof 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.

Use macros to create functions
Another strategy is to create your own functions and macros. This approach would be used
where the result would greatly simplify the use of the spreadsheet by the end user and keep theformulas simple with a better chance of avoiding errors. This approach also can make themaintenance easier by having corrections or updates kept in one central location. The use of
macros is described in Chapter 12, Macros, and is a specialized topic in itself. The danger ofoverusing macros and custom functions is that the principles upon which the spreadsheet isbased become much more difficult to see by a user other than the original author (andsometimes even by the author!).

Multi-threading
Many modern computers have multi-core processors and provide for multiple threads. A core is aphysical hardware component within a CPU. Threads are virtual components that help toefficiently manage the workload and tasks of the CPU. A CPU can interact with more than one
thread at a time and multi-threading makes CPUs more efficient, to give better overall
performance.
Calc supports multi-threading to help your spreadsheets take advantage of whatever parallel
processing is available within your computer. This facility is controlled by the Enable multithreaded calculation option in the CPU threading settings section of the Tools > Options >LibreOffice Calc > Calculate dialog. The initial default is for this option to be enabled, anddisabling it is not recommended. This is the only control in the Calc user interface that relates tomulti-threading; once initiated, the processing operates automatically.
If multi-threading is enabled, Calc automatically identifies where your spreadsheet could benefit
from multi-threading and processes it accordingly. Threads are generally used for formulagroups, 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 iscolumn-based and so a row-based layout could be less efficient.

Strategies for creating formulas and functions | 277

There are other ways to control Calc’s multi-threading capability, such as adjusting the
MAX_CONCURRENCY LibreOffice specific environment variable. However, these methods arebeyond the scope of this document.

Finding and fixing errors
It is common to find situations where errors are displayed. Even with all the tools available inCalc to help you to enter formulas, making mistakes is easy. Many people find inputting numbers
difficult and many may make a mistake about the kind of entry that a function’s argument needs.
In addition to correcting errors, you may want to find the cells used in a formula to change theirvalues or to check the answer.
Calc provides three tools for investigating formulas and the cells that they reference: error
messages, color coding for input, and the Detective.

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 anunhelpful piece of text such as #NAME?, #REF!, or #VALUE!. The error message appears in thecell, 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.
Error messages are not user-friendly, and may intimidate new users. However, they are valuableclues to correcting 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 13.
Table 13: Common error messages
Code

Meaning#NAME?

Instead of displaying Err:525. No valid reference exists for the argument.

#REF!

Instead of displaying Err:524. The column, row, or sheet for the referenced cell is
missing.

#VALUE!

Instead of displaying Err:519. The value for one of the arguments is not the type thatthe argument requires. The value may be entered incorrectly; for example, doublequotation 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.

#NUM!

Instead of displaying Err:503. A calculation results in an overflow of the defined value
range.

509

An operator such as an equals sign is missing from the formula.

510

A variable is missing from the formula.

Examples of common errors#DIV/0! division by zeroThis error is the result of dividing a number by either the number zero (0) or a blank cell. There isan easy way to avoid this type of problem. When you have a zero or blank cell displayed, use aconditional function. Figure 241 depicts division of column B by column C yielding 2 errors arisingfrom a zero and a blank cell showing in column C.
278 | Chapter 7 Using Formulas and Functions

Figure 241: Examples of #DIV/0!, division by zero error
It is very common to find an error such as this arising from a situation where data was notreported or reported incorrectly. When such an occurrence is possible, an IF function can beused to display the data correctly. The formula =IF(C3>0, B3/C3, “No Report”) can beentered. The formula is then copied over the remainder of column D. The meaning of this formularoughly would be: “If C3 is greater than 0, then compute B3 divided by C3, otherwise enter ‘No
Report’”. An example is shown in Figure 242.
It is also possible for the last parameter to use double quotes for a blank (no value) to beentered, or a different formula with a standardized number being substituted for the lower
number.

Figure 242: 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 theexample of Figure 243, text “None” has been entered in C8, where our formula in column D is
expecting a number.

Figure 243: Incorrect entry causing#VALUE! error
Finding and fixing errors | 279

The #REF! error is caused by a missing reference. In the example shown in Figure 244, theformula references a sheet that has been deleted.

Figure 244: 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 245: Color coding for input
Calc uses eight colors for outlining referenced cells, starting with blue for the first cell, andcontinuing with red, magenta, green, dark blue, brown, purple, and yellow before cycling throughthe sequence again.

Value highlighting
There are situations where the display of cell contents is the same when the data type isdifferent. For example a text contents and a 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 acell can be confused with the value 10.35. When the cell is used in a formula the string may takethe 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 is in black characters and the numeric contents is in blue. See Chapter 2,
Entering, Editing, and Formatting 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 cells areused 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 forremoving 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 tracingthese precedents, you frequently can find the source of the errors. Place the cursor in the cell inquestion and then choose Tools > Detective > Trace Precedents on the Menu bar or press
Shift+F9. Figure 246 shows a simple example of tracing precedents for cell B4.

280 | Chapter 7 Using Formulas and Functions

Figure 246: Tracing precedents using the
Detective
This allows us to check the source cells (which may be a range) for any errors which havecaused us to query the calculation result. If a source is a range, then that range is highlighted inblue.
In other instances we may have to trace an error. For this we use the Trace Error function, foundunder 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 novices, functions are one of the most intimidating features of LibreOffice Calc. New users
quickly learn that functions are an important feature of spreadsheets, but there are hundreds, andmany require input that assumes specialized knowledge. Fortunately, Calc includes many
functions that anyone can use.

Basic arithmetic and statistics
The most basic functions create formulas for basic arithmetic or for evaluating numbers in arange 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 anyother 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
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. Insteadof entering =POWER(A1,2), you can enter =A1^2.
Moreover, they have the advantage that you enter formulas with them in an order that moreclosely approximates human readable format than the spreadsheet-readable format used by theequivalent 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)).

Examples of functions | 281

The main disadvantage of using arithmetical operators is that you cannot directly use a range ofcells. 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 asa 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 asa 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 andthe 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 theseformulas, 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 wereabsent 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, arank of 2 used with SMALL gives you the second smallest number. Both LARGE and SMALL arehandy as a permanent control, since, by changing the rank argument, you can quickly scanmultiple results.
You would need to be an expert to want to find the Poisson distribution of a sample, or to find theskew or negative binomial of a distribution (and, if you are, you will find functions in Calc for suchthings). 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 canfind the arithmetical mean—that is, the result when you add all entries in a list then divided by the
number of entries, by entering a range of numbers when using AVERAGE, or AVERAGEA toinclude text entries and to give them a value of zero.
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 willbe 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 thevalue 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,

282 | Chapter 7 Using Formulas and Functions

and the type of rank (0 for the rank from the highest, or any other value for the rank fromthe 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. Which you use depends on
your temperament and your needs. Some might prefer to use MIN and MAX because they areeasy to remember, while others might prefer QUARTILE because it is more versatile.

Using these functions
In some cases, you may be able to get similar results to some of these functions by setting up afilter or a custom sort. However, in general, functions are more easily adjusted than filters or
sorts, and provide a wide range of possibilities.
At times, you may just want to enter one or more formulas temporarily in a convenient blank cell,and delete it once you have finished. However, if you find yourself using the same functions
constantly, you should consider creating a template and including space for all the functions youuse, with the cell to their left used as a label for them. Once you have created the template, you
can easily update each formula as entries change, either automatically and on-the-fly or pressing
the F9 key to update all selected cells.
No matter how you use these functions, you will probably find them simple to use and adaptable
for many purposes. By the time you have mastered this handful, you will be ready to try more
complex functions.

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 forbilling 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 isirrelevant 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, theformula =ROUND((SUM(A1,A2)) adds the figures in cells A1 and A2, then rounds them off tothe 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 areprobably 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.

Volatile / non-volatile functions
The Open Document Format for Office Applications (OpenDocument) Version 1.2 includes thefollowing 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 adifferent random number. Calc recalculates the random number in A1, despite the user notchanging the formula in A1 and despite the updated B2 having no link to A1. In summary, theVolatile / non-volatile functions | 283

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 yourspreadsheet 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 anddoes 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 section entitled “Regularexpressions” in Chapter 1, Introduction.
If interoperability with Microsoft Excel is important for your spreadsheet, then you may not beable to fully utilize Calc’s regular expression facilities because Excel does not provide equivalentfacilities. Hence, when you export a Calc spreadsheet to Excel format, information relating toregular expressions will not be usable within 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. A wildcard is a special character that represents one or moreunspecified characters. Wildcards make text searches more powerful, but often less specific. The
wildcards available are ? (question mark), * (asterisk), and ~ (tilde). The usage of these wildcards
is the same as that for the Find and Replace dialog, described in Section 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)•

SEARCH284 | Chapter 7 Using Formulas and Functions

Configuration options are available in the Formulas wildcards section on the Tools > Options >LibreOffice Calc > Calculate dialog (Figure 247) to control the use of wildcards and regularexpressions 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.
By default, regular expression searches within Calc functions are case insensitive, irrespective of
the setting of the Case sensitive checkbox on the Tools > Options > LibreOffice Calc >Calculate dialog. 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.

Figure 247: Tools > Options > LibreOffice Calc > Calculate dialog

Tip
When both the Search criteria = and <> must apply to whole cells and Enablewildcards in formulas options are selected, Calc behaves exactly as Microsoft
Excel when searching cells in the database functions.
To illustrate some of the features of regular expressions, consider the simple spreadsheet shownin Figure 248 and assume that Enable regular expressions in formulas is selected on the
Tools > Options > LibreOffice Calc > Calculate dialog.

Using wildcards and regular expressions in functions | 285

Figure 248: 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, asshown in Figure 248. 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 cellA7. 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.
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 will not work in simple comparisons. For example: A1=“r.d” will always
return FALSE if A1 contains red, even if regular expressions are enabled. It will only return TRUE
if A1 contains r.d (r then a dot then d). If you wish to test using regular expressions, try the
COUNTIF function: COUNTIF(A1, “r.d”) will return 1 or 0, interpreted as TRUE or FALSE informulas like =IF(COUNTIF(A1, “r.d”), “hooray”, “boo”).
Activating the Enable regular expressions in formulas option means all the above functions
will require any regular expression special characters (such as parentheses) used in strings
within formulas to be preceded by a backslash, despite not being part of a regular expression.
These backslashes will need to be removed if the setting is later deactivated.

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 12, Macros. Macros can belinked to menus or toolbars for ease of operation or stored in template modules to make thefunctions available in other documents. Calc macros can be written in Basic, BeanShell,
JavaScript, or Python.
Calc Add-ins are specialized office extensions which can extend the functionality of LibreOfficewith new built-in Calc functions. A number of extensions for Calc have been written; these can be

286 | Chapter 7 Using Formulas and Functions

found on the extensions site at https://extensions.libreoffice.org/. Refer to Chapter 14, Setting up
and Customizing, for more details.

Advanced functions | 287

Calc Guide

Chapter 8
Using Pivot Tables

Introduction
Many requests for spreadsheet support are the result of using complicated formulas andsolutions to solve simple day-to-day problems. For more efficient and effective solutions, use thepivot table, a tool for combining, comparing, analyzing, and summarizing large amounts of data
easily. Using pivot tables, you can view different summaries of the source data, display thedetails of areas of interest, and create reports, whether you are a beginner, an intermediate, oran advanced user. Besides, you can create a pivot chart to view a graphical representation of thedata in a pivot table.

Database preconditions
To work with a pivot table, you need a list of raw data, similar to a database table, consisting ofrows (data sets) and columns (data fields). The field names are in the first row above the list.
The data source could be an external file or database. For the simplest case, where data is
contained in a Calc spreadsheet, Calc offers sorting functions that do not require the pivot table.
For processing data in lists, Calc needs to know where in the spreadsheet the list is. The list canbe anywhere in the sheet, in any position. A spreadsheet can contain several unrelated lists.
Calc recognizes your lists automatically. It uses the following logic: Starting from the cell you
have selected (which must be within the list), Calc checks the surrounding cells in all four
directions (left, right, above, below). The border is recognized if the program discovers an empty
row or column, or if it hits the left or upper border of the spreadsheet. This means that thedescribed functions can only work correctly if there are no empty rows or columns in the list.
Avoid empty lines (for example for formatting). You can format the list by using cell formats.

Tip
To make sure that Calc automatically recognizes a list correctly, check that there areno empty rows or empty columns within the list.
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 relatively common source of errors is to inadvertently declare a list by mistake and then to sortthat list. If you select multiple cells—for example, a whole column—then the sorting mixes up thedata that should be together in one row.
In addition to these formal aspects, the logical structure of the list is also very important.

Note
Calc lists must have the normal form; that is, they must have a simple linear
structure.
When entering the data, do not add outlines, groups, or summaries. Here are some mistakes
commonly made by inexperienced spreadsheet users:•

You made several unnecessary sheets; for example, a sheet for each group of articles. In
this case, analyses are only possible within each group.
Introduction | 289

•In a sales list, instead of only one column for the amount, you made a column for theamounts for each employee. In this case, the system will have difficulty grouping datafrom the various columns together. Thus, an analysis with the pivot table would no longer
be possible. All data must be entered into the same column for the pivot table to be able
to analyze it.

•

You entered the amounts in chronological order. At the end of each month, you made asum total. In this case, sorting the list for different criteria is not possible because thepivot table will treat the sum totals the same as any other value. Getting monthly results
is one of the very fast and easy features of the pivot table.

Data sources
The possible data sources for the pivot table are a Calc spreadsheet or an external data sourcethat 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 orapplication. 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 10, Linking Data,
for more information.
The behavior of Calc while inserting data from a different application depends on the format ofthe 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. Whenusing 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 sourcesin addition to databases that are created and maintained with LibreOffice Base. For more
information, see Chapter 10, Linking Data.

Using shortcuts
If you use pivot tables often in Calc, you might find the frequent use of the built-in menu paths
inconvenient.
In some cases built-in keyboard shortcuts are already defined; see Appendix A, Keyboard
Shortcuts. An example is the F12 function key, which groups a selected data range. In someother cases, the built-in toolbars already provide relevant icons. An example is the Insert or Edit
Pivot Table icon on the Standard toolbar.
In addition to using the built-in keyboard shortcuts and toolbar icons, you can also define yourown. See Chapter 14, Setting up and Customizing, for instructions.

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 all
relevant cells.
With the cell (or cells) selected, create the pivot table by selecting Insert > Pivot Table on the
Menu bar, selecting Data > Pivot Table > Insert or Edit on the Menu bar, or click the Insert orEdit Pivot Table icon on the Standard toolbar.
290 | Chapter 8 Using Pivot Tables

Calc displays the Select Source dialog (Figure 250), where you can choose between using theselected data cells, a range of cells that has already been named, or a data source that has
already been registered with LibreOffice.

Note
See Chapter 13, Calc as a Database, for more information about named ranges. See
Chapter 10, Linking Data, for more information about linking to registered data
sources.

Figure 249: Select Source dialog
Click OK on the Select Source dialog to display the Pivot Table Layout dialog, which is describedin the next section.

The Pivot Table Layout dialog
The function of the pivot table is managed in two places: first, in the Pivot Table Layout dialog;
and second, through manipulations of the result in the spreadsheet. This section describes the
Pivot Table Layout dialog in detail.

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 Menubar, or select Data > Pivot Table > Insert or Edit on the Menu bar, or click theInsert 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
In the Pivot Table Layout dialog (Figure 250) are four areas that show the layout of the resulting
pivot table:•

Filters•

Column Fields•

Row Fields•

Data Fields

Besides these four areas is another area labeled Available Fields containing the names of the
fields in the source data list. To choose a layout, drag and drop the fields from the Available
Fields area to the other four areas.
The Data Fields area must contain at least one field. Advanced users can use more than one
field here. For the fields in the Data Fields area, an aggregate function is used. For example, if
The Pivot Table Layout dialog | 291

you move the Sales Value field into the Data Fields area, it initially appears there as Sum –Sales Value.

Figure 250: 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 theorder 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
251).

Figure 251: Field order for analysis and resulting layout of pivot table292 | Chapter 8 Using Pivot Tables

Fields that are placed into the Filters area appear at the top of the resulting pivot table as a dropdown 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 toanother, press the Alt+letter on the keyboard that corresponds to the underlined letterin the target area’s label.

Note
By default, Calc inserts a Data field into the Column Fields area. The Data field canbe 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 buttonlabeled Data appearing in the results of the pivot table, affecting the layout of theresults. If you do not wish to use this facility, simply place the Data field at the bottomof the list of fields in its area.

More options
To expand the Pivot Table Layout dialog and show more options, click the expansion symbol(plus or triangle sign) adjacent to the Options and Source and Destination labels (Figure 252).
Ignore empty rows
If the source data is not in the recommended form, this option tells the pivot table to ignore
empty rows.

Figure 252: Expanded area of the Pivot Table Layout dialog
Identify categories
With this option selected, if the source data has missing entries in a list and does not meetthe recommended data structure (as in Figure 253 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).

The Pivot Table Layout dialog | 293

Figure 253: Example of data with missing
entries (blank/empty values) in Column A
The option Identify categories ensures that in this example rows 3 and 4 are included forApples and that row 6 is included for Pears (Figure 254).

Figure 254: Pivot table result with Identify categories selected
Without category recognition, the pivot table shows an (empty) category (Figure 255).

Figure 255: Pivot table result without Identify categories selected
Logically, the behavior with category recognition is better. A list showing missing entries isalso less usefulbecause 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 ofeach column, or if it adds on the very right a column with the sums of each row. In somecases, 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” on page 311.

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 adetailed 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 287). If this function is disabled, thedouble-click will keep its usual edit function within a spreadsheet. For more information,
see “Drilling (showing details)” on page 310.

294 | Chapter 8 Using Pivot Tables

Source
The Selection field in this area shows the sheet name and the range of cells containing theraw data for the pivot table. If the source spreadsheet contains any named ranges, thesecan 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 thenumber 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 theNamed 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.

More settings for the fields: Field options
The options discussed in the previous section are valid for the pivot table in general. You canalso change settings for any field that is currently included in the pivot table layout. Change afield’s settings by double-clicking that field within the Filters, Column Fields, Row Fields, or Data
Fields areas of the Pivot Table Layout dialog. Double-clicking a field within the Available Fields
area has no effect. The options available for fields in the Data Fields area differ from those forfields in the other three areas.

Options for data fields
Double-click a field in the Data Fields area of the Pivot Table Layout dialog to access the Data
Field dialog shown in Figure 256.
In the Data Field dialog, you can select the function to be used to accumulate the values from thedata source. While you often use the Sum function, other functions (like standard deviation or acounting function) are also available. For example, the counting function can be useful for nonnumerical data fields.
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.

The Pivot Table Layout dialog | 295

Figure 256: Expanded dialog for a data field
In the Displayed value section, you can choose other possibilities for analysis using theaggregate function. Depending on the setting for Type, you may have to choose definitions for
the Base field and Base item.

Figure 257: Example choices forBase field and Base item
Table 14 lists the possible types of displayed value and associated base field and base item,
together with notes on usage.
Table 14: Description of Displayed value options on the Data Field dialog
Type

Base field

Base item

Analysis

Normal——Simple use of the chosen aggregate
function (for example, Sum).

296 | Chapter 8 Using Pivot Tables

Type

Base field

Base item

Analysis

Difference
fromSelection of afield from thedata source ofthe pivot table(for example,
Employee).

Selection of anelement fromthe selectedbase field (forexample,Brigitte)

The result is the difference between the
result of the base field and the base item
(for example, sales volume of the other
employees against the sales volume ofBrigitte; see Figure 258).
If previous item or next item is
specified as the Base item, the reference
value is the result for the next visible
member of the base field, in the basefield’s sort order.

% of

Selection of afield from thedata source ofthe pivot table(for example,
Employee)

Selection of anelement fromthe selectedbase field (forexample,Brigitte)

The result is a percentage ratio of thevalue of the base field to the base item
(for example, sales result of the other
employees relative to the sales result of
Brigitte; see Figure 259).
If previous item or next item is
specified as the Base item, the reference
value is the result for the next visible
member of the base field, in the basefield’s sort order.

% difference
fromSelection of afield from thedata source ofthe pivot table(for example,
Employee)

Selection of anelement fromthe selectedbase field (forexample,Brigitte)

From each result, its reference value issubtracted, and the difference is divided
by the reference value (for example,
sales of the other employees as arelative difference from the sales ofBrigitte; see Figure 260).
If previous item or next item is
specified as the Base item, the reference
value is the result for the next visible
member of the base field, in the basefield’s sort order.

Running
total in

Selection of afield from thedata source ofthe pivot table(for example,
Date)

—

Each result is added to the sum of theresults for preceding items in the basefield, in the base field’s sort order, andthe total sum is shown.
Results are always summed, even if a
different summary function was used toget each result.

% of row——

The result is a percentage of the value ofthe whole row (for example, the row
sum).

% of column——

The result is a percentage of the total
column value (for example, the column
sum).

% of total——

The result is a percentage of the overall
result (for example, the total sum).

Index

—

—

(Default result x total result) / (row total x
column total)

The Pivot Table Layout dialog | 297

Figure 258: Original pivot table (top) and a Difference from example (bottom)

Figure 259: Example of a % of analysis

Figure 260: Example of % difference from analysis

Options for row and column fields
Double-click a field in the Row or Column Fields areas of the Pivot Table Layout dialog to accessthe Data Field dialog shown in Figure 261.
In the Data Field dialog for a row or column field, you can choose to show subtotals for eachcategory. 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.

298 | Chapter 8 Using Pivot Tables

Figure 261: Data Field dialog for a row or column field
Some examples are shown in Figures 262, 263, and 264.

Figure 262: No subdivision with only one row or column field

Figure 263: Division of the regions for employees (two row fields) without
subtotals
The Pivot Table Layout dialog | 299

Figure 264: 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 typeof subtotal you want to calculate from the list. Functions in this list are only available when Userdefined is selected.
Normally, the pivot table does not show a row or column for categories that have no entries in theunderlying database. By choosing the Show items without data option, you can force these to
be displayed.
For illustration purposes, the data was manipulated in such a way that the employee Brigitte has
no sales values for the Golf category.

Figure 265: Default setting

300 | Chapter 8 Using Pivot Tables

Figure 266: Setting Show items without data
Click the Options button on the Data Field dialog to access the Data Field Options dialog (Figure267). Use this dialog to specify additional options for fields in the Column and Row Fields areasof the Pivot Table Layout dialog.

Figure 267: Data Field Options dialog
The following options are provided:•

Sort by. Select the data field that you want to sort columns or rows by. Ascending sorts
the values from the lowest value to the highest value. If the selected field is the field forwhich 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. Similarly
Descending sorts the values descending from the highest value to the lowest value.
Manual sorts values alphabetically.

•

Display Options. You can specify the display options for all row fields except for the last,
innermost row field. Select from the Layout drop-down list to select the layout mode forthe field in the list box. Select the Empty line after each item option to add an empty
row after the data for each item in the pivot table. Select or deselect the Repeat item
labels option as required.
The Pivot Table Layout dialog | 301

•Show Automatically. This feature displays the top or bottom nn items when you sort bya 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. Select the hierarchy to use, when the field has multiple hierarchies. The pivot
table must be based on external source data that contains data hierarchies. For the
majority of users, Calc does not provide multiple hierarchies for a single field and so thisoption is normally grayed. If you use a pivot table data source extension, that extension
could define multiple hierarchies for some fields and then the option could become
available. See the documentation supplied with that extension for more details.

Options for filter fields
The Data Field dialog for fields in the Filters area is the same as for fields in the Row and
Column Fields areas, even though it appears to be useless to have the same settings as
described for the row and column fields. With the flexibility of the pivot table, you can switch thedifferent fields between filters, columns, or rows. The fields keep the settings that you gave them.
The filter field has the same properties as a row or column field. These settings only take effectwhen you use the field not as a filter field but as a row or column field.

Working with the results of the pivot table
The Pivot Table Layout dialog is very flexible and a pivot table can be totally restructured with
only a few mouse clicks.

Changing the layout
The layout of the pivot table can be changed quickly and easily by using drag-and-drop. With the
Pivot Table Layout dialog open, fields can be dragged around from Row Fields, Column Fields,
Filters, and Data Fields areas to any position you want to put them, and then dropped. Unused
fields can also be added, and fields removed in error can be replaced by dragging and droppingthem into the positions required.
Some manipulation can also be carried out in the results view of the pivot table. Within the resultsof the pivot table, drag one of the filters, column, or row fields to a different position. The cursor
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 268: Drag a column field - note thecursor shape

302 | Chapter 8 Using Pivot Tables

Figure 269: Result of dragging column field(see Figure 268)

Figure 270: Drag a row field - note the cursor
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 cursor changes to that shown in Figure 271. A field removed cannot berecovered, without returning to the Pivot Table Layout dialog to replace it.

Figure 271: Field dragged out of the pivot table

Grouping rows or columns of a pivot table
For many analyses or summaries, the categories have to be grouped. You can merge the results
in classes. You can only carry out grouping on an ungrouped pivot table.
After selecting the correct cell area, select Data > Group and Outline > Group on the Menu bar,or press F12 on the keyboard. The type of values to be grouped is what mainly determines how
the grouping function works. You need to distinguish between scalar values, or other values,
such as text, that you want grouped.

Working with the results of the pivot table | 303

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 androws and not on the size of the basic data. Through grouping, you can produce thepivot table with a small number of rows and columns. The pivot table can contain alot 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 begrouped. Choose Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard; Calc displays the Grouping dialog shown in Figure 272.
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 canenter the class size, also known as the interval size.

Figure 272: Grouping dialog with scalar
categories
Figure 273 shows part of a pivot table created from a list containing speed measurements as afunction of time. This pivot table shows the count of km/h speed measurements in the raw data.
The pivot table in Figure 274 is based on the same raw data. However in this case the speed
measurements are grouped into intervals of 10 km/h.

304 | Chapter 8 Using Pivot Tables

Figure 273: Pivot tablewithout grouping

Figure 274: Pivot tablewith grouping

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 begrouped. Choose Data > Group and Outline > Group on the Menu bar or press F12 on the
keyboard; Calc displays the Grouping dialog shown in Figure 275.

Figure 275: Grouping dialog for date/timecategories
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 canenter the class size, also known as the interval size. In this case, you can select one of thepredefined time intervals (Seconds, Minutes, Hours, Days, Months, Quarters, or Years) as analternative to explicitly specifying a time interval in days.
Figure 276 shows a pivot table configured to show the daily sales in the North region.

Working with the results of the pivot table | 305

Figure 276: Pivot table without grouping
Figure 277 shows the same data but configured to show the monthly sales in the North region.

Figure 277: Pivot table with grouping

Grouping without automatic creation of intervals
It is not possible to create intervals for some categories (for example, those containing text
fields). However, for such fields, it is possible to define which values are put together in one
group.
For grouping of these categories, select in the results of the pivot table all the individual fieldvalues that you want to put together in the group. With more than one cell selected, choose Data
> Group and Outline > Group on the Menu bar, or press F12 on the keyboard, to group theselected cells.
306 | Chapter 8 Using Pivot Tables

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 278, 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 279.

Figure 278: Database with text categories

Figure 279: 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 280.

Figure 280: 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 281.
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 willremember these settings, even if you change the layout later on.

Working with the results of the pivot table | 307

Figure 281: Grouping finishedTo add partial sums for the groups, right-click the results of the pivot table and select theProperties option. Double-click the Department2 entry in the Row Fields area and select the
Automatic option on the Data Field dialog (Figure 261). Click the two OK buttons and the pivot
table is updated to include the partial sums for the groups, as shown in Figure 282.

Figure 282: 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 tocollapse/expand the group entries (for example, Figure 283 shows both groups collapsed).

Figure 283: Reduced to the newgroupsNote
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, thathas 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) canbe 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 arepresented 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 orcolumn field (Figure 267).

308 | Chapter 8 Using Pivot Tables

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 arow or column field, and select one of the three sorting options (Figure 284):•

Sort Ascending•

Sort Descending•

Custom Sort

Figure 284: Column sortingand filtering dialog
Selecting the Custom Sort option sorts according to one of the predefined custom sorts definedin Tools > Options > LibreOffice Calc > Sort Lists. See Chapter 2, Entering, Editing, andFormatting 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 therequired individual boxes to select the data displayed in the results of the pivot table. Options areprovided to show all, show only the current item, or hide only the current item. Click OK toactivate the selected filtering. Once filtering has been carried out, the color of the arrow changes
from black to blue, and a small square of matching color is added to the bottom right of the arrow
button (Figure 285).

Figure 285: Arrow color change and indicator square on column heading

Working with the results of the pivot table | 309

Sort manually by using drag and drop
You can change the order within the categories by moving the cells with the category values in
the results of the pivot table. The dragged cell is inserted above the cell on which you drop it.
Be aware that in Calc, a cell must be selected, it is not enough that the cursor is in the cell. The
background of a selected cell is marked with a different color. To mark a single cell do one of thefollowing:•

Click, then Shift+click the cell.

•Press the mouse button, drag a range across two cells, do not release the mouse button,
and then drag back to the first cell. Release the mouse button. You can now move theindividual cell by drag and drop.

To select several cells, mark one cell with no extra key pressed, then press the Shift or Ctrl key
while clicking in other cells.

Sort automatically
To sort automatically, right-click within the pivot table and choose Properties. This will open the
Pivot Table Layout dialog (Figure 250). Double-click the row or column field you want to sort. In
the Data Field dialog which opens (Figure 261), click Options to display the Data Field Options
dialog (Figure 267).
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, theitems 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 (showing details)
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:•

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 286: 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.

310 | Chapter 8 Using Pivot Tables

Figure 287: Selecting the field for thesubdivision

Figure 288: After the drill down
To hide the details again, double-click on the cell Golf or choose Data > Group andOutline > 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.
•

The active cell is a data field. In this case, drill-down results in a listing of all data entriesof 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 286,
we would have a new list of all data sets that are included in this value. This list isdisplayed in a new sheet.

Figure 289: 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.

Working with the results of the pivot table | 311

Note
An AutoFilter or Standard Filter used on the sheet containing the raw data has noeffect 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 andselect 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 290: Filter button in the upper left area of the pivot table
In the Filter dialog (Figure 291), 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 theequivalent controls on Calc’s Standard Filter dialog – see Chapter 2, Entering, Editing, andFormatting Data for more information.

Figure 291: Dialog for defining the filter
The data presented in a pivot table can also be filtered using the drop-downs on the right handside 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” on page 309.
Filter fields (that is, fields that you placed in the Filters area of the Pivot Table Layout dialog) areanother 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 accessthe associated filtering dialog (Figure 292).

312 | Chapter 8 Using Pivot Tables

Figure 292: Filter field filtering dialog
The text adjacent to a filter field button indicates the filtering status, that is “- all -” when nothing isfiltered, “- 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-clickin the results area and choose Data > Pivot Table > Refresh on the Menu bar, or rightclick 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 newsale from a different employee was inserted), it is possible to update the pivot table bychanging the range in the Selection field in the Source area of the Pivot Table Layout
dialog. It means, for a fundamental changes to the data set collection, you must redo thepivot table from the beginning.

Cell formatting
The cells in the results area of the pivot table are automatically formatted by Calc. You canchange this formatting using all the tools in Calc. However, if you make any change in the designof the pivot table using direct formatting, the formatting will return to that applied automatically by
Calc when the table is next 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. You cancustomize these pivot table styles. The pivot table styles are:•

Pivot Table Category•

Pivot Table Corner•

Pivot Table Field

Working with the results of the pivot table | 313

•Pivot Table Result•

Pivot Table Title•

Pivot Table ValueTip
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.
For the number format in the data field, Calc uses the number format that is used in thecorresponding cell in the source list. In most cases, this is useful (for example, if the values are in
the currency format, then the corresponding cell in the result area is also formatted as currency).
However, if the result is a fraction or percentage, the pivot table does not recognize that thismight be a problem; such results must either be without a unit or be displayed as a percentage.
Although you can correct the number format manually, the correction stays in effect only until thenext update.

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 thecontext menu.

CautionIf you delete a pivot table with an associated pivot chart, the pivot chart is alsodeleted. 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 thevalue. 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 wascalculated by referencing specific categories of the row and column fields. In Figure 293, cell C6
contains the sum of the sales values of the employee Hans in the category Sailing. The formulain cell C12 uses this value.

Figure 293: Formula reference to a cell of the pivot table314 | Chapter 8 Using Pivot Tables

If the underlying data or the layout of the pivot table changes, then you must take into accountthat 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 294, the location is now C7.

Figure 294: The value that you really want to use can befound 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.

SyntaxThe 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 yourpivot table has only one data field, this entry is ignored, but you must enter it anyway.
If your pivot table has more than one data field, then you have to enter the field name from theunderlying data source (for example “Sales Value”) or the field name of the data field itself (forexample “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 thatyou 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 295, where we want to get the partial sum of Hans for Sailing, theformula in cell C12 would look like this:Using pivot table results elsewhere | 315

=GETPIVOTDATA("Sales
Value",A1,"Employee","Hans","Category","Sailing")

Figure 295: 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 thepivot 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 ofField name[Element].
In the example in Figure 296, where we want to get the partial sum of Hans for Sailing, theformula in cell C12 would look like this:=GETPIVOTDATA(A1,"Sales Value Employee[Hans] Category[Sailing]")

Figure 296: Second syntax variation
When working with data sets containing date information, you must take care if you use the date
information in the GETPIVOTDATA() function. The function will only recognize the date entry if it
is entered into the formula in exactly the same way that it appears in the data set from which thepivot table is produced. In the example of Figure 297, an error is returned when the date format
does not match that of the data. Only with the correct format is the result returned.

316 | Chapter 8 Using Pivot Tables

Figure 297: Error produced if date information is not entered correctly

Using pivot charts
Introduction
A pivot table is a powerful tool to reorganize, manipulate and summarize data. A pivot chart
provides a visual representation of the information in a pivot table. You can create a pivot chartfrom 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 chart buttons are provided on pivot charts. These buttons are unique to pivot charts
and are not provided on Calc’s normal charts. An important purpose of the buttons is torepresent the layout of the underlying pivot table and they show the pivot table’s fields.
Buttons representing the filter fields (if present) are provided at the top of the pivot chart.
Buttons representing the row fields are provided at the bottom of the pivot chart. Buttons
representing the column fields are stacked in the legend at the right of the pivot chart.
You can also use pivot chart buttons to filter the data displayed in the pivot chart.

Using pivot charts | 317

Figure 298: Sample pivot chart and associated pivot table

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.
The first step in the wizard is to select the chart type and the same options are available as for anormal chart (Figure 299).

318 | Chapter 8 Using Pivot Tables

Figure 299: 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 300).

Figure 300: 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
After you have created a pivot chart, you may find that you would like to move it, change its size
or improve its appearance. 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 thoseavailable 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.
Using pivot charts | 319

Filtering a pivot chart
Use filters to remove unwanted data from a pivot chart.
All filters applied to a pivot table affect any linked pivot chart equally, since the table and chartshow exactly the same data. The various pivot table filtering mechanisms are described in“Filtering” on page 311.
Pivot chart buttons include a down arrow to indicate that there is an associated pop-up action. If
any filtering is applied, then this arrow turns from black to blue. Pivot chart buttons become
operational when you double-click on the chart and a gray frame appears around the chart. Thisaction puts the pivot chart into edit mode.
Click a filter field button located at the top of a pivot chart to access a filtering dialog similar tothat shown in Figure 292. Change the filtering applied to the pivot table and pivot chart throughthis dialog. The right-hand section of the button’s legend 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.
Buttons located at the bottom and right of a pivot chart that include a downward pointing arrowprovide access to a sorting and filtering dialog similar to the one shown in Figure 284. Change
the sorting and filtering applied to the pivot table and pivot chart through this dialog.

Figure 301: 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.

CautionIf you delete a pivot table with an associated pivot chart, the pivot chart is alsodeleted. Calc opens a dialog box to confirm the pivot table deletion.

320 | Chapter 8 Using Pivot Tables

Calc Guide

Chapter 9
Data Analysis
Using Scenarios, Goal Seek, Solver, Statistics, others

Introduction
Once you are familiar with functions and formulas, the next step is to learn how to use Calc’s
automated processes to quickly perform useful analysis of your data.
In addition to formulas and functions, Calc includes several tools for processing your data. These
tools include features for copying and reusing data, creating subtotals, running what-if analysis,
and performing statistical analysis. They can be found under the Tools and Data menus on the
Menu bar. Although they are not necessary when using Calc, they can help you save time andeffort with handling large data sets or preserving your work for future review.

Note
A related tool, the Pivot Table, is not mentioned here, as it is complex enough torequire its own chapter. See Chapter 8, Using Pivot Tables, for more information.

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 forreview. 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 302).
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 deletionis 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 (numbersonly), 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 theminto reusable named ranges to make the process easier. For more information about
named ranges, see Chapter 13, Calc as a Database.

322 | Chapter 9 Data Analysis

Figure 302: Consolidate dialog

Consolidation settings
In the Consolidate dialog, expand the Options section to access the settings shown in Figure
303.

Figure 303: 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
themselves to be combined.
– Row labels – Consolidates rows by matching label. If this option is unchecked, thetool 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 inthe source ranges. When you select this option, any changes you make in the source
ranges will automatically update values in the target range.
Consolidating data | 323

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 aredisplayed by default.

Consolidation example
Figures 304, 305, and 306 show a simple example of consolidation using a spreadsheet with the
sheets Year 1, Year 2, and Consolidated Sales. Figure 304 shows the contents of the Year 1
sheet, with sales figures by region for each of the four product colors.

Figure 304: Year 1 sales by region
Figure 305 shows the Year 2 sheet, sales figures by region for each of four product colors. Notethe different ordering of row and column labels between the two figures.

Figure 305: Year 2 sales by region
Figure 306 shows the consolidated sales data, created by using the Consolidate dialog settings
shown in Figure 303. 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 adocument with consolidated ranges, they will still be available in the Consolidation ranges list of
the Consolidate dialog.

324 | Chapter 9 Data Analysis

Figure 306: 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, andthe Functions deck of the Sidebar, which are described in Chapter 7, Using Formulas andFunctions. 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 Figure307. 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, Editing,and Formatting Data.

Figure 307: 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 308):– Select Insert > Function on the Menu bar– Click the Function Wizard icon on the Formula bar– Press Ctrl+F2

Creating subtotals | 325

Figure 308: 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 eachvalue shown in Table 15.

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, Editing, andFormatting Data. Filtered-out cells are always excluded by the SUBTOTAL function.
Table 15: SUBTOTAL function numbers
Function index(includes hidden values)

Function index(ignores hidden values)

Function

1

101

AVERAGE

2

102

COUNT

3

103

COUNTA

4

104

MAX

5

105

MIN

326 | Chapter 9 Data Analysis

Function index(includes hidden values)

Function index(ignores hidden values)

Function

6

106

PRODUCT

7

107

STDEV

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 thecells with your mouse (Figure 308). Use the Shrink / Expand button if you need totemporarily 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 Standard Filter area except those next to Brigitte and (empty). The cellthat you selected in step 1 should now reflect the sum of all of Brigitte’s sales (Figure
309).

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 309: SUBTOTAL result for Brigitte’s sales

Using 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:

Creating subtotals | 327

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 310).
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 thiscolumn.
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 automaticallyrecalculate 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 Groupby list for each page set to “- none -”.
8) Click OK. Calc will add subtotal and grand total rows to your cell range.

Figure 310: Subtotals dialog
For our sales data example, a partial view of the results is shown in Figure 311. The groupsettings are identified in Table 16.
Table 16: Group settings used on Subtotals dialog for example sales data
Tab

Group byCalculate
subtotals for

Use function

1st Group

Employee

Sales ValueSum

2nd Group

Category

Sales ValueSum

3rd Group- none ---328 | Chapter 9 Data Analysis

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 be used to hide orshow 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, suchas individual entries, to produce a high-level summary of your data. For more information on how
to use outlines, see Chapter 2, Entering, Editing, and Formatting Data.
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 311 shows the outline for our sales data example.

Figure 311: Partial outlined view of sales data example with subtotals
Column 1 represents the highest group level, the grand total over all employees. Columns 2 to 5
show descending group levels as follows:•

Column 2 represents the grand total over all categories.
Creating subtotals | 329

•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:
GroupsDefines how subtotal data is organized.
– Page break between groups – inserts page breaks between each subtotal group sothat 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 bycase. In our sales data example, entries with “Brigitte” and “brigitte” under the
Employee column will not match if this option is selected.
– 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” inbetween them.

Figure 312: Options tab of the Subtotals dialog
Sort
Defines how subtotal data is sorted. This section is disabled if Pre-sort area according togroups is unchecked.
– Ascending or Descending – sorts entries by value from lowest to highest andhighest to lowest, respectively. You can modify these sort rules by using Data > Sort
on the Menu bar. For more detail, see Chapter 2, Entering, Editing, and Formatting
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, Editing, and Formatting
Data.
330 | Chapter 9 Data Analysis

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 dialogs will be displayed.

Using scenarios
Scenarios are saved, named cell ranges that you can use 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 foryou.

Creating scenarios
To create a new scenario:
1) Select the cells that contain the values that will change between scenarios. To selectmultiple 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 (Figure313).

Figure 313: Create Scenario dialog
3) Enter a name for the new scenario in the Name of Scenario field.

Using scenarios | 331

Tip
For each scenario you create, use a unique name that clearly identifies anddistinguishes it. This practice will save you time and headache if you have to workwith a large set of scenarios. We do not recommend using the default namesuggested by Calc.
4) Optionally, add information to the Comment field. The example in Figure 313 shows thedefault 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 what calculations are dependent on your scenarios, use Tools >Detective > Trace Dependents on the Menu bar after highlighting your scenario
cells. Arrows will point from your scenario cells to the dependent formula cells. For
more information about the Detective tool, see Chapter 7, Using Formulas andFunctions.

Scenario settings
The Settings section of the Create Scenario dialog contains the following options:Figure 314: Create Scenario dialog – Settings section
Display border
Places a colored border around the cell range that contains your scenario (Figure 315).
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 canswap to another scenario by selecting it in this list.

332 | Chapter 9 Data Analysis

Figure 315: Scenario cell range withborderCopy backCopies 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 andthe Prevent changes setting (see Table 18 on page 334).

CautionWhen 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 isprotected. This option and its effects are more fully explained in the next section.

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, Editing, and Formatting Data.

Changing scenario properties
Table 17 summarizes how sheet protection and the Prevent changes option affect your ability tochange scenario properties.

Using scenarios | 333

Table 17: Changing scenario properties
Sheet
protection

Preventchanges

Property changes

On

On

No scenario properties can be changed.

On

Off

Display border and Copy back can be changed.
Prevent changes and Copy entire sheet cannot bechanged.

Off

Any setting

All scenario parameters except for Copy entire sheet canbe changed. In this case, the Prevent changes option
has no effect.

Changing scenario cell values
Table 18 summarizes the interaction of various settings in making changes to scenario cellvalues.
Table 18: Changing scenario cell values
Sheet
Scenario cell
Prevent
protection
protectionchanges

Copy backChange allowed

On

Off

On

On

Scenario cell values cannot bechanged.

On

Off

Off

On

Scenario cell values can bechanged, and the scenario is
updated.

On

Off

Any setting

Off

Scenario cell values can bechanged, but the scenario is not
updated due to the Copy backsetting.

On

On

Any setting

Any setting

Scenario cell values cannot bechanged.

Off

Any setting

Any setting

Any setting

Scenario cell values can bechanged and the scenario is
updated or not, depending on
the Copy back setting.

Working with scenarios using the Navigator
After you add scenarios to a spreadsheet, you can view a particular scenario by using theNavigator. Open it by selecting View > Navigator on the Menu bar, then click on the Scenarios
icon in the Navigator and select a scenario in the list (Figure 316). Any defined scenarios arelisted along with the comments that were entered when each scenario was created. You can also
use the equivalent facilities in the Navigator deck of the Sidebar. For more information about the
Navigator, see Chapter 1, Introduction.
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 Delete
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 313).

334 | Chapter 9 Data Analysis

Figure 316: Scenarios in the Navigator

Using the Multiple Operations tool
Like scenarios, the Multiple Operations tool performs what-if analysis on your calculations. Unlike
scenarios, which represent individual sets of values for multiple formula variables, this tool uses awhole range of values for just one or two variables. It then uses one or more formulas to create amatching range of solutions. Since each solution corresponds to one or two variable values, boththe variable and solution ranges can be easily arrayed in tabular format. As a result, the Multiple
Operations tool is well-suited to generating data that is easy to read and share or visualize usinggraphs.

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 easiest way to learn how to use the Multiple Operations tool is with one formula and one
variable. To learn how to use the tool with multiple formulas or with two variables, see“Calculating with several formulas simultaneously” (page 338) and “Multiple operations with two
variables” (page 340), respectively.
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 will be used for one of the variables of the formula that you defined instep 1.
3) With the mouse, select the range containing both the variable range that you defined instep 2 and the adjacent empty cells that follow it. Depending on how your variable range

Using the Multiple Operations tool | 335

is arrayed, these empty cells will either be in the column to the right (if the range is in acolumn) 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 317).

Figure 317: 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 needto 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 themouse. 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 toysthat you sell for $10 each (cell B1 of a worksheet). Each toy costs $2 to make (B2), and you havea 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).
To answer this question:
1) Enter the following formula into B5: =B4*(B1-B2)-B3. This formula represents theequation 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 alternatequantity 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.
6) Using the Column input cell field, select the cell B4 to set the quantity as the variable forour calculations. Figure 318 shows the worksheet and Multiple Operations dialog at thispoint.

336 | Chapter 9 Data Analysis

Figure 318: Inputs to Multiple Operations tool for one formula, one variable
7) Click OK. The profits for the different quantities are now shown in column E (Figure 319).
We can see that the break-even point is between 1000 and 1500 toys sold – namely,
1250. Figure 319 shows an XY (Scatter) chart showing the profit as a function of quantity.

Figure 319: Results of Multiple Operations tool for one formula and one variable

Using the Multiple Operations tool | 337

Figure 320: XY (Scatter) plot of profit over quantity of toys sold (example of visualization)

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 theresults 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 inthat order, then Calc will generate the results of A in the first results table column, theresults 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 orcolumn, depending on how your results table is oriented. If the table is columnoriented – 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 acolumn.

CautionBe 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 enoughrows 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 soldin 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 peritem sold.
3) Select the range D2:F11 for the results table. Column F will contain the results of theannual profit per item formula in C5.

338 | Chapter 9 Data Analysis

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 321 shows the worksheet andthe dialog at this point.

Figure 321: Inputs to Multiple Operations tool for one variable and two
formulas7) Click OK. Now the profits are listed in column E and the annual profit per item in column
F.

Figure 322: Results of Multiple Operations tool for one variable and two formulas

Using the Multiple Operations tool | 339

Multiple operations with two variables
When you use the Multiple Operations tool with two variables, it creates a two-dimensional
results table. Each variable defines one of the table’s dimensions such that the alternate values
for both variables serve as the table’s row and column headings, respectively. Each cell in thetable corresponds to a distinct pair of row and column heading values. In turn, the results in eachcell are created from these values for both variables.
Since you are using two variables, you must use both the Column input cell and Row input cell
dialog fields to define them. The order is important; the Column input cell field corresponds to therow heading values, while the Row input cell field corresponds to the column heading values.

Tip
A good guideline to remember is that since column headings are in a row at the topof the table, they correspond to the Row input cell field. Likewise, row headings arein 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 theexpected 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 323 shows
the worksheet and dialog at this point.
7) Click OK. The profits for the different sale prices and quantities are now shown in therange E2:H11 (Figure 341).

340 | Chapter 9 Data Analysis

Figure 323: Inputs to Multiple Operations tool for two variables

Figure 324: Results of Multiple Operations tool for two variables

Using Goal Seek
In addition to scenarios and the Multiple Operations tool, Calc has a third “what-if” analysis tool:
Goal Seek. Usually, you use a formula to calculate a result from existing values. In contrast, with
Goal Seek, you work backwards from a result to discover what values produce it. This feature isuseful if you already know the outcome you want, but need to answer questions such as how toreach it or how it could be changed if you altered 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.

Using Goal Seek | 341

Goal Seek example
To illustrate how to use Goal Seek, suppose that we want to calculate the annual interest returnfor 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.
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 325).

Figure 325: 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 mouseto 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 is15000. Figure 326 shows the cells and dialog fields at this point.

Figure 326: Example setup for goal seek6) Click OK. A dialog appears informing you that the goal seek was successful (Figure 327).

342 | Chapter 9 Data Analysis

Figure 327: Goal seek result dialog
7) Click Yes to enter the goal value into the variable cell. The result is shown in Figure 328,
indicating that a capital requirement of $200,000 is needed to achieve a $15,000 return.

Figure 328: Result of goal seek inworksheet

Note
Not every goal seek problem succeeds in returning a good result. It depends on theformula used, goal value, and initial value. The goal seek algorithm iterates internallyseveral 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
The Solver amounts to a more elaborate form of goal seek, which allows you to solve
mathematical programming or optimization problems. A mathematical programming problem isconcerned with minimizing or maximizing a function subject to a set of constraints. Suchproblems arise in many scientific, engineering, business, and other disciplines. A full discussionof mathematical programming is beyond the scope of this guide and the interested reader isreferred to the relevant Wikipedia page athttps://en.wikipedia.org/wiki/Mathematical_optimization, which provides high level information
and references to more detailed materials.
Currently 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).

Using the Solver | 343

CautionAs 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 intended for solving non-linear problems - they
are only available if you have a Java runtime environment installed on your computer and haveenabled the Tools > Options > LibreOffice > Advanced > Use a Java runtime environment
configuration option. The DEPS Evolutionary Algorithm is the initial default if it is available, while
LibreOffice CoinMP Linear Solver is the initial default otherwise.
The available options provide flexibility to choose the most suitable algorithm for a given problem,
which may be linear or non-linear, and a given performance requirement. The Help system
contains much more information about the available algorithms and their configuration options.
In order to use the Solver to solve a mathematical programming problem, you must formulate theproblem 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 andmaximize or minimize the result of the objective function.

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 329).

Note
Depending on the configuration of your computer, a message may be displayed thefirst time that you select Tools > Solver after starting Calc. The nature of thismessage 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 tothat 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 theminimum result, or Value of to set it to a specific value. If you select Value of, enter therequired 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.

344 | Chapter 9 Data Analysis

– Operator – defines a parameter for a constraint. Available options include <= (lessthan 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.

Figure 329: 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.
Once you have finished setting up the Solver, click the Solve button to begin the process ofadjusting values and calculating results. Depending on the complexity of the task, this may takesome time. If you want to start again, click the Reset All button and the data inserted in the
Solver dialog (Figure 329) will be cleared.
On successful completion, Calc presents a Solving Result dialog (Figure 330). This dialog
includes buttons to save (Keep Result) or discard (Restore Previous) your results.

Figure 330: Solving Result dialog
The Solver dialog also has an Options button, which opens the Options dialog shown in Figure
331.
Using the Solver | 345

Solver options

Figure 331: Solver Options dialog
Solver engine
With the standard LibreOffice 7.0 download, and an enabled Java runtime environment, theSolver 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 selectedsolver engine, and the options available vary between engines.

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 incells 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 FundX.
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.
346 | Chapter 9 Data Analysis

– 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 332 shows
the worksheet at this point.

Figure 332: Solver example setup
3) Select Tools > Solver on the Menu bar to open the Solver dialog (Figure 329).
4) 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.
5) 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.
6) Using the By changing cells field, select cell C2 in the sheet. In this example, you need tofind the amount invested in Fund X (cell C2).
7) 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 amountavailable.
– C2 => 0 – the amount invested in Fund X cannot be negative.
– C2 is an Integer – specified for convenience.
8) Click Solve. The result is shown in Figure 333.

Figure 333: Solver example result

Using Statistics tools
Under Data > Statistics on the Menu bar, Calc features several tools for quick and easystatistical analysis of your data. These tools include:•

Sampling•

Descriptive Statistics•

Analysis of Variance (ANOVA)•

Correlation•

Covariance•

Exponential Smoothing•

Moving Average•

Regression•

Paired t-test
Using Statistics tools | 347

•F-test•Z-test•

Test of Independence (Chi-square)•

Fourier Analysis

Sampling tool
The Sampling tool creates a target table with data sampled from a source table. The sampling
tool can pick samples randomly or on a periodic basis. Sampling is done row-wise, with wholerows of the source table copied into rows of the target table. To use this tool, select Data >Statistics > Sampling on the Menu bar to access the Sampling dialog (Figure 334).

Figure 334: Sampling dialog
Input range
Specifies the cell range containing the source table.
Results toSpecifies 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.
RandomEnables 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, themaximum value that can be entered in this field is limited to the number of rows in thesource table.
With replacement
If this option is selected, a sample drawn from the source table is effectively returned andso is eligible for re-sampling later. In this case, the sample size can be larger than thenumber of rows in the source table. If the option is deselected, a sample drawn from thesource table is not eligible for re-sampling later. In this case, the sample size is limited to348 | Chapter 9 Data Analysis

the number of rows in the source table. This option is automatically deselected for periodic
sampling. It is not possible to have both With replacement and Keep order options
selected simultaneously.
Keep order
If this option is selected, samples are drawn from the source table in order of the data inthe 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 bothWith replacement and Keep order options selected simultaneously.
Periodic
Enables periodic sampling mode when selected.
PeriodDefines 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,
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 thesource table.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
Figure 335 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 334.

Figure 335: Example data for the
Sampling tool

Descriptive Statistics tool
Given a set of data, the Descriptive Statistics tool creates a tabular report of the data set’s
primary statistical properties, such as information about its central tendency and variability. SelectData > Statistics > Descriptive Statistics on the Menu bar to access the Descriptive Statistics
dialog (Figure 336).

Using Statistics tools | 349

Figure 336: Descriptive Statistics dialog
Input range
Specifies the cell range containing the source data.
Results toSpecifies 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.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
Figure 337 shows a small data set comprising student examination results in three subjects.

Figure 337: Input data fordescriptive statistics analysis
Figure 338 shows the statistics report generated for this input data using the settings shown in
Figure 336.

350 | Chapter 9 Data Analysis

Figure 338: 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
The Analysis of Variance (ANOVA) tool compares the means of two or more groups in a sample.
Select Data > Statistics > Analysis of Variance (ANOVA) on the Menu bar to access theAnalysis of Variance (ANOVA) dialog (Figure 339).

Figure 339: Analysis of Variance (ANOVA) dialog

Using Statistics tools | 351

Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will fill out theanalysis of variance report table starting at this cell.
Single / 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.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we use the input data set from Figure 337. Figure 340 shows theanalysis of variance results generated for this data using the settings shown in Figure 339.

Figure 340: 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.

Correlation tool
The Correlation tool calculates the correlation of two sets of numeric data and generates theresulting correlation coefficient. This coefficient is a value between -1 and +1 that indicates how
strongly two variables are related to each other. A correlation coefficient of +1 indicates a perfect
positive correlation (the data sets match) and a coefficient of -1 indicates a perfect negative
correlation (the data sets are inverse to each other). Select Data > Statistics > Correlation on
the Menu bar to access the Correlation dialog (Figure 341).

352 | Chapter 9 Data Analysis

Figure 341: Correlation dialog
Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will fill out thecorrelation coefficient table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 337. Figure 342 shows
the six correlation coefficients generated for this input data using the settings shown in Figure
341.

Figure 342: Correlation results

Tip
For more information on statistical correlation, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Correlation_and_dependence.

Using Statistics tools | 353

Covariance tool
The Covariance tool measures how much two sets of numeric data vary together. Select Data >Statistics > Covariance on the Menu bar to access the Covariance dialog (Figure 343).

Figure 343: Covariance dialog
Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will fill out thecovariance table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 337. Figure 344 shows
the six covariance values generated for this input data using the settings shown in Figure 343.

Figure 344: Covariance results

Tip
For more information on statistical covariance, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Covariance.

354 | Chapter 9 Data Analysis

Exponential Smoothing tool
The Exponential Smoothing tool filters a data set to produce smoothed results. It is used indomains such as stock market analysis and in sampled measurements. Select Data > Statistics> Exponential Smoothing on the Menu bar to access the Exponential Smoothing dialog (Figure
345).

Figure 345: Exponential Smoothing dialog
Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will generatesmoothed results starting at this cell.
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.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we use the data set shown in Figure 346. The table has two timeseries representing impulse functions at times t=0 and t=2.

Using Statistics tools | 355

Figure 346: Input data set for
exponential smoothing
exampleFigure 347 shows the smoothed results for this input data using the settings shown in Figure 345.

Figure 347: Results from
Exponential Smoothing tool

Tip
For more information on exponential smoothing, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Exponential_smoothing.

356 | Chapter 9 Data Analysis

Moving Average tool
The Moving Average tool calculates the moving average of a time series data set. Select Data >Statistics > Moving Average on the Menu bar to access the Moving Average dialog (Figure
348).

Figure 348: Moving Average dialog
Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will generate themoving 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 valueis 2).

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 346. Figure 349 shows
the moving averages calculated for this input data using the settings shown in Figure 348.

Using Statistics tools | 357

Figure 349: Calculated
moving averages

Tip
For more information on the moving average, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Moving_average.

Regression tool
The Regression tool analyzes the relationship in a data set between one or more independent
variables and a dependent variable. Select Data > Statistics > Regression on the Menu bar toaccess the Regression dialog (Figure 350).
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 toSpecifies the top left cell of the results area. When you run the tool, it will generate theregression analysis table starting at this cell.
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 straight line in the formof y = (a * x) + b that best fits the data, where a is the slope and b is the intercept.
Logarithmic Regression
Select this option to use logarithmic regression. Logarithmic regression finds a logarithmic
curve in the form of y = (a * ln(x)) + b that best fits the data, where a is the slope, b
is the intercept and ln(x) is the natural logarithm of x.
Power Regression
Select this option to use power regression. Power regression finds a power curve in theform of y = (a * x) ^ b that best fits the data, where a is the coefficient and b is the
exponent.

358 | Chapter 9 Data Analysis

Confidence level
Specifies the confidence level, which is a value between 0 and 1. The default value is 0.95.
Calculate residuals
Specifies whether to calculate residuals.
Force intercept to be zero
Specifies whether to force the regression intercept to be 0.

Figure 350: Regression dialog

Tip
Use the Shrink / Expand buttons next to the Independent variable(s) (X) range,
Dependent variable (Y) range, and Results to fields if you need to shrink the dialog
while selecting cells with the mouse.

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, thetext “Independent variable(s) range is not valid.” appears if you have not entered avalid cell range in the Independent variable(s) (X) range field, and in thiscircumstance the OK button is grayed.

Using Statistics tools | 359

To illustrate how to use this tool, we use the data set shown in Figure 351. This table contains
measurements taken at 1 second intervals.

Figure 351: Input data
set for regression
analysis
Figure 352 shows the regression outputs calculated for this input data using the settings shownin Figure 350.

Tip
For more information on regression analysis, refer to the corresponding Wikipedia
article at https://en.wikipedia.org/wiki/Regression_analysis.

360 | Chapter 9 Data Analysis

Figure 352: Linear regression outputs

Paired t-test tool
The Paired t-test tool compares the population means of two related sample sets and determines
the difference between them. Select Data > Statistics > Paired t-test on the Menu bar to accessthe Paired t-test dialog (Figure 353).
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 toSpecifies the top left cell of the results area. When you run the tool, it will generate thepaired t-test table starting at this cell.

Using Statistics tools | 361

Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Variable 1 range, Variable 2 range, andResults to fields if you need to shrink the dialog while selecting cells with the mouse.

Figure 353: Paired t-test dialog
To provide an example of using this tool, we make use of the input data set shown in Figure 354.
The data sets in columns A and B represent two sets of paired values referred to as Variable 1
and Variable 2.

Figure 354: Input data forpaired t-test example
Figure 355 shows the paired t-test results calculated for this input data using the settings shownin Figure 353.
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.

362 | Chapter 9 Data Analysis

Tip
For more information on paired t-tests, refer to the corresponding Wikipedia article athttps://en.wikipedia.org/wiki/Student's_t-test.

Figure 355: Results from Paired t-test tool

F-test tool
The F-test tool calculates the F-test of two data samples. The tool is used to test the hypothesisthat the variance of two populations are equal. Click Data > Statistics > F-test on the Menu bar
to access the F-test dialog shown in Figure 356 and define the required inputs to the tool.

Figure 356: 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 toSpecifies the top left cell of the results area. When you run the tool, it will generate the Ftest table starting at this cell.
Using Statistics tools | 363

Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Variable 1 range, Variable 2 range, andResults to fields if you need to shrink the dialog while selecting cells with the mouse.
To illustrate how to use this tool, we again use the data set from Figure 354. In this case, the datain columns A and B represent two independent sample sets, referred to as Variable 1 andVariable 2. Figure 357 shows the F-test results calculated for this input data using the settings
shown in Figure 356.

Figure 357: Results from F-test tool
It is possible to insert different values for Alpha. The F Critical values (right-tail, left-tail, and twotail) will be updated automatically.

Tip
For more information on F-tests, refer to the corresponding Wikipedia article athttps://en.wikipedia.org/wiki/F-test.

Z-test tool
The Z-test tool calculates the Z-test of two data samples. The tool 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 for large samples (n > 30); if you are using a small sample, the Paired ttest tool may be more appropriate. Click Data > Statistics > Z-test on the Menu bar to accessthe z-test dialog shown in Figure 358 and define the required inputs to the tool.
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 toSpecifies the top left cell of the results area. When you run the tool, it will generate the Ztest table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
364 | Chapter 9 Data Analysis

Tip
Use the Shrink / Expand buttons next to the Variable 1 range, Variable 2 range, andResults to fields if you need to shrink the dialog while selecting cells with the mouse.

Figure 358: z-test dialog
To provide an example of using this tool, we again make use of the input data set shown in
Figure 354. In this case the data in columns A and B represent two data sets, referred to as
Variable 1 and Variable 2. Figure 359 shows the Z-test results calculated for this input data using
the settings shown in Figure 358.

Figure 359: Results from Z-test tool
For the Z-test tool to work properly, a known variance for each sample must be inserted in therelated cell. In the example shown in Figure 359, 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 describedabove, after changing the Alpha and the Hypothesized Mean Difference, the subsequent z and P
values will be updated automatically.

Using Statistics tools | 365

Tip
When analyzing the Z-test results, compare the selected Alpha level with theappropriate calculated P value (depending whether a one-tailed or two-tailed test isrequired). 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.

Tip
For more information on z-tests, refer to the corresponding Wikipedia article athttps://en.wikipedia.org/wiki/Z-test.

Test of Independence (Chi-Square) tool
The Test of Independence (Chi-Square) 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.
Select Data > Statistics > Chi-square Test on the Menu bar to access the Test of Independence(Chi-Square) dialog (Figure 360).
Input range
Specifies the cell range containing the source data.
Results toSpecifies the top left cell of the results area. When you run the tool, it will generate the Chisquare table starting at this cell.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.

Figure 360: 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 354. In this case the data in column A is the observed data while the data in column B are
the corresponding expected values. Figure 361 shows the chi-square results calculated for this
input data using the settings shown in Figure 360.

366 | Chapter 9 Data Analysis

Figure 361: Results of chi-square test
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.

Fourier Analysis tool
The Fourier Analysis 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. Select Data > Statistics > Fourier Analysis on the Menu bar to access theFourier Analysis dialog (Figure 362).

Figure 362: Fourier Analysis dialog
Input range
Specifies the cell range containing the source data. A 2 x N or N x 2 range representing anarray 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 toSpecifies the top left cell of the results area. When you run the tool, it will generate theFourier transform table starting at this cell.
Using Statistics tools | 367

Input range has label
Specifies whether the first row or column of the input array is a label and not part of thedata to be analyzed.
Columns / Rows
Specifies whether the data to be analyzed is organized in columns or rows.
InverseIf 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 suppressedwith 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. By
providing a suitable value to this parameter, these non-existent frequency components canbe suppressed.

Tip
Use the Shrink / Expand buttons next to the Input range and Results to fields if you
need to shrink the dialog while selecting cells with the mouse.

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, thetext “Output address is not valid.” appears if you have not entered a valid cell range
in the Results to field, and in this circumstance the OK button is grayed.
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 363. The data shownin 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 362.

Note
For those with a technical interest in the algorithms used by the Fourier Analysis tool,a radix-2 decimation-in-time FFT is used when the length of the input sequence is aneven power of 2, while Bluestein’s FFT algorithm is used when the length of the input
sequence is not an even power of 2.

Tip
For more information on Fourier analysis, refer to the corresponding Wikipedia article
at https://en.wikipedia.org/wiki/Fourier_analysis.

368 | Chapter 9 Data Analysis

Figure 363: Fourier analysis tool - example input data and results

Using Statistics tools | 369

Calc Guide

Chapter 10
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 fullpower of Calc. Consider this case:John is having trouble keeping track of his personal finances. He has several bankaccounts 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 accountbalances 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
364).

Figure 364: Options LibreOffice Calc Defaults dialog
Sheets in Calc are managed using tabs located at the bottom of the spreadsheet.

Using multiple sheets | 371

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 sametime, 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 theInsert 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 Sheetdialog.

•Select Sheet > Insert Sheet from File on the Menu bar. Calc displays the Insert Sheetdialog with the Before current sheet and From file options preselected. It also displays
a file browser dialog on top of the Insert Sheet dialog to enable you to first select thesource file containing the sheet to be inserted.

•

Right-click on a sheet tab and select Insert Sheet in the context menu (Figure 365). Calc
displays the Insert Sheet dialog with the Before current sheet and New sheet options
preselected.

•

Left-click in the empty space at the right end of the line of sheet tabs (Figure 365). 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 from the context menu (Figure 365). Calc displays the Insert Sheet dialog with the
Before current sheet and New sheet options preselected.

Figure 365: Creating a new sheet through the sheet tabs area
The above methods use either the Insert Sheet dialog (Figure 366) or the Append Sheet dialog(Figure 367).
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).

372 | Chapter 10 Linking Data

The From file option is described in “Inserting sheets from a different spreadsheet” (page 374).

Figure 366: Insert Sheet dialog

Figure 367: Append Sheet dialog
For John’s spreadsheet we need six sheets, one for each of his five accounts and one as asummary 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 eachnew 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 as the No. of sheets. Because you are inserting morethan one sheet, the Name box is not available.
4) Click OK to insert the sheets.
Using multiple sheets | 373

For the subsequent steps to rename the sheets, see “Renaming sheets” (page 375).
To insert sheets and name them at the same time:1) Rename the existing sheet as Summary, as described in “Renaming sheets” (page 375).
2) Make sure that the correct sheet tab is selected and open the Insert Sheet dialog.
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 thefile using the file browser dialog, and click Open. A list of the available sheets in that file appears
in the adjacent list box (Figure 368). Select the sheet to import (you can only import one at atime). If, after you select the file, no sheets appear, you probably selected an invalid file type (nota spreadsheet, for example).

Figure 368: From file area of Insert Sheet dialog showing file pathand names of available sheets
If you prefer, select the Link option to insert the external sheet as a link instead of as a copy. Thisis one of several ways to include “live” data from another spreadsheet – see also “Linking toexternal data” (page 385). The links can be updated manually to show the current contents of theexternal 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 yourspreadsheet. For more information about macros see Chapter 12, Macros.

374 | Chapter 10 Linking Data

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 theRename Sheet dialog.

•

Right-click on the relevant sheet tab, select Rename Sheet in the context menu, andreplace the existing name through the Rename Sheet dialog.

•

Left-click on the relevant sheet tab, select Sheet > Rename Sheet on the Menu bar, andreplace the existing name through the Rename Sheet dialog.

Figure 369: 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 characterof 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 370: 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 Figure371.
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.

Using multiple sheets | 375

Figure 371: Checking ledger

Referencing other sheets
On the Summary sheet we display the balance from each of the other sheets. If you copy theexample in Figure 371 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 thecell reference. Figure 372 shows the Summary sheet with a blank Balance column. We want toplace the reference for the Checking Account balance in cell B3.

Figure 372: 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 in the Formula bar. The icons in the Formula barchange and an equals character appears in the Input line (Figure 373).

Figure 373: Equals character in Input line of Formula bar
376 | Chapter 10 Linking Data

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 374).

Figure 374: Click on the Checking Account sheet tab3) 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 375) and theselected cell is surrounded by a colored border.

Figure 375: 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 376.

Figure 376: Finished Checking Account reference

Creating the reference with the keyboard
From Figure 376, you can deduce how the cell reference is constructed. The reference has twoparts: the sheet name prefixed by a dollar symbol ($'Checking Account'), and the cellreference (F3). Notice that they are separated by a period. The default behavior of Calc is toinsert 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 thebalance is in the same cell (F3) in the Savings Account sheet, the cell reference should be=$'Savings Account'.F3 (Figure 377).

Using multiple sheets | 377

Figure 377: Savings Account cell reference

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 describedfor different sheets in a single spreadsheet, but we add one more step to indicate which file thesheet 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 378. You
can press the keyboard Enter key at this point, or continue with steps 6 and 7.

Figure 378: Selecting the Savings Account reference cell6) Switch back to the original spreadsheet.
7) Click the Accept icon in the Formula bar.
Your spreadsheet should now resemble Figure 379.
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.

378 | Chapter 10 Linking Data

Figure 379: 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

From Figure 379, 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 canlead 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 (meaningfrom the folder in which your current document is saved), while an absolute hyperlink says, Hereis 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 startand target locations change relative to each other. For instance, if you have two spreadsheets inthe 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 thefolder homepage\graphics existed, your picture would not be available. It is better to use relative
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 movethe file.

Using hyperlinks and URLs | 379

Note
HTML (Hypertext Markup Language) files containing links as relative to the filesystem 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 absolutereference, because Calc uses absolute path names internally. The complete pathand 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 itwith a text editor.

Creating hyperlinks
You can insert a hyperlink into a Calc spreadsheet using one of these methods:•

Place the text cursor at the point where you want to insert the hyperlink, or select the textthat you want to put the hyperlink on. Select Insert > Hyperlink on the Menu bar, or click
the Insert Hyperlink icon on the Standard toolbar, or press Ctrl+K, to access theHyperlink dialog; see “Hyperlink dialog” (page 381).

•

Drag-and-drop an item from the Navigator to the point where you want to insert thehyperlink (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 thisdoes not happen, you can enable this feature using Tools > AutoCorrect Options >Options on the Menu bar and selecting URL Recognition. Make sure you start thehyperlink with http://, www., or ftp.; if you type only libreoffice.org forexample, 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 380) or a button hyperlink (Figure 381). In both cases, the visible text can be different
from the linked URL.

Figure 380: Example text hyperlink

Figure 381: 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, andclick OK.

380 | Chapter 10 Linking Data

NoteThis 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 befound in Chapter 18, Forms, of the Writer Guide.

Opening hyperlinks
To open a text hyperlink, do one of the following:•Ctrl-click with the cursor positioned over the hyperlink. This option is only available if theTools > Options > LibreOffice > Security > Security Options and Warnings >Options > Ctrl-click required to open hyperlinks option is selected.

•

Left-click with the cursor positioned over the hyperlink. This option is only available if theTools > Options > LibreOffice > Security > Security Options and Warnings >Options > Ctrl-click required to open hyperlinks option is not selected.

•

Right-click with the cursor positioned over the hyperlink and select the Open Hyperlink
option in the context menu.

To open a button hyperlink, left-click the button. This option is only available when the form
design mode is deactivated; the status of this mode is controlled by clicking the Design Modebutton on either the Form Controls toolbar or the Form Design toolbar.

Hyperlink dialog
You can insert and modify hyperlinks using the Hyperlink dialog (Figure 382). To display this
dialog, choose Insert > Hyperlink on the Menu bar, or click the Insert Hyperlink icon on theStandard toolbar, or press Ctrl+K.

Figure 382: Hyperlink dialog showing details for theInternet category
Using hyperlinks and URLs | 381

On the left side of the dialog, select one of the four categories of hyperlink:•

Internet. The hyperlink points to a WWW (World Wide Web) or FTP (File Transfer
Protocol) address.

•

Mail. The hyperlink points to an email address.

•

Document. The hyperlink points to a location in either the current document or anotherexisting document.

•

New Document. Opening the hyperlink creates a new document.

Figure 382 shows the Hyperlink dialog with the Internet category and the Web hyperlink typeselected.
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 theleft 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– Web / FTP. Select the type of hyperlink. On selection of the FTP option, the controls
above the Further Settings area change to those shown in Figure 383.
– 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 relativeand you move the file, this text will not change, though the target will.
– Login name. If necessary, enter your login to access the URL. Only applicable for
FTP hyperlinks.
– Password. If necessary, enter your password to access the URL. Only applicable for
FTP hyperlinks.
– Anonymous user. Mark this option to access the URL anonymously. Only applicablefor FTP hyperlinks.

Figure 383: FTP specific controls on theHyperlink dialog
Mail
For Mail hyperlinks, the controls above the Further Settings area change to those shown in
Figure 384.
– Recipient. Enter the email address of the recipient, or select the address from anexisting database accessed by clicking the Data Sources button.
– Subject. Enter the text to be used as the subject line of the message.

382 | Chapter 10 Linking Data

The Text field (shown in the Hyperlink Type area in Figures 382 and 383, 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.

Figure 384: Mail controls on the Hyperlink
dialogDocument
For document hyperlinks, the controls above the Further Settings area change to thoseshown in Figure 385.

Figure 385: Document controls on the Hyperlink
dialog– Path. Specify the path of the file to be opened. Leave this blank if you want to link to atarget in the same spreadsheet. The Open File icon opens a file browser for you tolocate 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 canselect the target, or if you know the name of the target, you can type it into the box.
New Document
For New Document hyperlinks, the controls above the Further Settings area change tothose shown in Figure 386.
– 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).

Using hyperlinks and URLs | 383

Figure 386: New Document controls on theHyperlink 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 todocuments 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 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.

•

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 isclicked. 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 thehyperlink 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 thehyperlink.
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 theInsert 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 haveedited all of them. Be sure to click Apply after each one. When you are finished, click Close.
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
384 | Chapter 10 Linking Data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 thedesired changes, just close the dialog.

Removing hyperlinks
To remove a text or button hyperlink from the document completely, select it and use one of themany 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 theNavigator. If your file has named ranges, database ranges, or named tables, and you know thename 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 beeasier.
Calc provides other methods for including linked data from external sources, see for example“Linking to registered data sources” (page 392) and “Dynamic Data Exchange (DDE)” (page
401).

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 > Link to External Data on the Menu bar. Calc displays the External Datadialog (Figure 387).
4) Type the URL of a web resource that is to be used as a data source, or type the addressof a source file, or select an entry in the drop-down list, or select a source file from the fileselection dialog accessed through the Browse button. For entries typed in, press Enteron completion.
5) If you selected an HTML file as the data source at step 4, Calc displays the Import
Options dialog (Figure 388). On this dialog you can choose the import language of thesite. Select Automatic to let Calc import the data directly, or select Custom and choose
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.

Linking to external data | 385

Figure 387: External Data dialoga) 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 muchformatting 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 topermit selection of the entire document and HTML_tables to permit selection of all thetables.
b) In the Available Tables/Ranges area, select the named ranges or tables you want toinsert (hold Ctrl to select multiple entries). The OK button then becomes available.

Figure 388: Import Options dialog
6) If you selected a CSV file as the data source at step 4, Calc displays the Text Importdialog (Figure 389). 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 theExternal Data dialog. The OK button then becomes available.
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 names anddatabase ranges that you want to insert (hold Ctrl to select multiple entries) and the OK
button then becomes available.

386 | Chapter 10 Linking Data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 theExternal 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.

Figure 389: Text import dialog
Calc adds the new entry to the Linked areas list in the Navigator (Figure 390). If you double-click
this entry, Calc highlights the linked data within the sheet. When you hover the cursor over theentry, a tooltip indicates the file location of the linked data.

Linking to external data | 387

Figure 390: Linked areas in the NavigatorTo view a list of all external data links in the spreadsheet, select Edit > Links to External Fileson the Menu bar. Calc displays the Edit Links dialog (Figure 391).

Figure 391: Edit Links dialog

Note
The Edit Links dialog can display information about other links that were not createdusing 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, thepreviously-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.

388 | Chapter 10 Linking Data

Note
The Status column on the Edit Links dialog always shows Manual for a link createdusing the External Data dialog. The status shown in this column does not reflect thesetting 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 an HTML file, Calc displays
the Import Options dialog (Figure 388) before opening the file.
3) In the target document, open the Navigator (Figure 392). This illustration shows the
Navigator for a new file called Untitled 1, which currently has no range names, databaseranges, or linked areas.
4) At the bottom of the Navigator, select the source document in the drop-down menu
(Figure 393). In this case the source is called summary-indices-constituents and the filecontains 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 392: Navigator for target file

Linking to external data | 389

Figure 393: Navigator for source file5) In the Navigator, select the Insert as Link option in the Drag Mode menu, as shown in
Figure 394.

Figure 394: Select Insert as Link from Drag Mode menu
You can also change the drag mode by right-clicking on a range name and selecting therequired option in the context menu.

390 | Chapter 10 Linking Data

Tip
The graphic on the Drag Mode icon on the Navigator changes to reflect the currently
selected drag mode.
6) Select the required Range names or Database ranges entry and drag it from theNavigator into the target document, to the cell where you want the upper left cell of thedata 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 390.

How to find the required data range or tableCalc’s Web Page Query import filter gives names to the data ranges (tables) it finds in a web
page, starting from HTML_1. 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, alongwith the ranges Calc has sequentially numbered.
If the data range or table you want is not meaningfully named, how can you tell which one toselect?
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 395 shows a table of bestselling 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 395: 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 396). The range name can be selected in the drop-down list to highlight it on the page.

Linking to external data | 391

Figure 396: 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 LibreOfficewhat type of data source it is and where the file is located. The way to do this depends onwhether 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 397.

Figure 397: Options – LibreOffice Base – Databases dialog
2) Click the New button to open the Create Database Link dialog (Figure 398).

392 | Chapter 10 Linking Data

Figure 398: 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 databaseis added to the list of registered databases and LibreOffice uses the registered name toaccess 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 (Figure399). For more about the Database Wizard, see Chapter 2, Creating a Database, of theBase Handbook.
2) Select Connect to an existing database and select the appropriate database type fromthe 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 399 relates to a
Windows 10 installation.

Note
The exact interactions required to connect to a database vary depending on the typeof 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 databasefor 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 originaldBASE database. The original dBASE database remains unchanged.

Linking to registered data sources | 393

Figure 399: Database Wizard
Once a data source has been registered, it can be used by any LibreOffice component (forexample, 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 thespreadsheet.
The Data Source window has three main components:•

The Table Data toolbar (Figure 400), which is by default located at the top of the Data
Source window.

Figure 400: Table Data toolbar
The Table Data toolbar provides the following icons, from left to right:– Save current record– Edit Data
– Cut
– Copy394 | Chapter 10 Linking Data

– Paste– Undo– Find Record– Refresh– Sort– Sort Ascending– Sort Descending– AutoFilter– Apply Filter– Standard Filter– Reset Filter/Sort– Data to Text
– Data to Fields– Mail Merge– Data Source of Current Document– Explorer On/Off•

The Data Source Explorer (Figure 401), which by default is located on the left side of theData 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 401. 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 inthat table.

Figure 401: Data Source Explorer•

The data records for the selected table are displayed in the area at the right side of theData Source window, below the Table Data toolbar.

Figure 402: 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.
Linking to registered data sources | 395

Below the data records is a navigation bar, which shows which record is selected and thetotal 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 visiblearea. A vertical scroll bar appears when the available data records do not all fit in thevisible area.
At the bottom center of the Data Source window is an additional control to hide and show theentire window. This control is highlighted with a red box in Figure 402.

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 Filein the context menu. Once in Base, you can edit, add, and delete tables, queries, forms, andreports.
For more about using Base, see Chapter 8, Getting Started with Base, in 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.
You can select a single cell, a single row, or multiple rows in the Data Source window and dragand drop the data into the spreadsheet. The data is inserted at the place where you release themouse 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 thelast 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 thecolumn 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.
396 | Chapter 10 Linking Data

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 tocreate 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 orpressing 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 (Figure403). By default, this toolbar opens at the bottom of the Calc window, just above theStatus bar.
Figure 403: Form Navigation toolbar
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 thedata in the spreadsheet fields updates to correspond to the data for that particular record
number.
From left to right, the Form Navigation toolbar provides the following interactions:– Find Record (provides access to the Record Search dialog)– Absolute Record (type in the number of the required record)– First Record– Previous Record– Next Record– Last Record– New Record– Save Record– Undo– Delete Record– Refresh– Refresh Control– Sort– Sort Ascending– Sort Descending– AutoFilter– Apply Filter– Form-Based Filters– Reset Filter/Sort– Data source as Table
Linking to registered data sources | 397

Embedding spreadsheets
Spreadsheets can be embedded in other LibreOffice files and vice versa. This is often used inWriter 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 isinserted as a Linked OLE object into the Writer document, then the spreadsheet can be edited inWriter 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 doubleclicking on it. You can also insert a link to the object that will appear as an icon rather than anarea 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, whileembedding inserts a static copy of the data. If you want to edit the embedded spreadsheet,double-click on the object.

Note
If your OLE object is empty, inactive, and not displayed as an icon, then it will betransparent.
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 404, 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.0 Spreadsheet.
2) Click OK.
3) LibreOffice places an empty container in the slide, ready for you to enter information. Bydefault 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.

398 | Chapter 10 Linking Data

Figure 404: 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 of the it 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 Save button.

Note
If the object inserted is handled by LibreOffice, then the transition to the program tomanipulate the object will be seamless; in other cases the object opens in a new
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 405.

Embedding spreadsheets | 399

Figure 405: Insert OLE Object dialog with
Create from file option selected
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.
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 406).

Figure 406: Inserting an OLE object under Windows

400 | Chapter 10 Linking Data

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.
3) If you choose Create from File, the layout of the Insert Object dialog changes to thatshown in Figure 407. 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 407: 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 aspreadsheet 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
When the spreadsheet OLE object is linked, if you change it in Writer it will change in Calc; if youchange it in Calc, it will change in Writer. This can be a very powerful tool if you create reports inWriter using Calc data, and want to make a quick change without opening Calc.

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 indocument 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 notembedded. 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.
Embedding spreadsheets | 401

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, for example, selecting Edit > Copy on the Menu bar,or clicking the Copy icon on the Standard toolbar, or right-clicking the selected area andselecting 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 Menubar, 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 408).

Figure 408: Paste Special dialog
8) Select the Link option on the Paste Special dialog (highlighted with a red box on Figure408) and then click OK.
If you now click on one of the linked cells you will see that the Formula bar shows areference beginning with the characters {=’. See Figure 409 for an example, highlighted
with a red box.
9) Save and close both spreadsheets.

402 | Chapter 10 Linking Data

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.

Figure 409: 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 Enable Content button to update 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) andTools > Options > LibreOffice Calc > General (Update links when opening section)
respectively.

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 Chapter 19, Spreadsheets, Charts, Other
Objects from 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 410).
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 tablein Writer is automatically updated.

Embedding spreadsheets | 403

Figure 410: 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 orin 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 isimported.
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><employee>Brigitte</employee></sale><sale><date>01/25/08</date><value>$3,116</value><category>Sailing</category><region>East</region><employee>Hans</employee>
404 | Chapter 10 Linking Data</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 411).

Figure 411: XML Source dialog (on initial display)2) Click the icon in the Source File area at the top of the dialog. Calc displays the Opendialog, which lets you specify the path to the XML file that you wish to import into yourdocument.
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 areaon the XML Source dialog to show the structure of the XML, as can be seen in Figure412. The Map to Document area is described further below.

XML Source | 405

5) In the case of our example data, select sale in the Map to Document area. This will importall <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 yourspreadsheet. In the case of our example, click cell A1. A tellback of the cell clickedappears in the Mapped cell text box.
7) The contents of the XML Source dialog should now look like that shown in Figure 412.
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 412: XML Source dialog (populated)
Calc will place the XML content into the specified position in the spreadsheet, as shown in Figure
413.

Figure 413: 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 @.

406 | Chapter 10 Linking Data•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 cellin the document.

•

Recurring element, represented by the symbol <//>. A recurring element is an elementthat can appear multiple times under the same parent. It serves as an enclosing parent ofa 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
points to the top-left cell of the range where the whole record entries plus header will get
imported.

XML Source | 407

Calc Guide

Chapter 11
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 andcomparing 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 Chapter 1, Introducing LibreOffice, in the Getting
Started Guide.

Tip
In order to correctly identify the changes, each collaborator should enter their name inTools > 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 ordisable sharing.

Figure 414: Share Document dialog
To enable sharing, select the checkbox at the top of the dialog (Figure 414) and click OK. If the
spreadsheet has been saved previously, a message appears stating that you must save it to
Sharing spreadsheets | 409

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 fromshared 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 copyof 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 notavailable 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 thefollowing will occur:

410 | Chapter 11 Sharing and Reviewing Spreadsheets•

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 415: Resolve Conflicts dialog•

If the changes conflict, the Resolve Conflicts dialog (Figure 415) is shown. You must
decide for each conflict which version to keep, yours or the other person’s. When allconflicts are resolved, the document is saved. While you are resolving the conflicts, noother user can save the shared document.

•

If another user is trying to save the shared spreadsheet and resolve conflicts, they see amessage that the file is locked due to a merge in progress. They can cancel the Savecommand and retry saving later.

When you successfully save a shared spreadsheet, the document shows the latest version of allchanges 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 anotherperson 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 adifferent name, or both), then use Calc to compare the files and show the changes. See“Comparing documents” on page 417.

•

You can save versions that are stored as part of the original file. See “Saving versions”
on page 417.

Reviewers can leave comments in the document, either attached to specific changes orstandalone.

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 sothat the editor or reviewer does not have to remember to turn on the revision marks.
After you have turned on revision marks, you can optionally password protect the spreadsheet sothat any user must enter the correct password in order to accept or reject changes.

Reviewing documents | 411

1) Open the spreadsheet and select Edit > Track Changes > Record on the Menu bar, orpress Ctrl+Shift+C. You can also use File > Properties > Security and select Recordchanges.
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 canalso use File > Properties > Security and click the Protect button to open the similarEnter Password dialog. Guidelines for choosing a suitable password are in the Help.

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 416). A deleted column or row is marked by a heavy colored bar.

Figure 416: Edited document with red border on changed cells
To see the changed information, hover the mouse pointer over the changed cell. See Figure 417.

Figure 417: Showing details of the change

NoteSome 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.

412 | Chapter 11 Sharing and Reviewing Spreadsheets

You may want to explain your rationale for the changes. You can do this by adding comments tothe 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. Typeyour comment and click OK. See Figure 418.

Note
Do not use Insert > Comment on the Menu bar or the context menu for thispurpose. Comments inserted using that method are handled differently (see “Adding
other (general) comments” on page 414) and do not appear in the Manage Changes
dialog.

Figure 418: Entering a comment associated with a change
After you have added a comment to a changed cell, you can see the change and the commentby hovering the mouse pointer over the cell, as shown in Figure 419.

Figure 419: Comment added to cell B3
The comment also appears on the Manage Changes dialog when you are accepting andrejecting changes, as shown in the first line of Figure 423 on page 416.

Reviewing documents | 413

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
418 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 420 appears.

Figure 420: Inserting a comment3) 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 dot in the upper right-hand corner,as shown in Figure 421. It does not have a colored border, unless the cell was also changed.

Figure 421: Colored dot in cell containing a comment

Tip
You can change the colors Calc uses for comments by selecting Tools > Options >LibreOffice > Application Colors and adjusting the color for Notes background 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 below.

Figure 422: Viewing a comment

414 | Chapter 11 Sharing and Reviewing SpreadsheetsNote
If you hover the cursor over a cell that has both a change comment and a generalcomment, 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 thecontext menu, or left-click on the cell and press Ctrl+Alt+C.
2) Calc shows the cell’s comment. The cursor changes to the usual text-entry cursor, andthe 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 acomment.
1) Right-click on the cell containing the comment marker, and choose Show comment in
the context menu.
2) Click on the comment itself. The Formatting toolbar changes to show many of thecomment formatting options. These are the same as the options for formatting graphics;
see Chapter 5, 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 todialogs where you can fine-tune the formatting; these dialogs are also discussed in
Chapter 5.
3) When done, click outside the comment to deselect it. To hide the comment again, rightclick on the cell and choose Hide Comment in the context menu.

Finding general comments
The small comment markers in the corners of cells can be difficult to see, so Calc provides twoother ways to find them: by showing all comments and by using the Navigator. To show all
general comments, choose View > Comments on the Menu bar. To hide all comments, choose
View > Comments again.
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 comments. Doubleclick 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 thecomments 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 423 appears.

Reviewing documents | 415

3) You can step through the changes one at a time, choosing to accept or reject eachchange 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 thereviewer added a comment to the change, it is displayed, followed by the description of thechange.
If a change has been superseded by a later change (by either the same person or anotherperson), the changes are hierarchically arranged with an expansion symbol for opening up thehierarchy.
Below the list of changes to be accepted or rejected are shown any changes that have previously
been dealt with.

Figure 423: Manage Changes dialog – List tab

Figure 424: Manage Changes dialog – Filter tab
416 | Chapter 11 Sharing and Reviewing SpreadsheetsOn the Filter tab of the Manage Changes dialog (Figure 424), you can choose how to filter the listof changes: by date, author, cell range, or comments containing specific terms. After selecting thefilter criteria, switch back to the List tab to see the results. Filtering the changes affects only thecontents of the List tab on the dialog, you will not see any filtered results in your spreadsheet.

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 thispurpose, you can merge documents in Calc.
To merge documents, all of the edited documents (but not the original document) need to haverecorded 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 bymore than one reviewer. If you want to merge more documents, close the dialog and thenrepeat steps 2 and 3.
Now all of the changes are combined into one document and you can accept or reject thechanges. 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 bycomparing 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 cando this by saving a copy of the spreadsheet (under a different name) after each revision, or byusing Calc’s version feature.

CautionIf you select File > Save As on the Menu bar, or press Ctrl+Shift+S, for a documentwith different versions stored in it, the old versions are not saved in the new file.

Saving versions | 417

To use version management in Calc:
1) Choose File > Versions on the Menu bar. A version management dialog (Figure 425)
opens, showing a list of the existing versions saved in this file.

Figure 425: Version management dialog
2) Click the Save New Version button to save a new version. The Insert Version Comment
dialog (Figure 426) opens where you can enter comments about this version.

Figure 426: Insert Version Comment
dialog3) After you enter your comment and click OK, the new version is included in the Existing
Versions list (Figure 427).
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 thedifferent versions.

•

Review the version comments – Select a version and click Show to display the fullcomments made by yourself or other reviewers.

•

Delete a version – Select a version and click Delete. Be careful with this option, whendeleting a version, there is no request for confirmation.

418 | Chapter 11 Sharing and Reviewing SpreadsheetsFigure 427: Updated version list

Saving versions | 419

Calc Guide

Chapter 12
MacrosAutomating repetitive tasks

Introduction
Chapter 13 of the Getting Started Guide (entitled Getting Started with Macros) 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 newfeatures 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 andenhanced 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, BeanShell, JavaScript, and Python). 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 BeanShell, JavaScript, andPython scripting languages but fuller descriptions of the facilities for these languages are beyond
the scope of this document.

On Visual Basic for Application (VBA) compatibility
LibreOffice Basic programming language and 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, youmust first edit the code in the LibreOffice Basic IDE editor.
Some elements for the conversion of Excel macros written in VBA are detailed at the end of thischapter.

Using the macro recorder
Chapter 13, 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 moredetailed 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.
1) Use File > New > Spreadsheet on the Menu bar to create a new spreadsheet.
2) Enter the numbers shown in Figure 428 into cells A1:C3 of Sheet1 in the new
spreadsheet.

Using the macro recorder | 421

Figure 428: Enter numbers into
cells A1:C3
3) Select cell A3, which contains the number 3, and use Edit > Copy on the Menu bar tocopy the value to the clipboard.
4) Select all cells in the range A1:C3.
5) 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 429).

Figure 429: Record Macro dialog with Stop Recording button
6) Use Edit > Paste Special > Paste Special on the Menu bar to open the Paste Special
dialog (Figure 430).

Figure 430: Paste Special dialog
7) Select the Paste all option in the Selection area and Multiply in the Operations area, andclick OK. The values in cells A1:C3 are now multiplied by 3 (Figure 431).

422 | Chapter 12 Macros

Figure 431: Cells A1:C3 multiplied by 3
8) Click the Stop Recording button to stop the macro recorder. Calc displays a variant of
the Basic Macros dialog (Figure 432).

Note
The Save Macro In area of the Basic Macros dialog shows the existing LibreOffice
Basic macros, hierarchically structured into library containers, libraries, modules, andmacros as described in Chapter 13 of the Getting Started Guide. Figure 432 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 filecreated at step 1. Use the expand/collapse icons to the left of each library containername to view the libraries, modules, and macros within that container.

Using the macro recorder | 423

1

My Macros5

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

Figure 432: Parts of the Basic Macros dialog
9) 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.
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 theexample 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.
10) Click the New Module button. Calc displays the New Module dialog (Figure 433). Type aname for the new module or leave the name as the default Module1.

Figure 433: New Module dialog
424 | Chapter 12 Macros

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), andunderscore characters (_)•

Begin with a letter or an underscore•

Not contain any other spaces, punctuation symbols, or special characters (including
accents)11) 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.
12) 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 434).

Figure 434: Select the module and name the macro
The macro is saved with the name PasteMultiply in the newly created module within theStandard library of the Untitled 1 document. Listing 1 shows the contents of the macro.
Listing 1. Paste special with multiply macro
sub PasteMultiply
rem -------------------------------------------------------------rem define variables
dim document
as object
dim dispatcher as object
rem -------------------------------------------------------------rem get access to the document
document= ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")rem -------------------------------------------------------------dim args1(5) as new com.sun.star.beans.PropertyValue
Using the macro recorder | 425

args1(0).Name = "Flags"
args1(0).Value = "A"
args1(1).Name = "FormulaCommand"args1(1).Value = 3
args1(2).Name = "SkipEmptyCells"
args1(2).Value = false
args1(3).Name = "Transpose"args1(3).Value = false
args1(4).Name = "AsLink"
args1(4).Value = false
args1(5).Name = "MoveMode"args1(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0,
args1())
end sub

Note
The component model used in LibreOffice is Universal Network Objects (UNO) andthe 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 recorderignores some values from dialogs that are opened while recording a macro – it ispossible, 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 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 itwith 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 435). Note that the layout of the Basic Macros dialog in thiscircumstance is different from the version that Calc displays when the user clicks theStop Recording button on the Record Macro dialog (Figure 432).

426 | Chapter 12 Macros

Figure 435: Basic Macros dialog
The Macro From area lists the available macro library containers, including those relating
to any LibreOffice documents that are currently open. My Macros contain macros that you
write or add to LibreOffice and are available to more than one document. LibreOfficeMacros contains macros that were included with your LibreOffice installation and should
not be changed.
3) Click Organizer to open the Basic Macro Organizer dialog (Figure 436).
Click on the Libraries tab and, in the Location area, select the entry for the name of thecurrent document. The Library area updates to show the name of the empty Standard
library.

Figure 436: Basic Macro Organizer

Write your own functions | 427

4) Click New to open the New Library dialog to create a new library for this document(Figure 437).

Figure 437: New Library dialog
5) 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 thename of the newly created library. A library name can comprise up to 30 characters. Notethat in some cases, the dialog may show only a portion of the name.

Figure 438: The new library is shown in the Libraryarea6) 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 439.

428 | Chapter 12 Macros

Figure 439: LibreOffice Basic Integrated Development Environment
Figure 439 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 forediting 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.

•

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 thisdocument, but more information can be found in the Help system.
7) 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.

Write your own functions | 429

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.
Listing 2. Function that returns the value 5
REM ***** BASIC
Option Explicit*****

Sub Main
End Sub
Function NumberFive ()NumberFive = 5
End Function8) Within the LibreOffice Basic IDE select File > Save on the Menu bar, or click the Save
icon on the Standard toolbar, or press Ctrl+C, to save the modified Module1.

Using a macro as a function
Using your newly created CalcTestMacros.ods spreadsheet, select a cell and enter theformula =NumberFive() (Figure 440). Calc finds the macro, calls it, and displays the result (5)in that cell.

Figure 440: Use the NumberFive macro as a
Calc function

Tip
Function names are not case sensitive. In Figure 440, the function name wasentered as NumberFive() but Calc displays it as NUMBERFIVE() in the Formulabar.

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 441 and 442.
In the case of the warning shown in Figure 441, 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 amacro, it is safer to click Disable Macros in case the macro is a virus.
In the case of the warning shown in Figure 442, 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.
430 | Chapter 12 Macros

Figure 441: Warning that a document contains macros

Figure 442: 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 theavailable 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 itis called (Figure 443).

Figure 443: The macro function is notavailable
Use Tools > Macros > Organize Macros > Basic on the Menu bar to open the Basic Macros
dialog (Figure 444). 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.

Write your own functions | 431

Figure 444: Different symbols for loaded and unloaded libraries
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 orif there are many macros, a stub with the desired name is stored in the Standard library. The stubmacro 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 445).

Figure 445: Select a macro and click Edit
2) Calc displays the LibreOffice Basic IDE (Figure 439), 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
Function NumberFive_Implementation ()NumberFive_Implementation = 5
End Function3) Click the Select Macro button in the Standard toolbar of the LibreOffice Basic IDE toopen the Basic Macros dialog (Figure 445).

432 | Chapter 12 Macros

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 andclick OK. Calc automatically creates a macro named Main and opens the module forediting.
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
Function NumberFive()
If NOT BasicLibraries.isLibraryLoaded("AuthorsCalcMacros") Then
BasicLibraries.LoadLibrary("AuthorsCalcMacros")
End IfNumberFive = NumberFive_Implementation()
End Function6) Save, close, and reopen the Calc document. This time, if macros are enabled, theNumberFive() function works as expected.

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
Function PositiveSum(Optional x)
Dim TheSum As Double
Dim iRow As Integer
Dim iCol As Integer
TheSum = 0.0
If NOT IsMissing(x) Then
If NOT IsArray(x) Then
If x > 0 Then TheSum = x
Else
For iRow = LBound(x, 1) To UBound(x, 1)
For iCol = LBound(x, 2) To UBound(x, 2)
If x(iRow, iCol) > 0 Then TheSum = TheSum + x(iRow, iCol)
Next
Next
End IfEnd IfPositiveSum = TheSum
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 iscalled without it, Calc outputs a warning message every time the macro is called. If Calccalls 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

Write your own functions | 433

passed as an argument, and in the second case, the value of cell A4 is passed to thefunction. 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; forexample, =PositiveSum(A2:B5). The functions LBound and UBound are used todetermine the array bounds that are used. Although the lower bound is one, it isconsidered 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 asingle 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 acomma; for example, =TestMax(3, -4).
Listing 6. TestMax accepts two arguments and returns the larger
Function TestMax(x, y)
If x >= y Then
TestMax = x
Else
TestMax = y
End If
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, andPositiveSum has no way of knowing that cell A3 was used. If you must know which cells arereferenced rather than the values in the cells, pass the range as a string, parse the string, andobtain 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-infunctions. 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 isfor experienced programmers and is beyond the scope of this guide. Some information, alongwith 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 445 on page 432).
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.

434 | Chapter 12 Macros

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 445 on page 432).
2) Click the Organizer button to open the Basic Macro Organizer dialog (Figure 446).
3) Make sure that the Modules tab is selected.

Figure 446: Basic Macro Organizer dialog, Modules tab4) 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.

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 themacro 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
Function SumCellsAllSheets()
Dim TheSum As Double
Dim i As integer
Accessing cells directly | 435

Dim oSheets
Dim oSheet
Dim oCell
TheSum = 0
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)oCell = oSheet.getCellByPosition(0, 1) ' GetCell A2
TheSum = TheSum + oCell.getValue()
Next
SumCellsAllSheets = TheSum
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 thecorresponding set functions to set appropriate values.
Use oSheet.getCellRangeByName("A2") to return a range of cells by name. If a single cell isreferenced, then a cell object is returned. If a cell range is given, then an entire range of cells isreturned (see Listing 8). Notice that a cell range returns data as an array of arrays, which is morecumbersome 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
Function SumCellsAllSheets()
Dim TheSum As Double
Dim iRow As Integer, iCol As Integer, i As Integer
Dim oSheets, oSheet, oCells
Dim oRow(), oRows()
TheSum = 0
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)oCells = oSheet.getCellRangeByName("A2:C5")
REM The getDataArray() method returns strings and numbers
REM but is not used in this function.
REM The getData() method returns only numbers and is applicable
REM to this function.
oRows() = oCells.getData()
For iRow = LBound(oRows()) To UBound(oRows())
oRow() = oRows(iRow)
For iCol = LBound(oRow()) To UBound(oRow())
TheSum = TheSum + oRow(iCol)
Next
Next
Next
SumCellsAllSheets = TheSum
End Function

436 | Chapter 12 Macros

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 thefunction.

Sorting
Consider sorting the data shown in Figure 447. First, sort on column B descending and then on
column A ascending.

Figure 447: Sort column B descending and column A
ascending
The example in Listing 9 demonstrates how to sort on these two columns. Run the macro byclicking the Run icon in the Macro toolbar of the LibreOffice Basic IDE.
Listing 9. SortRange sorts cells A1:C5 of Sheet 1
Sub SortRange
Dim oSheet
Dim oCellRange' Calc sheet containing data to sort.
' Data range to sort.

REM An array of sort fields determines the columns that are
REM sorted. This is an array with two elements, 0 and 1.
REM To sort on only one column, use:
REM Dim oSortFields(0) As New com.sun.star.util.SortField
Dim oSortFields(1) As New com.sun.star.util.SortField
REM The sort descriptor is an array of properties.
REM The primary property contains the sort fields.
Dim oSortDesc(0) As New com.sun.star.beans.PropertyValue
REM Get the sheet named "Sheet1"
oSheet = ThisComponent.Sheets.getByName("Sheet1")
REM Get the cell range to sort
oCellRange = oSheet.getCellRangeByName("A1:C5")
REM Select the range to sort.
REM The only purpose would be to emphasize the sorted data.
'ThisComponent.getCurrentController.select(oCellRange)
REM The columns are numbered starting with 0, so
REM column A is 0, column B is 1, etc.
REM Sort column B (column 1) descending.
oSortFields(0).Field = 1
oSortFields(0).SortAscending = FALSE
Sorting | 437

REM If column B has two cells with the same value,
REM then use column A ascending to decide the order.
oSortFields(1).Field = 0
oSortFields(1).SortAscending = TRUEREM Setup the sort descriptor.
oSortDesc(0).Name = "SortFields"
oSortDesc(0).Value = oSortFields()
REM Sort the range.
oCellRange.Sort(oSortDesc())
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, andPython.
The primary macro scripting language for Calc is LibreOffice Basic and the standard LibreOfficeinstallation 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
library container holds your macros that are available to any of your LibreOffice documents. Eachdocument 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 448).
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
languagesand provides a means of access to the various interfaces which they might need toperform some action on a document.

438 | Chapter 12 Macros

Figure 448: 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 449).
Click the Edit button on the BeanShell Macros dialog to access the BeanShell Debug Window(Figure 450).

Overview of BeanShell, JavaScript, and Python macros | 439

Figure 449: BeanShell Macros dialog

Figure 450: 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.

440 | Chapter 12 Macros

Listing 10. Sample BeanShell macro
import com.sun.star.uno.UnoRuntime;
import com.sun.star.sheet.XSpreadsheetView;
import com.sun.star.text.XText;
model = XSCRIPTCONTEXT.getDocument();
controller = model.getCurrentController();view = UnoRuntime.queryInterface(XSpreadsheetView.class, controller);
sheet = view.getActiveSheet();cell = sheet.getCellByPosition(0, 0);
cellText = UnoRuntime.queryInterface(XText.class, cell);textCursor = cellText.createTextCursor();cellText.insertString(textCursor, "Hello World from BeanShell", true);
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 451).

Figure 451: JavaScript Macros dialog

Overview of BeanShell, JavaScript, and Python macros | 441

Click the Edit button on the JavaScript Macros dialog to access the Rhino JavaScript Debugger(Figure 452). Detailed instructions for using this tool can be found on Mozilla’s website athttps://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Debugger.

Figure 452: Rhino JavaScript Debugger
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
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
importClass(Packages.com.sun.star.container.XIndexAccess);
importClass(Packages.com.sun.star.table.XCellRange);
importClass(Packages.com.sun.star.table.XCell);documentRef = XSCRIPTCONTEXT.getDocument();

442 | Chapter 12 MacrosspreadsheetInterface = UnoRuntime.queryInterface(XSpreadsheetDocument,
documentRef);
allSheets = UnoRuntime.queryInterface(XIndexAccess,spreadsheetInterface.getSheets());
theSheet = allSheets.getByIndex(0);Cells = UnoRuntime.queryInterface(XCellRange,theSheet);
cellA1 = Cells.getCellByPosition(0,0);
theCell = UnoRuntime.queryInterface(XCell,cellA1);
theCell.setFormula("Hello World from JavaScript");

Python macros
Python is a high-level, general-purpose programming language that was first released in 1991.
When you select Tools > Macros > Organize Macros > Python on the Menu bar, Calc displays
the Python Macros dialog (Figure 453).

Figure 453: 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 oran 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 yourpreferred source code editor, start the integrated Python shell and debug Python scripts. For
more information search for Python 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) and the Help pages startingat (https://help.libreoffice.org/latest/en-US/text/sbasic/python/main0000.html).

Overview of BeanShell, JavaScript, and Python macros | 443

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
import uno
def HelloWorld():
doc = XSCRIPTCONTEXT.getDocument()
cell = doc.Sheets[0]['A1']
cell.setString('Hello World from Python')returnWorking 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, theobjects, attributes, and methods use different names and the corresponding behavior issometimes 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 canchoose whether to keep any macros in Microsoft Office documents that are opened in
LibreOffice.

Figure 454: Choosing Load/Save VBA Properties
If you choose Load Basic code, you can edit the macros in LibreOffice. The changed code issaved in an ODF document but is not retained if you save it 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 inspect

444 | Chapter 12 Macros

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 ina Microsoft Office format.
To remove any possible macro viruses from the Microsoft Office document, deselect Saveoriginal 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 programcode 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 thesame 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
Option VBASupport 1
Sub Example
Dim sVar As Single
sVar = Worksheets("Sheet1").Range("A1")
Print sVar
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
Sub Example
Dim sVar As Single
Dim oSheet as Object
Dim oCell as Object
REM Worksheets(“Sheet1”).
oSheet = ThisComponent.getSheets().getByIndex(0)REM Range("A1")
oCell = oSheet.getCellByPosition(0, 0)
sVar = oCell.getValue()
Print sVar
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,...).

•

Support Private/Public keywords for procedures.
Working with VBA macros | 445

•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 parameterselections. 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”
Sub MyProc
MyForm.Show
End Sub
Listing 16. LibreOffice Basic display of a UserForm [Dialog] called “MyForm”
Rem oDlg should be visible at the module level
Dim oDlg As Object
Sub MyProc
DialogLibraries.LoadLibrary("Standard")oDlg = CreateUnoDialog(DialogLibraries.Standard.MyForm)oDlg.execute()
End Sub

Note
The oDlg variable is visible at the module level to all other procedures that areaccessing controls on the dialog. This means all the procedures manipulating oraccessing 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 beginningof what you can learn.
If you are already familiar with the Basic language (or with one programming language), theLibreOffice Extensions website has a set of LibreOffice Basic quick reference cards at theaddress https://extensions.libreoffice.org/?Tags%5B%5D=53&Tags%5B%5D=173.
Additional detail about Calc’s macro facilities can be obtained from the Help system(https://help.libreoffice.org/7.0/en-US/text/sbasic/shared/main0601.html?DbPAR=BASIC for
general macros information, or, to find some specific VBA Support information go tohttps://help.libreoffice.org/latest/en-US/text/sbasic/shared/03103350.html), 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).

446 | Chapter 12 Macros

Calc Guide

Chapter 13
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 databasefacilities 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 andsubsequently 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 takeadvantage 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 example LibreOffice Basic macros. These are
now available on The Document Foundation’s wiki athttps://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-likeseries 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 offields, 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 thatmeet a specified set of criteria. It is this ease of access that makes a database table more usefulthan 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 455). In this sheet, each row represents individual students taking the class, while eachcolumn 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 455: 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 Base448 | Chapter 13 Calc as a Database

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 databasetable to be contained in a Calc sheet. The data can be deeply analyzed using a wide range oftools and functions. It can be sorted, filtered, pivoted, and presented visually in 2-D/3-D chartsand 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 tooccupy. 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 groupof 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 withmultiple 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 aformula like =SUM(Scores).

•

References by name to a named range are automatically updated every time therange’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 astring. 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, theexpression “$Sheet1.$A$1:$A$4~$Sheet1.$B$1:$B$4” encompasses two separate cellranges (the tilde character is a reference concatenation operator). Alternatively a formulaexpression such as “PI()*B1*B1” might be defined to calculate the area of a circle, given theradius. In the remainder of this section we will be concerned only with named ranges defined asa single rectangular cell range.
A quick way of creating a new named range is to select the relevant cells in your sheet and thensimply 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 456), which is opened
either by selecting Sheet > Named Ranges and Expressions > Define on the Menu bar or byclicking the Add button on the Manage Names dialog (Figure 457).

Associating a range with a name | 449

Figure 456: Define Name dialog
To create a named range, select a range of cells from a sheet, then open the Define Namedialog. 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 theManage Names dialog (Figure 457), which is opened by selecting Sheet > Named Ranges andExpressions > 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 457: Manage Names dialog
To reduce the typing required when referencing a named range, a Paste Names dialog (Figure458) 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 named450 | Chapter 13 Calc as a Databaserange and click the Paste button to insert the selected named range at the current cursor
position.

Figure 458: Paste Names dialog
For more detail about how to create and manage ranges, see Chapter 6, Printing, Exporting,
Emailing, and Signing, and Chapter 7, Using Formulas and Functions.

Creating named ranges using row or column headersWith the Create Names tool, which is accessed by selecting Sheet > Named Ranges andExpressions > Create on the Menu bar (Figure 459), 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 theranges.

Figure 459: Create Names dialog

Associating a range with a name | 451

To use the Create Names tool:
1) In a sheet, select the table from which to create the named ranges. Be sure to include theheader 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.
3) Calc automatically identifies which rows or columns contain headers, and will mark thecheckboxes – 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 fromthem 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 likea 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 thelast 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, whichis 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 460).

452 | Chapter 13 Calc as a Database

Figure 460: Define Database Range dialog
To create a database range:
1) If you want Calc to automatically determine the full extent of your database table, thenselect a single cell within its cell area. If you want to explicitly define the extent of thedatabase table, then select all relevant cells.
2) Open the Define Database Range dialog by selecting Data > Define Range on the Menubar.
3) Type a name for the range in the Name field. Only use letters, numbers, andunderscores; 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 toexpand 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 anexternal database source is linked to the range. To manually update the databaserange, 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 thesource 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 databaserange. For example, “Sort”, “Filter”, or “Subtotals”.
Associating a range with a name | 453

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 461). Next, select a
range in the Ranges list and click OK. Another way to select an existing database range is using
the Navigator deck on the Sidebar. Calc will automatically highlight the range’s position in the
sheet in which it is located.

Figure 461: Select Database Range dialog
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 orpressing Ctrl+Shift+F4.
2) In the left pane of the Data Sources Explorer, click the expand symbol at the left of thedata 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 theData 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.

454 | Chapter 13 Calc as a Database5) Drag and drop the data to the cell that is to be at the top left corner of the data in yourspreadsheet. 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 460) to update settings ofthe new database range.
Select Data > Refresh Range on the Menu bar to refresh the contents of a database range oncethe data in the associated data source is updated. The data in the sheet is updated to match thedata in the external database. Registering and linking to external database sources are explainedin more detail in Chapter 10, Linking Data.

Sorting
Sorting is the process of rearranging data in a range or a sheet according to a specified sortorder.
The simplest way to sort a database table based on the contents of a single column is to use theSort 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 combobox.
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 canalso select Sort Descending on the relevant column’s AutoFilter combo box.
When using the Sort Ascending and Sort Descending tools, Calc automatically identifies the fullcell range occupied by your table and sorts the entire area based only on the values in theindicated column. However, it also recognizes the first row as a header row and excludes it fromthe sort.
For more complex sorting, use the Sort dialog (Figure 462), 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 shownas selected when the dialog is displayed.
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 selectedin the Sort Key 3 drop-down. For example, if you chose Last Name for the first sort key and First
Name for the second sort key, the data would primarily be sorted by last name with all rows
sharing the same last name sorted by first name.
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, Editing, and Formatting Data, andthe Help system.

Sorting | 455

Figure 462: Sort dialog

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, Editing, and Formatting 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(Figure 463). 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 or click the AutoFilter
icon on the Standard toolbar. It is possible to add AutoFilters to individual columns by selecting
those columns before choosing Data > AutoFilter or clicking the AutoFilter icon, but this is notnormally necessary for a database table. To access the AutoFilter combo box for a column, clickon 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 thetable area and select Data > AutoFilter on the Menu bar, select Data > More Filters > Hide
AutoFilter on the Menu bar, or click the AutoFilter icon on the Standard toolbar. The downarrow buttons at the tops of columns will disappear.

456 | Chapter 13 Calc as a Database

Tip
Selecting Data > AutoFilter and clicking the AutoFilter icon normally toggle
AutoFilters on/off.
Each AutoFilter combo box provides the following options:•

A basic sort can be applied using the Sort Ascending and Sort Descending options.

•

Selecting the Top 10 filter causes the ten rows with the largest values to be displayed.
More than ten rows may be displayed if there are multiple instances of large values in acolumn. For example, if there are eleven students with a perfect score of 100, then thefilter will display all eleven instances. Similarly, if there are six students with a score of
100 and six other students with a score of 99, then the filter will display twelve instances.

•

Selecting Empty hides all non-empty rows that contain a value in the current column.
Likewise, selecting Not Empty hides all non-empty rows that lack a value in the current
column. Entirely empty rows are ignored but these would not be expected inside a
database table.

•

The Standard Filter option opens the Standard Filter dialog (Figure 464) andautomatically sets the current field as the field for the first condition in the dialog.

•

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 areprovided, 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 (forexample the “1” in Figure 463).

•

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 inthis column are not displayed. Change the filtering status of a particular value by marking
or removing the mark from the relevant check box.

Figure 463: AutoFilter combo box
Filtering | 457

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 464), which is accessed by selecting Data > More Filters > Standard Filteron 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, Editing,and Formatting Data.

Figure 464: Standard Filter dialog

Advanced filters
The criteria for an advanced filter are stored in a sheet rather than entered into a dialog. As aresult, you must first set up a cell range that contains the criteria before you use the Advanced
Filter dialog (Figure 465).

Figure 465: 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 definedfor a filter.
458 | Chapter 13 Calc as a Database

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 databasetable’s headings to the criteria area.
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 acell 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 465).
3) In the Read Filter Criteria From field, enter the address for the criteria range, either byselecting 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 DefineName and Manage Names dialogs (Figures 456 and 457 respectively). Only named
ranges marked for filtering in this way can be selected in the drop-down box in theRead 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 detailin Chapter 2, Entering, Editing, and Formatting Data.
Figure 466 demonstrates an example criteria range for the grading sheet example in Figure 455.

Figure 466: Advanced filter criteria range (in Sheet 2)
In this range, there are two criteria groups: the first displays the records of students who scoredabove a 75% in every homework, and the second displays records of any student named“Ferdinand”. Figure 467 displays the result of this filter operation using these criteria.

Figure 467: Grading sheet example filtered using an advanced filter

Filtering | 459

Useful database-like functions
Database category functions
Overview
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 thedata 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 thespecified SearchCriteria to identify the subset of records in the Database that are to be usedduring subsequent calculations. The second step is to extract the data values and perform thecalculations 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 therange contains the field names, and subsequent rows are records with corresponding fieldvalues.
One way of defining the range of cells is to enter the cell reference for the upper left-handcell, 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 tothe 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 thecell 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
460 | Chapter 13 Calc as a Databasethe header cell at F6. Calc expects an integer value that lies between 1 and thenumber 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 thevalue is greater than the number of columns in Database, Calc reports a #VALUE!
error.
– 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 anarbitrary cell (not within the Database and SearchCriteria areas) that contains therequired 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-handcell, 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 widthof 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 needappear 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 indifferent 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 > Calculatedialog. 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 regularexpressions have been enabled via the Enable regular expressions in formulas option on the
Tools > Options > LibreOffice Calc > Calculate dialog.

Useful database-like functions | 461

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 theevaluation 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 > Calculatedialog. This option controls whether the search criteria you set for the Database functions mustmatch the whole cell exactly. When interoperability with Microsoft Excel is important for yourspreadsheet, this option should be enabled.

Example of Database function use

Figure 468 - Example usage of a Database function
Figure 468 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 andcomprises 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 cellrange A1:E10.
•

DatabaseField argument. As the DCOUNT function counts the records that match thecriteria 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 overthe cell range A12:E13. The condition in cell D13 (“>600”) will cause DCOUNT to countall 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 databasetable within the search criteria area as shown in Figure 468. However this is not essential
and the formula =DCOUNT(A1:E10,,D12:D13) would give exactly the same value of 5.

462 | Chapter 13 Calc as a DatabaseMany more examples can be found by searching for “database functions” in the Help system, orby visiting the relevant page for each function within the Calc Functions Wiki athttps://wiki.documentfoundation.org/Documentation/Calc_Functions.

List of Database functions

Note
Calc will treat dates and logical values (such as TRUE or FALSE) as numeric whencalculating 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)
DCOUNTFor 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)
DCOUNTAFor 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 thespecified 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 theircontents.
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 numericvalues. 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 numericvalues. Blank cells or cells containing non-numeric characters are not included.
Useful database-like functions | 463

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: 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 thespecified column for the matching records.
Syntax: DPRODUCT(Database; DatabaseField; SearchCriteria)
DSTDEVFor 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 matchingrecords.
Returns 0 if no matches are found, or if there are no numeric values in the cells of thespecified 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 orcells 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 thespecified 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 matchingrecords.
Returns 0 if no matches are found, or if there are no numeric values in the cells of thespecified column for the matching records.
Syntax: DVAR(Database; DatabaseField; SearchCriteria)

464 | Chapter 13 Calc as a Database

DVARPFor 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 thesefunctions are intended for use with tabular data (such as HLOOKUP and VLOOKUP), whileothers 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 typicalspreadsheet 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.
Function

Category

Description

AGGREGATE

Mathematical

Returns an overall result calculated by applying a selected
aggregation function to the specified data. Nineteen selectable
aggregation functions are available, including average, count,large, maximum, median, minimum, mode, percentile, product,
quartile, small, standard deviation, sum, and variance.

AVERAGE

Statistical

Returns the arithmetic mean of the specified data, ignoring
empty cells and cells that contain text.

AVERAGEA

Statistical

Returns the arithmetic mean of the specified data, ignoring
empty cells but assigning the value 0 to any cell that contains
text.

AVERAGEIF

Statistical

Returns the arithmetic mean of all cells in a range that satisfy
a given criterion.

AVERAGEIFS

Statistical

Returns the arithmetic mean of all cells in a range that satisfy
multiple criteria in multiple ranges.

CHOOSE

Spreadsheet

Returns one value from the specified data, selected according
to the index passed as an argument.

COUNT

Statistical

Returns a count of the numeric values in the specified data,
ignoring empty cells and cells that contain text.

COUNTA

Statistical

Returns a count of the numeric and text values in the specified
data, ignoring empty cells.

COUNTBLANK

Statistical

Returns the number of empty cells in the specified data.

COUNTIF

Statistical

Returns the number of cells in a range that satisfy a given
criterion.

COUNTIFS

Statistical

Returns the number of cells that satisfy multiple criteria in
multiple ranges.

Useful database-like functions | 465

Function

Category

Description

HLOOKUP

Spreadsheet

Searches for a specified value in the first row of a table (often
a column heading) and returns a value retrieved from thesame column but a different row. HLOOKUP stands forhorizontal lookup.

INDEX

Spreadsheet

Returns the contents of one cell in a table. The position of thatcell is specified by row and column offsets. Can also be usedin an array formula context to retrieve data from multiple cells.

INDIRECT

Spreadsheet

Returns a valid reference constructed from a supplied string
representation of the reference. This function is powerful
because it enables a user to create dynamic references.

LOOKUP

Spreadsheet

Searches for a specified value in a single row or column andreturns a value from the same position in a second row orcolumn. It is not necessary for the search and result areas tobe adjacent.

MATCH

Spreadsheet

Returns the relative position of a search item in a single row orcolumn range.

MAX

Statistical

Returns the maximum value in the specified data, ignoring
empty cells and cells that contain text.

MAXA

Statistical

Returns the maximum value in the specified data, ignoring
empty cells but assigning the value 0 to any cell that contains
text.

MAXIFS

Statistical

Returns the maximum value of all cells in a range that satisfy
multiple criteria in multiple ranges.

MEDIAN

Statistical

Returns the median value of the specified data. The median ofa finite list of numbers is the "middle" number, when thosenumbers are listed in order from smallest to greatest.

MIN

Statistical

Returns the minimum value in the specified data, ignoring
empty cells and cells that contain text.

MINA

Statistical

Returns the minimum value in the specified data, ignoring
empty cells but assigning the value 0 to any cell that contains
text.

MINIFS

Statistical

Returns the minimum value of all cells in a range that satisfy
multiple criteria in multiple ranges.

MODE
MODE.SNGL

Statistical

Returns the mode value of the specified data. The mode is themost common value in a list of values. If there are several
values with the same frequency, the smallest value is returned.

MODE.MULT

Statistical

Returns a vertical array of the mode values of the specified
data. The mode is the most common value in a list of values.
The function returns more than one value when there are
multiple modes sharing the same frequency of occurrence.

OFFSET

Spreadsheet

Returns a modified reference to a single cell or a range ofcells, offset by a certain number of rows and columns from agiven reference point.

PRODUCT

Mathematical

Returns the product of the numeric values in the specified
data, ignoring empty cells and cells that contain text.

STDEV
STDEV.S

Statistical

Returns the sample standard deviation of the specified data,
ignoring empty cells and cells that contain text.

466 | Chapter 13 Calc as a DatabaseFunction

Category

Description

STDEVA

Statistical

Returns the sample standard deviation of the specified data,
ignoring empty cells but assigning the value 0 to any cell that
contains text.

STDEVPSTDEV.P

Statistical

Returns the population standard deviation of the specified
data, ignoring empty cells and cells that contain text.

STDEVPA

Statistical

Returns the population standard deviation of the specified
data, ignoring empty cells but assigning the value 0 to any cellthat contains text.

SUBTOTAL

Mathematical

Returns an overall result calculated by applying a selected
total function to the specified data. Eleven selectable total
functions are available, including average, count, maximum,
minimum, product, standard deviation, sum, and variance. Use
this function with AutoFilter to take only the filtered records into
account.

SUM

Mathematical

Returns the sum of the specified data, ignoring empty cells
and cells that contain text.

SUMIF

Mathematical

Returns the sum of all cells in a range that satisfy a given
criterion.

SUMIFS

Mathematical

Returns the sum of all cells in a range that satisfy multiple
criteria in multiple ranges.

VAR
VAR.S

Statistical

Returns the sample variation of the specified data, ignoring
empty cells and cells that contain text.

VARA

Statistical

Returns the sample variation of the specified data, ignoring
empty cells but assigning the value 0 to any cell that contains
text.

VARP
VAR.P

Statistical

Returns the population variation of the specified data, ignoring
empty cells and cells that contain text.

VARPA

Statistical

Returns the population variation of the specified data, ignoring
empty cells but assigning the value 0 to any cell that contains
text.

VLOOKUP

Spreadsheet

Searches for a specified value in the first column of a table(often a row heading) and returns a value retrieved from thesame row but a different column. VLOOKUP stands for verticallookup.

Useful database-like functions | 467

Calc Guide

Chapter 14
Setting up and Customizing

Introduction
This chapter presents some of the setup options found under Tools > Options on the Menu bar(LibreOffice > Preferences on macOS). Additional options, and more details about those given
here, are covered in the Help and in Chapters 2 (Setting up LibreOffice) and 14 (Customizing
LibreOffice) in the Getting Started Guide.
This chapter also describes some common customizations to menus, toolbars, and keyboard
shortcuts. Other customizations are made easy by extensions that you can install from the
LibreOffice website or from other providers.

LibreOffice options
This section covers some of the settings that apply to all the components of LibreOffice and areof particular interest to users of Calc.
1) Choose Tools > Options to open the Options dialog. The list on the left-hand side varies
depending on which LibreOffice component is open. 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. A list of subsections drops
down.

Figure 469: 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 placewhen you opened the dialog.

LibreOffice options | 469

User data
User data is used by templates and wizards in LibreOffice. For example, Calc uses the first andlast name stored here to fill in the Created and Modified fields in the document properties. These
fields may also be used in the footer of a printed spreadsheet or as the name associated withcomments. If you want your name to appear, then fill in the form on the LibreOffice – User Data
page.

View
The options on the LibreOffice – View page affect how the document window looks and behaves,including the size and style of toolbar and Sidebar icons. Set these options to suit your personal
preferences.

Print
On the LibreOffice – Print page, you can set the print options to suit your default printer and yourmost common printing method. You can change these settings at any time, either through this
dialog or during the printing process (through the Print dialog).
Calc-specific print options are described in “Print options” on page 486.
See Chapter 6, Printing, Exporting, Emailing, and Signing, for more about these options.

Paths
On the LibreOffice – Paths page, you can change the location of files associated with, or used by,
LibreOffice to suit your needs. For example, you might want to store spreadsheets by default ona shared server. Some items can have at least two paths listed: one to a shared folder (whichmight be on a network) and one to a user-specific folder (normally on the user’s personal
computer).

Security
Use the LibreOffice – Security page to choose security options for saving documents and for
opening documents that contain macros.

Figure 470: Choosing security options for opening and saving documents
470 | Chapter 14 Setting up and Customizing

Security Options and Warnings
If you record changes, save multiple versions, or include hidden information or notes inyour 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 LibreOfficeremove some information automatically. Note that (unless removed) much of thisinformation 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 471).
Passwords for Web Connections
You can enter a master password to enable easy access to websites that require a username 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 thepasswords from the list after you enter the master password.
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. LibreOfficedoes not provide a secure method of storing these certificates, but it can access certificatesthat have been saved using other programs. Click the Certificate button and select which
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 optionally 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 wassigned. 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 notaltered after the date the timestamp vouches for.

Security Options and Warnings
The following options are on the Security Options and Warnings dialog (Figure 471).
Remove personal information on saving
Select this option to always remove user data from the file properties when saving the file.
To manually remove personal information from specific documents, deselect this option andthen 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.
The other options on this dialog should be self-explanatory.

LibreOffice options | 471

Figure 471: Security Options and Warnings dialog

Application colors
On the LibreOffice – Application Colors page (Figure 472), you can specify which user interface
elements are visible and the colors used to display them. Scroll down the list until you find thesection 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 472: 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 Nameof color scheme box in the pop-up dialog, and then click OK.
472 | Chapter 14 Setting up and Customizing

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.
Enable macro recording (may be limited)
This option enables macro recording, with some limitations. For more about macro
recording, see Chapter 13, Getting Started with Macros, in the Getting Started Guide, andChapter 12, Macros, in this book.

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 ofthe options, those most relevant to working with Calc. See Chapter 2, Setting up LibreOffice, in
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 ofload/save options pages.

GeneralMany of the choices on the Load/Save – General page (Figure 473) are familiar to users of otheroffice suites. Those of most interest to Calc users are in the Default File Format and ODF
Settings section.

Figure 473: Choosing Load and Save general options
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 mightwant 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.
Options for loading and saving documents | 473

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.

VBA Properties
On the Load/Save – VBA Properties page (Figure 474), you can choose whether to keep any
VBA (Visual Basic for Applications) macros in Microsoft Office documents that are opened in
LibreOffice.

Figure 474: Choosing
Load/Save VBA Properties
If you choose Load Basic code, you can edit the macros in LibreOffice. The changed code issaved 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 inspect
it with the LibreOffice Basic IDE you will notice that it is all commented), with this option the codeis 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 Saveoriginal Basic code. The document will be saved without the Microsoft Basic code.

Microsoft Office
On the Load/Save – Microsoft Office page (Figure 475), you can choose what to do whenimporting 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.

474 | Chapter 14 Setting up and Customizing

Figure 475: 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 sharedspreadsheets. 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 476) affect how LibreOfficeimports or exports HTML pages. See Chapter 2, Setting up LibreOffice, in 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 theheader 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 12, 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 serverwhen uploading using FTP.

Options for loading and saving documents | 475

Character set
Select the appropriate character set for the export.

Figure 476: 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 477).

Figure 477: Calc options

GeneralThe choices on the LibreOffice Calc – General page (Figure 478) affect the units used for rulers
and other measurements, the default tab stop positions, the updating of links and fields, andvarious input settings.
Metrics
Choose the unit of measurement used in spreadsheets and the default tab stops distance.
Update links when opening
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 thisoption is set to Always.
476 | Chapter 14 Setting up and Customizing

Figure 478: 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 thedirection 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 andmove 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 inanother cell by pressing the Enter key. After pasting occurs, the clipboard is cleared. Hereyou can enable/disable this feature.
Expand formattingSpecifies whether to automatically apply the formatting attributes of the selected cell toempty 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 signon 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 nolonger 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 thereference range. This is only possible if the reference range, where the column or row isinserted, originally spanned at least two cells in the desired direction.

Calc-specific options | 477

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 newrow is inserted under row 1, the reference is not expanded, since there is only a single cellin 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 notselected, 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 thenselecting 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 isin 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 inthe 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 bydefault 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 479) 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 an empty cell.
Comment indicator
Select this option to show a small symbol in the top right corner of a cell that contains acomment.
To always display a comment, right-click on the cell and select Show comment in thecontext menu.

478 | Chapter 14 Setting up and Customizing

Figure 479: Selecting view options for Calc
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 number by Calc; formulas are displayed in green. When this option is active, any colors
assigned in the document are not displayed.
Anchor
If an inserted object, such as a picture, is anchored to a cell, an image of an anchor willappear in the cell to which the object is anchored.
Text overflow
If a cell contains text that is wider than the width of the cell, the text is displayed over empty
neighboring cells in the same row. If there is no empty neighboring cell, a small triangle atthe cell border indicates that the text continues. If this option is selected, text will wrap
inside the cell and the height of the row will expand to accommodate the hight of the
expanded cell.
Show references in color
Select this option to provide a visual aid to assist the editing of a formula. Each reference isthen highlighted in color in the formula, and the referenced cell range is enclosed by acolored border as soon as the cell containing the reference is selected for editing.

Figure 480: 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, Editing, and Formatting Data.
Calc-specific options | 479

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 theselection made in Tools > Options > LibreOffice > Application Colors > Spreadsheet >Grid lines.

Note
To print grid lines, choose Format > Page > Sheet > Print > Grid.
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 otherobjects. These lines help you align objects.
In Figure 481, 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 481: 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 beapplied to individual sheets.

480 | Chapter 14 Setting up and Customizing

Calculate
Use the LibreOffice Calc – Calculate page (Figure 482) to define the calculation settings for
spreadsheets.

Figure 482: 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 beinteroperable with Microsoft Excel.
The options listed above are mutually exclusive. For more information about them, see Chapter
7, 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 areimported from foreign formats.

Calc-specific options | 481

General Calculations section
Specify a variety of options relevant to spreadsheet calculation.
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 notmarked, 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 ofthe 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 thetarget. 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 ofrounding.
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 theiteration 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 7, Using
Formulas and Functions for more information.

482 | Chapter 14 Setting up and Customizing

Caution
When calculations involve a range that includes an empty cell, take note of thesetting for Zero values in the LibreOffice Calc > View options. If this option is notselected, a value of zero will display as an empty cell. Empty cells and the value zeroare 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 whichcontains 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).

FormulaUse the LibreOffice Calc – Formula page (Figure 483) to specify the following formula options.

Figure 483: Formula options
Formula syntax
Syntax is the format in which formulas are written. Choose the syntax most appropriate foryour 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.
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 locale
is not English, you may wish to express functions in English; if so, select this option tochange formula input and display, Function Wizard, and formula tips.
Calc-specific options | 483

Separators
Separators are used in functions to distinguish points in the range used in the function: thesymbols 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 infunctions 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 notneed to update your large spreadsheet data immediately, you can postpone therecalculation to a better time. Calc allows you to defer recalculation of Excel 2007 (andmore 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, wheresuch cached formula results may not exist, recalculation can be deferred to speed up fileloading as with Excel 2007 files.
For each of these two options, the following choices are possible: Never recalculate (noformulas will be recalculated on loading the file), Always recalculate (all formulas will berecalculated on file load), and Prompt user (prompt user for action).
Calc saved ODF spreadsheets will honor Never recalculate and Always recalculate options.

Sort lists
View, define, delete, and edit sort lists on the LibreOffice Calc – Sort Lists page. Sort lists areused for more than sorting, for example filling a series of cells during data entry. They are lists
that are sorted in a particular order but not alphabetically or numerically; for example, days of theweek. In addition to the supplied lists, you can define and edit your own lists, as described in
Chapter 2, Entering, Editing, and Formatting Data.

Figure 484: Defining sorting lists in Calc

484 | Chapter 14 Setting up and Customizing

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 thelatter case, one color will apply to all changes made by that author. The selections made here areapplied when change recording is enabled by Edit > Track Changes > Record on the Menu bar.

Figure 485: Calc options for highlighting changes

Compatibility
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 thedefaults are identical, but there are some differences.
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

DeleteImmediately deletes contents

Opens Delete Contents dialog

Control+D(Command+D on macOS)

Fills cell content down within
selection

Opens the Selection List
dialogAlt+DownArrow(Option+DownArrow onmacOS)

Select header of range;no action in empty cell

Increases row heightCalc-specific options | 485

Grid options
The LibreOffice Calc – Grid page defines the grid settings for spreadsheets. Using a grid helps
you 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, you can 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 486: Calc grid options

Print options
Use the LibreOffice Calc - Print page to choose defaults for printing spreadsheets. You canoverride these for individual print jobs.

Figure 487: 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” on page 498.
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.
486 | Chapter 14 Setting up and Customizing

Click Default to restore the color settings that were defined when the program was installed.

Figure 488: Defining chart colors

Customizing the user interface
You can customize menus, toolbars, keyboard shortcuts, and the tabbed interface; add newmenus and toolbars; and assign macros to events.

Tip
Changes to menus and toolbars can be saved in a template. First, save them in adocument; 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 489) or the Context Menus tab. The following examples focus on the
Menus tab but the Context Menus tab is similar in appearance and behavior.

Customizing the user interface | 487

Figure 489: The Menus tab of the Customize dialog

Modifying an existing menu
1) In the Scope drop-down list in the upper right of the Customize dialog, choose whether tosave 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 areshown in the Assigned Commands list below.
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 anddown arrows on the far right-hand side to move the command into the place where youwant 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.

488 | Chapter 14 Setting up and Customizing

Figure 490: Customize dialog, Menus tab,Insert drop-down
6) To rename a menu item, select it in the Assigned Commands list and choose Renamefrom the Modify drop-down below.

Figure 491: 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
1) On the Menus tab of the Customize dialog, click the button next to the Target field (Figure492) and select Add in the drop-down list, to display the New Menu dialog (Figure 493).

Figure 492: 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, as described above formodifying a menu.

Customizing the user interface | 489

Figure 493: 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 andthe Art menu will open.

CautionWhen 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 andlocking the position of a docked toolbar, as described in Chapter 1, Introducing LibreOffice, of theGetting 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 494), do any of the following:•

On the toolbar, right-click in the toolbar and choose Customize Toolbar.

490 | Chapter 14 Setting up and Customizing•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 494: 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 yoursearch 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.
Customizing the user interface | 491

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 thebottom right.
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 andselect 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 ismade 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 495), scroll through the available icons, select one, and click OK to
assign it to the command.

Figure 495: Change Icon dialog

492 | Chapter 14 Setting up and CustomizingTo use a custom icon, create it in a graphics program and import it into LibreOffice by clicking theImport 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 ofcommands and contents. You can find more information about these variants in the Help system,by searching for “notebook bar” in the index.
One of the variants is Tabbed. In this variant, 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 496) to show andhide the individual options on the various tabs that are provided in the Tabbed user interface.

Figure 496: The Notebookbar tab of the Customize dialog
Use the Reset button to reset the Tabbed configuration to the default settings.

Customizing the user interface | 493

NoteThree notebook bar variants can be selected through View > User Interface on the
Menu bar: Tabbed, Tabbed Compact, and Groupedbar Compact. However, only the
first of these can be modified using the Notebookbar tab of the Customize dialog.

Keyboard shortcuts
In addition to using the built-in keyboard shortcuts (listed in Appendix A), you can define yourown. You can assign shortcuts to standard LibreOffice functions or your own macros and savethem for use with the entire LibreOffice suite or only for Calc.

CautionAvoid reassigning your operating system’s predefined shortcut keys.

Note
Shortcut keys that are grayed out in the listing on the Customize dialog, such as F1and F10, are not available for reassignment.
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 497).
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 from the Category and Function lists.
4) Now select the desired shortcut keys in the Shortcut Keys list and click the Modify 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 isfree for use. If it were not, and you wanted to reassign a shortcut key combinationthat is already in use, you must first delete the existing key.

494 | Chapter 14 Setting up and Customizing

Figure 497: Customizing a keyboard shortcut

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, orto 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 497).
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.

Customizing the user interface | 495

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 theLoad 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 arestrictly user-defined; none are built in. For more information on macros, see Chapter 12, Macros.

Assigning macros to events
In LibreOffice, when something happens, we say that an event occurred. For example, adocument was opened, a key was pressed, or the mouse moved. You can associate a macrowith an event, so the macro is run when the event occurs. A common use is to assign the “opendocument” 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 Chapter 13, Getting Started with Macros, in 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 > Extension Manager 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 yourcomputer.
3) After the extension is downloaded and saved, return to the Extension Manager dialog andclick 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 Extension Manager dialog.
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 Extension Manager dialog to check for updates toinstalled extensions.

496 | Chapter 14 Setting up and Customizing

Removing and disabling extensions
To remove (uninstall) an extension that you installed, select the extension in the main window of
the Extension Manager dialog and click the Remove button.
To disable an extension without removing (uninstalling) it, select the extension in the main
window of the Extension Manager dialog and click the Disable button, which then changes to
Enable.

Tip
Extensions can be installed from some other places in Calc, such as the Gallery on
the Sidebar, the Templates dialog, the Language Settings > Writing Aids page of theTools > 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 afiltered 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 yourLibreOffice installation.

Figure 498: The Extension Manager dialog

Adding functionality with extensions | 497

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 499). 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 500).
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 499: Defining a new color

498 | Chapter 14 Setting up and Customizing

Figure 500: Defining a color by picking it from a color
chart

Adding custom colors | 499

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 aredescribed in this chapter, assuming no customization. When using Calc, you can discovershortcuts 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 thechapters 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 14, 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 509 (Windows / Linux) and 517 (macOS).

CautionBe 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 asleep / 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 areused 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.

Windows / Linux keyboard shortcuts | 501

Keyboard shortcuts for Menu bar options and toolbars
Tables 19 to 22 list Calc keyboard shortcuts that can be used instead of the options on the Menubar, the Standard toolbar, or the Formatting toolbar. The toolbars are assumed to contain theinitial default set of icons, without any user customization.
Table 19: 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.

F7

Tools > Spelling.
Spelling icon on the Standard toolbar.

Ctrl+F7

Tools > Thesaurus.

Ctrl+Shift+F7

Tools > Language > Hangul/Hanja Conversion. The availability of thismenu 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.

F11

View > Styles.
Styles > Manage Styles.

Shift+F11

File > Templates > Save as Template.
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+F12Tools > Options.

Table 20: Number key shortcuts for menu and toolbar options
Windows / Linux

Equivalent Menu bar / toolbar option

Ctrl+1

Format > Cells.

Ctrl+Shift+1

Format > Number Format > Number (use the “1” key on the main
keyboard).
Format as Number icon on the Formatting toolbar.

502 | Appendix A Keyboard Shortcuts

Windows / Linux

Equivalent Menu bar / toolbar option

Ctrl+Shift+2

Format > Number Format > Scientific (use the “2” key on the main
keyboard).

Ctrl+Shift+3

Format > Number Format > Date (use the “3” key on the main keyboard).
Format as Date icon on the Formatting toolbar.

Ctrl+Shift+4

Format > Number Format > Currency (use the “4” key on the main
keyboard).
Format as Currency icon on the Formatting toolbar.

Ctrl+Shift+5

Format > Number Format > Percent (use the “5” key on the main keyboard).
Format as Percent icon on the Formatting toolbar.

Ctrl+Shift+6

Format > Number Format > General (use the “6” key on the main
keyboard).

Note
The Format > Spacing menu appears to provide shortcuts for Line Spacing: 1.5(Ctrl+5) and Line Spacing: 2 (Ctrl+2). However these options are never active in
Calc 7.1 and so the shortcuts are not included in Table 20.
Table 21: Letter key shortcuts for menu and toolbar options
Windows / Linux

Equivalent Menu bar / toolbar option

Ctrl+B

Format > Text > Bold.
Bold icon on the Formatting toolbar.

Ctrl+Shift+B

Format > Text > Subscript.

Ctrl+C

Edit > Copy.
Copy icon on the Standard toolbar.

Ctrl+Shift+C

Edit > Track Changes > Record.

Ctrl+Alt+C

Insert > Comment.
Sheet > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.

Ctrl+D

Sheet > Fill Cells > Fill Down.
Via drop-down menus on Row or Column icons on the Standard toolbar.

Ctrl+E

Format > Align > Centered.
Align Center icon on the Formatting toolbar.

Ctrl+Alt+E

Tools > Extension Manager.

Ctrl+F

Edit > Find.

Ctrl+H

Edit > Find and Replace.
Find and Replace icon on the Standard toolbar.

Ctrl+I

Format > Text > Italic.
Italic icon on the Formatting toolbar.

Ctrl+J

Format > Align > Justified.

Ctrl+Shift+J

View > Full Screen.

Ctrl+K

Insert > Hyperlink.
Insert Hyperlink icon on the Standard toolbar.

Windows / Linux keyboard shortcuts | 503

Windows / Linux

Equivalent Menu bar / toolbar option

Ctrl+L

Format > Align > Left.
Align Left icon on the Formatting toolbar.

Ctrl+M

Format > Clear Direct Formatting.
Clear Direct Formatting icon on the Standard toolbar.

Ctrl+Shift+M

Edit > Edit Mode.

Ctrl+N

File > New > Spreadsheet.
New icon on the Standard toolbar.

Ctrl+Shift+N

File > New > Templates.
File > Templates > Manage Templates.
Via drop-down menu on New icon on the Standard toolbar.

Ctrl+O

File > Open.
Open icon on the Standard toolbar.

Ctrl+Shift+O

File > Print Preview.
Toogle Print Preview icon on the Standard toolbar.

Ctrl+P

File > Print.
Print icon on the Standard toolbar.

Ctrl+Shift+P

Format > Text > Superscript.

Ctrl+Q

File > Exit LibreOffice.

Ctrl+R

Format > Align > Right.
Align Right icon on the Formatting toolbar.

Ctrl+S

File > Save.
Save icon on the Standard toolbar.

Ctrl+Shift+S

File > Save As.
Via drop-down menu on Save icon on the Standard toolbar.

Ctrl+U

Underline icon on the Formatting toolbar.

Ctrl+V

Edit > Paste.
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.

Ctrl+X

Edit > Cut.
Cut icon on the Standard toolbar.

Ctrl+Y

Edit > Redo.
Redo icon on the Standard toolbar.

Ctrl+Shift+Y

Edit > Repeat.

Ctrl+Z

Edit > Undo.
Undo icon on the Standard toolbar.

504 | Appendix A Keyboard Shortcuts

Table 22: 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 down

Edit > Select > Select to Next Sheet.

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).

Ctrl+;

Insert > Date.

Ctrl+Shift+;

Insert > Time.

Ctrl+`

View > Show Formula. The grave (`) character can be found to the left of
the “1” key on many English keyboards. In the Windows build of LibreOffice
Calc 7.1, the grave character is omitted from the menu option.

Other Calc keyboard shortcuts
Tables 23 to 28 provide lists of additional Calc keyboard shortcuts that may be less obvious tousers because they are not indicated on Menu bar items or in tooltips associated with icons on
the Standard and Formatting toolbars.
Table 23: 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 thecurrent cell.

Ctrl+Shift+F5
Ctrl+Shift+T

Moves the cursor to the Name Box field on the Formula bar.

Table 24: 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.

Windows / Linux keyboard shortcuts | 505

Table 25: Arrow key shortcuts
Windows / Linux

Description↑

Moves the cell focus up.

Ctrl+↑

Moves the cursor in the up direction to the edge of the current data range (ifthe 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.

Ctrl+Shift+↑

Selects in the up direction to the edge of the current data range (if 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 right.

Ctrl+→

Moves the cursor in the right direction to the edge of the current data range(if the cell adjacent to the cursor is empty, the cursor moves to the next cellthat contains data).

Shift+→

Selects the adjacent cell or cells located in the right direction.

Ctrl+Shift+→

Selects in the right direction to the edge of the current data range (if 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.

Ctrl+↓

Moves the cursor in the down direction to the edge of the current data range(if the cell adjacent to the cursor is empty, the cursor moves to the next cellthat 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.

Ctrl+Shift+↓

Selects in the down direction to the edge of the current data range (if 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.

Ctrl+←

Moves the cursor in the left direction to the edge of the current data range (ifthe 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.

Ctrl+Shift+←

Selects in the left direction to the edge of the current data range (if the 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.

506 | Appendix A Keyboard Shortcuts

Table 26: 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.

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 inthe current sheet.

Shift+End

Selects cells along the current row from the cursor to the cell in the lastcolumn 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 27: 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 28: Other miscellaneous key shortcuts
Windows / Linux

Description

EscapeCancels the current cell edit.

InsertAfter making a selection, opens the Paste Special dialog.

Ctrl+Insert

Copies the selected cell or cell range to the clipboard in preparation for alater paste operation.

Shift+Insert

Pastes the contents of the clipboard into the selected cells.

DeleteDeletes 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.

Windows / Linux keyboard shortcuts | 507

Windows / Linux

Description

Ctrl+/

Selects the cells in the matrix formula range that contains the cursor.

Ctrl+’

Copies the contents of the cell above the cursor into the current cell, but
remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.

Enter

Moves the cursor to the next cell in the selected range, from top to 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 29 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 moveelements with a finer degree of movement for more accuracy.
Table 29: Chart shortcuts
Windows / Linux

EffectTab

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
chartsMoves the selected pie segment in the direction of the arrow.

F2 in titles

Enters text input mode.

F3 in legends anddata series

Opens groups so that you can edit the individual components.

Ctrl+F3 in legends
and data series

Exits groups.

+/-

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).

508 | Appendix A Keyboard Shortcuts

Outline keyboard shortcuts
Table 30 lists shortcuts that are available in an outline window. To use these shortcuts, press F6or Shift+F6 until the vertical or horizontal outline window has the focus.
Table 30: Outline shortcuts
Windows / Linux

EffectTab

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-numberedlevels 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 31 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 31: Grayed key combinations in Tools > Customize > Keyboard
Operatingsystem

Key combinations grayed in Customize dialog

Windows 10

F1, Ctrl+F1, Shift+F1
Shift+F2
Ctrl+F4, Alt+F4, Ctrl+Alt+F4
F6, Ctrl+F6, Shift+F6, Ctrl+Shift+F6
F10

Linux

F1, Ctrl+F1, Shift+F1
Shift+F2
Ctrl+F4, Alt+F4, Ctrl+Alt+F4
F6, Ctrl+F6, Shift+F6, Ctrl+Shift+F6
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

Windows / Linux keyboard shortcuts | 509

macOS keyboard shortcuts
macOS keyboard symbols
Keys on many macOS keyboards use symbols rather than text labels. Table 32 identifies somecommon 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 32: Common macOS keyboard symbols
Key name

SymbolCommand (shortened to “Cmd” in the tables that follow)
Control (shorted to “Ctrl” in the tables that follow)
Option
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
DeleteForward Delete (shortened to “Fwd Del” in the tables that follow)

Keyboard shortcuts for Menu bar options and toolbars
Tables 33 to 36 list Calc keyboard shortcuts that can be used instead of the options on the Menubar, the Standard toolbar, or the Formatting toolbar. The toolbars are assumed to contain theinitial default set of icons, without any user customizations.
Table 33: Function key shortcuts for menu and toolbar options
macOS

Equivalent Menu bar / toolbar option

F1

Help > LibreOffice Help.

F2

Edit > Cell Edit Mode.

Cmd+F2Insert > 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+F5View > Sidebar.

Shift+F5

Tools > Detective > Trace Dependents.

Cmd+F7

Tools > Thesaurus.

Shift+Cmd+F7

Tools > Language > Hangul/Hanja Conversion. The availability of this menu
option depends on selections in LibreOffice > Preferences > Language
Setting > Languages.

510 | Appendix A Keyboard Shortcuts

macOS

Equivalent Menu bar / toolbar option

Shift+F7

Tools > Automatic Spell Checking.

Cmd+F8View > Value Highlighting.

F9

Data > Calculate > Recalculate.

Shift+F9

Tools > Detective > Trace Precedents.

Shift+Cmd+F9

Data > Calculate > Recalculate Hard.

Shift+F11

File > Templates > Save as Template.
Via drop-down menu on Save icon on Standard toolbar.

F12

Data > Group and Outline > Group.

Cmd+F12

Data > Group and Outline > Ungroup.

Table 34: Number key shortcuts for menu and toolbar options
macOS

Equivalent Menu bar / toolbar option

Cmd+1

Format > Cells.

Ctrl+Shift+1

Format > Number Format > Number (use the “1” key on the main keyboard).
Format as Number icon on Formatting toolbar.

Ctrl+Shift+2

Format > Number Format > Scientific (use the “2” key on the main
keyboard).

Ctrl+Shift+3

Format > Number Format > Date (use the “3” key on the main keyboard).
Format as Date icon on Formatting toolbar.

Ctrl+Shift+4

Format > Number Format > Currency (use the “4” key on the main
keyboard).
Format as Currency icon on Formatting toolbar.

Ctrl+Shift+5

Format > Number Format > Percent (use the “5” key on the main keyboard).
Format as Percent icon on Formatting toolbar.

Ctrl+Shift+6

Format > Number Format > General (use the “6” key on the main keyboard).

Note
The Format > Spacing menu appears to provide shortcuts for Line Spacing: 1.5(Cmd+5) and Line Spacing: 2 (Cmd+2). However, these options are never active in
Calc 7.1 and so the shortcuts are not included in Table 34.
Table 35: Letter key shortcuts for menu and toolbar options
macOS

Equivalent Menu bar / toolbar option

Cmd+B

Format > Text > Bold.
Bold icon on the Formatting toolbar.

Shift+Cmd+B

Format > Text > Subscript.

Cmd+C

Edit > Copy.
Copy icon on the Standard toolbar.

Shift+Cmd+C

Edit > Track Changes > Record.

Option+Cmd+C

Insert > Comment.
Sheets > Cell Comments > Edit Comment.
Insert Comment icon on the Standard toolbar.

macOS keyboard shortcuts | 511

macOS

Equivalent Menu bar / toolbar option

Cmd+D

Sheet > Fill Cells > Fill Down.

Cmd+E

Format > Align > Centered.
Align Center icon on the Formatting toolbar.

Option+Cmd+E

Tools > Extension Manager.

Cmd+F

Edit > Find.

Option+Cmd+F

Edit > Find and Replace.
Find and Replace icon on the Standard toolbar.

Ctrl+Cmd+F

View > Full Screen.

Cmd+H

LibreOffice > Hide LibreOffice.

Cmd+I

Format > Text > Italic.
Italic icon on the Formatting toolbar.

Cmd+J

Format > Align > Justified.

Cmd+K

Insert > Hyperlink.
Insert Hyperlink icon on the Standard toolbar.

Cmd+L

Format > Align > Left.
Align Left icon on the Formatting toolbar.

Ctrl+M

Format > Clear Direct Formatting.
Clear Direct Formatting icon on the Standard toolbar.

Shift+Cmd+M

Edit > Edit Mode.

Cmd+N

File > New > Spreadsheet.
New icon on the Standard toolbar.

Shift+Cmd+N

File > New > Templates.
File > Templates > Manage Templates.
Via drop-down menu on New icon on the Standard toolbar.

Cmd+O

File > Open.
Open icon on the Standard toolbar.

Shift+Cmd+O

File > Print Preview.
Toogle Print Preview icon on the Standard toolbar.

Cmd+P

File > Print.
Print icon on the Standard toolbar.

Shift+Cmd+P

Format > Text > Superscript.

Cmd+Q

LibreOffice > Quit LibreOffice.

Cmd+R

Format > Align > Right.
Align Right icon on the Formatting toolbar.

Cmd+S

File > Save.
Save icon on the Standard toolbar.

Shift+Cmd+S

File > Save As.

Cmd+T

View > Styles.
Styles > Manage Styles.

Cmd+U

Underline icon on the Formatting toolbar.

Cmd+V

Edit > Paste.
Paste icon on the Standard toolbar.

512 | Appendix A Keyboard Shortcuts

macOS

Equivalent Menu bar / toolbar option

Shift+Cmd+V

Edit > Paste Special > Paste Special.

Option+Shift+Cmd+V

Edit > Paste Special > Paste Unformatted Text.

Cmd+W

Window > Close Window.

Cmd+X

Edit > Cut.
Cut icon on the Standard toolbar.

Cmd+Y

Edit > Redo.
Redo icon on the Standard toolbar.

Shift+Cmd+Y

Edit > Repeat.

Cmd+Z

Edit > Undo.
Undo icon on the Standard toolbar.

Table 36: Other shortcuts for menu and toolbar options
macOS

Equivalent Menu bar / toolbar option

Shift+Cmd+Pg Up

Edit > Select > Select to Previous Sheet. (In Calc 7.1, the menu option
indicates an up arrow symbol rather than a page up symbol).

Shift+Cmd+Pg Dn

Edit > Select > Select to Next Sheet. (In Calc 7.1, the menu option
indicates a down arrow symbol rather than a page down symbol).

DeleteSheet > Clear Cells.

Ctrl+Space

Edit > Select > Select Column.

Shift+Space

Edit > Select > Select Row.

Ctrl+Shift+Space
Cmd+A

Edit > Select All.

Cmd++

Sheet > Insert Cells (use the + key on the numeric keypad).

Cmd+-

Sheet > Delete Cells.

Cmd+*

Edit > Select > Select Data Area.

Cmd+;

Insert > Date.

Shift+Cmd+;

Tools > Spelling.
Spelling icon on the Standard toolbar.

Cmd+,

LibreOffice > Preferences.

Other Calc keyboard shortcuts
Tables 37 to 42 provide lists of additional Calc keyboard shortcuts that may be less obvious tousers because they are not indicated on Menu bar items or in tooltips associated with icons on
the Standard and Formatting toolbars.
Table 37: 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 thecurrent cell.

Shift+Cmd+F5
Shift+Cmd+T

Moves the cursor to the Name Box field on the Formula bar.

macOS keyboard shortcuts | 513

macOS

Description

F8

Toggles between the standard and extending selection modes.

Shift+F8

Toggles between the standard and adding selection modes.

Table 38: 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.

Table 39: Arrow key shortcuts
macOS

Description↑

Moves the cell focus up.

Cmd+↑

Moves the cursor in the up direction to the edge of the current data range (ifthe 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.

Shift+Cmd+↑

Selects in the up direction to the edge of the current data range (if 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 right.

Cmd+→

Moves the cursor in the right direction to the edge of the current data range (ifthe 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.

Shift+Cmd+→

Selects in the right direction to the edge of the current data range (if 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.

Cmd+↓

Moves the cursor in the down direction to the edge of the current data range (ifthe 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.

Shift+Cmd+↓

Selects in the down direction to the edge of the current data range (if 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.

514 | Appendix A Keyboard Shortcuts

macOS

Description

Cmd+←

Moves the cursor in the left direction the edge of the current data range (if thecell 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.

Shift+Cmd+←

Selects in the left direction to the edge of the current data range (if the 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.

Table 40: 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+EndMoves the cursor to the cell in the last column and row that contain data in thecurrent sheet.

Shift+End

Selects cells along the current row from the cursor to the cell in the lastcolumn 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 41: 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 Dn

Selects cells from the cursor to the column one page to the left.

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 Up

Selects cells from the cursor to the column one page to the right.

Table 42: Other miscellaneous key shortcuts
macOS

Description

Esc

Cancels the current cell edit.

Fwd DelDeletes cell contents without a dialog (does not remove formatting).
macOS keyboard shortcuts | 515

macOS

Description

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.

Cmd+/

Selects the cells in the matrix formula range that contains the cursor.
Use the forward slash key on the main keyboard or the numeric keypad.

Cmd+’

Copies the contents of the cell above the cursor into the current cell, but
remains in cell edit mode so that you can make further changes.
Use the single apostrophe key.

Enter

Moves the cursor to the next cell in the selected range, from top to 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 43 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 tomove elements with a finer degree of movement for more accuracy.
Table 43: 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
chartsMoves the selected pie segment in the direction of the arrow.

F2 in titles

Enters text input mode.

F3 in legends anddata series

Opens groups so that you can edit the individual components.

Cmd+F3 in legends
and data series

Exits groups.

516 | Appendix A Keyboard Shortcuts

Outline keyboard shortcuts
Table 44 lists shortcuts that are available in an outline window. To use these shortcuts, press F6or Shift+F6 until the vertical or horizontal outline window has the focus.
Table 44: Outline shortcuts
macOS

Effect⇥Cycles through each outline indicator from top to bottom or left to right.

Shift+⇥

Cycles through each outline indicator in the opposite direction.

Cmd+1 to
Cmd+8Show all levels up to the specified number while hiding all higher-numberedlevels 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 45 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 45: Grayed key combinations in Tools > Customize > Keyboard
Operatingsystem

Key combinations grayed in Customize dialog

macOS

F1, Cmd+F1, Shift+F1
Shift+F2
Cmd+F4, Option+F4, Cmd+Option+F4
F6, Cmd+F6, Shift+F6, Shift+Cmd+F6
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+9macOS keyboard shortcuts | 517

Calc Guide

Appendix B
Error CodesIntroduction to Calc error codes
Calc provides feedback for errors of miscalculation, incorrect use of functions, invalid cellreferences and values, and other user initiated mistakes. The feedback may be displayed within
the cell that contains the error (Figure 501), or on the Status bar (Figure 502), 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 501 shows the error code returned when a column is too narrow todisplay the entire formatted date. The date displayed within the input line, 04/05/1998, would fit
within the cell without a problem, but the format used by the cell produces the date value
Sunday, April 05, 1998.

Figure 501: Error codes displayed within cells
When the cell displaying the #REF! error code in Figure 501 is selected, the Status bar displays
the error message as shown in Figure 502. This message is more descriptive than the message
displayed in the cell, but it still may not provide enough information to correctly diagnose theproblem. For fuller explanations, consult the following tables and the Help topic, Error Codes in
LibreOffice Calc.

Figure 502: An error message displayed in the Status bar
This appendix presents error codes in two tables.
1) Table 46 lists error strings which are displayed within the cell that actually contains theerror. Except in the case of the ### error, they all correspond to a Calc error code
number. Alphanumeric codes such as Err502 and Err511 can also appear in cells; these
are not separately identified in the Table 46 but their meanings are given in Table 47.
2) Table 47 explains all of the error codes, listed by code number, including those error
codes in the first table.

Tip
You can use the ERRORTYPE() function to find the code number for an error
occurring in a different cell. Refer to the Help system for more detail about thisfunction.

Introduction to Calc error codes | 519

Error codes displayed within cells
Table 46: Error codes in cells
Code

Message

Explanation of the error

N/A

###

The column is too narrow to display the complete formatted
contents of the cell. This is not really an error value, so there is nocorresponding 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 tofit cell size in the Properties area to make the text match thecurrent column width.

503

#NUM!

A calculation resulted in an overflow of the defined value range.

519#VALUE!

The formula within the cell returns a value that does notcorrespond to the definition of the formula or functions used. Thiserror could also mean that the cell referenced by the formulacontains text instead of a number.

524

#REF!

The formula within the cell uses a reference that does not exist.
Either a column or row description name could not be resolved, orthe column, row, or sheet that contains a referenced cell is
missing.

525#NAME?

An identifier could not be evaluated: no valid reference, no valid
domain name, no column/row label, no macro, incorrect decimal
divider, add-in not found. For example, entering in a cell=sum(bob*5) where there is no cell named “bob” or containing
the text “bob” generates this error.

532#DIV/0!

Division operator / if the denominator is 0.
Some more functions return this error; see next table for details.

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. Errors listed as Not used are not currently assigned to any error condition
and will not occur.
Table 47: List of error codes
Code

Message

Explanation of the error

501

Invalid character

Character in a formula is not valid. This error is the sameas the Invalid Name error (525) except that it occurs withina formula. The cell containing the error will display the#NAME? error reference.

520 | Appendix B Error CodesCodeMessage

Explanation of the error

502

Invalid argument

Function argument is not valid; for example, a negative
number for the SQRT() function. This error also occurs if
more than one matching cell is found by the DGET()
function.

503

Invalid floating point
operation (celldisplays #NUM!)

Division by 0, or another calculation that results in an
overflow of the defined value range (a value too big or too
small).

504

Parameter list error

Function parameter is not valid; for example, text instead ofa number, or a domain reference instead of a cellreference.

505

Internal syntax error

Not used.

506

Invalid semicolon

Not used.

507

Pair missing

Not used.

508

Pair missing

Missing bracket or parenthesis; for example, closing
brackets but no opening brackets.

509

Missing operator

Operator is missing; for example,"=2(3+4)* ", where the operator between "2" and "(" ismissing.

510

Missing variable

Variable is missing; for example, when two operators are
together "=1+*2".

511

Missing variable

Function requires more variables than are provided; forexample, AND() and OR().

512

Formula overflow

The total number of internal tokens (that is, operators,
variables, brackets) in the formula exceeds 8192, or the
total number of matrices the formula creates exceeds 150.
This includes basic functions that receive too large an arrayas a parameter.

513

String overflow

An identifier in the formula exceeds 64 KB in size, or a
result of a string operation exceeds 64 KB in size.

514

Internal overflow

Sort operation attempted on too much numerical data (max.
100000) or a calculation stack overflow.

515

Internal syntax error

Not used.

516

Internal syntax error

Matrix is expected on the calculation stack, but is notavailable.

517

Internal syntax error

Unknown error; for example, a document with a newer
function is loaded in an older version of Calc that does notcontain the function.

518

Internal syntax error

Variable is not available.

General error codes | 521

CodeMessage

Explanation of the error

519

No result (cell displays#VALUE!)

Formula yields a value that does not correspond to thedefinition, or a cell that is referenced in the formula contains
text instead of a number.

520

Internal syntax error

Compiler creates an unknown compiler code.

521

Internal syntax error

No result.

522

Circular reference

Formula refers directly or indirectly to itself and the
Iterations option is not selected under Tools > Options >LibreOffice Calc > Calculate.

523

The calculation
procedure does notconverge

Financial statistics function missed a targeted value, or
iterations of circular references do not reach the minimumchange within the maximum steps that are set.

524

Invalid references (celldisplays #REF!)

A column or row description name could not be resolved, orthe column, row, or sheet that contains a referenced cell is
missing.

525

Invalid names (celldisplays #NAME?)

An identifier could not be evaluated; for example, no valid
reference, no valid domain name, no column/row label, nomacro, incorrect decimal divider, add-in not found.

526Internal syntax error

Obsolete, no longer used, but could come from old
documents if the result is a formula from a domain.

527

Internal overflow

References, such as when a cell references a cell, are too
encapsulated or deeply nested. This is an internal error andshould not be displayed in LibreOffice.

528 to531—

Not used.

532

Division by zero (celldisplays #DIV/0!)

Division operator / if the denominator is 0.
Some more functions return this error; for example:
VARP with less than 1 argument
STDEVP with less than 1 argument
VAR with less than 2 arguments
STDEV with less than 2 arguments
STANDARDIZE with stdev=0
NORMDIST with stdev=0533

Nested arrays are notsupported

For example, “={1;{2}}”538

Error: Array or matrix
size

—

539

Unsupported inline
array content

For example, “={1+2}”

540

External content
disabled

Occurs when a function that requires (re)loading of externalsources is encountered and the user hasn't confirmed
reloading of external sources yet.

522 | Appendix B Error CodesIndex3
3D charts 143
3D View dialog 143Aabsolute hyperlinks 380
absolute referencing 261
accepting changes 416
advanced filters 93, 460
aligning images 219
Alternative Python Script Organizer (APSO)
extension 444
Analysis of Variance (ANOVA) dialog 352
anchoring images 219
Apply Style list 187
area charts 168
arguments, passing to macros 434
arithmetic operators 257
arranging images 218
array formulas 274
Asian typography
options on Format Cells dialog 74
AutoCorrect 53
AutoFilters 92, 458
AutoFormat 77
AutoInput 55
AutoOutline 89
axes of a chart 129
Axis dialog 130

Bbackground, formatting for cell 76
bar charts 165
Base, launching to edit data sources 397
Basic macro programming 422
BeanShell macro programming 440
borders, formatting for cell 75
bubble charts 174
button hyperlinks 381

C
Calc options, setting
calculate 483
changes 487
compatibility 487
defaults 480
formula 485
general 478
grid 488
print 488
sort lists 486
view 480
Calc, list of main features 9, 16
Calc, new features in this version 14
calculations
linking sheets 265
order of 265
speeding up 276

Cell Style dialog 188
cell styles
Apply Style list 187
Cell Style dialog 188
fill format mode 186
hiding and showing 200
overview 184
Styles deck 185
Styles menu 185
cells
AutoFormat 77
copying styles 84
deleting 35, 64
error codes and messages 522
formatting background 76
formatting borders 75
inserting fields 69
merging and splitting 59
navigating between 27
selecting 31
validating contents 60
changes
accepting or rejecting 416
adding comments on 414
editing comments on 415
recording / tracking 413
chart types
3D 143area 168bar 165
bubble 174
changing 116
column 164
column and line 180
line 169net 175
pie 166
pivot 181
scatter or XY 171
stock 176
Chart Wizard
overview 102
selecting chart type 103
selecting data range 104
selecting data series 105
selecting elements 108
chartsadding drawing objects 155
axes 129background 120
chart type 103, 116
copying 162
data labels 136
data range and data series 104, 121
default colors 488
deleting 162
edit mode 111
error bars 152

Index | 523

exporting images 163
editing and deleting 64
grid lines 141
entering 49
legend 118
finding and replacing 96
mean value lines 150
formatting 69
moving 156
grouping and outlining 88
moving elements 116
hiding and showing 85
overall appearance 161
Data Labels dialog 136
pivot 317
Data Series dialog 122
resizing 156
data sources
selecting elements 115
editing 397
selecting multiple 160
launching Base 397
Sidebar, using to specify options 109
linking to when registered 393
title and subtitle 117
registering 393
trend lines 146
using in Calc spreadsheets 397
chi-square test of independence 367
viewing 395
clipboard, inserting image from 213
database primer 450
color coding for input 280
database ranges
colors, adding custom 500
creating and managing 454
column and line charts 180
linking to external data source 456
column charts 164
overview 454
columnsrefreshing data 457
deleting 34
selecting 456
freezing 38
databases
inserting 33
filtering 458
maximum number of 16
sorting 457
repeat printing 234
date and time, formatting 51
selecting 32
DDE (Dynamic Data Exchange) objects 399
comments
Define Database Range dialog 454
editing 416
deleting
finding 416
cells 35
formatting 416
charts 163
inserting 415
columns and rows 34
comparative operators 257
data 64
comparing spreadsheets 418
page breaks 236
compatibility of functions with other applications 269
pivot charts 320
conditional formatting
pivot tables 314
example 84
sheets 37
managing 83
Descriptive Statistics dialog 350
setting up 79
Detective 64, 280
types of 82
dialogs
Consolidate dialog 323
Create Names 453
copying charts 162
Define Database Range 454
copying sheets 35
Manage Names 452
Correlation dialog 353
Paste Names 452
Covariance dialog 355
Select Database Range 456
Create Names dialog 453
Sort 457
Create Scenario dialog 332
dialogs, choosing LibreOffice or operating systemcreating
11
formulas 255
dialogs, recognizing common controls 12
pivot charts 318
digital signing of documents
pivot tables 290
applying signature 250
spreadsheet 23
overview 249
CSV file
signing macros 252
importing 386
signing multiple times with same signature 251
opening 23
direct formatting, removing 184
custom colors, adding 500
direction of text 73
document properties 41
DDrawing Object Properties toolbar 161, 221
dashes, inserting 54
drawing objects
data
adding text to 216

524 | Index

additional tools in context menu 223
grouping and ungrouping 223
including in charts 155
resizing 222
setting the properties of 221
Drawing toolbar 155, 220
Dynamic Data Exchange (DDE) objects 399

formatting
cell background and borders 75
conditional 79
data 69
fonts 71
numbers 71
Formatting toolbar 18
Formatting toolbar, options when editing a chart 114
E
Formula bar 18
edit mode, for a chart 111
formulasediting data 64
array 274
emailing spreadsheets 249
color coding for input 280
embedding images 211
creating 255
embedding spreadsheets 399
operators in 255
Enter key, using to navigate and customizing 30
order of calculation 265
entering data 49
strategies for creating 275
Error Bars dialog 152
value highlighting 280
error codes and messages 278, 521
Fourier Analysis dialog 368
errors, finding and fixing 278
freezing columns and rows 38
Exponential Smoothing dialog 356
Function Wizard dialog 272
exporting charts 162
functions
exporting to formats other than PDF 249
basic arithmetic 281
exporting to PDF, using the Export Directly as PDF
compatibility with other applications 269
icon 241
creating with macros 427
exporting to PDF, using the PDF Options dialog 241
database-like 467
extensions
database-specific 462
Alternative Python Script Organizer (APSO) 444
examples 281
disabling 499
nested 270
Galaxy icon set 12
overview 269
installing 498
rounding numbers 283
legacy Gallery backgrounds 12
simple statistics 282
overview 498
structure 270
Oxygen icon set 12
using regular expressions 44, 284
removing 499
using wildcards 284
Tango icon set 12
Functions deck 22, 271
updating 498
GExternal Data dialog 386
external data, linking to 386
Galaxy icon set 12
Gallery deck 12, 22, 214
F
GETPIVOTDATA function 314
F-test dialog 364
Goal Seek dialog 343
FAQs (frequently asked questions) 13
graphs - see charts 102
feedback, sending about LibreOffice 10grouping and ungrouping
fields, inserting 69
data 88
fill format mode, using to apply cell styles 186
drawing objects 223
fill series 56
images 220
fill tool 55
Hfiltering
advanced filters 460
headers and footers 238
AutoFilters 458
Help menu 9
data 90
help, getting 9
standard filters 460
hiding data 86
using regular expressions 44, 91
highlighting values 78
Find and Replace dialog 96
HTML import, finding the required data 392
Find toolbar 96
HTML loading and saving options 477
finding and replacing data 96
Hyperlink dialog 382
font effects 72
hyperlinks
Fontwork objects 223
absolute and relative 380
footers and headers 238
buttons and text 381
Format menu, options when editing a chart 113
changing color 381

Index | 525

creating 381
editing 385
Hyperlink dialog 382
modifying 385
opening 382
removing 386

Ileading zeroes, entering 49
LibreOfficelicensing of 13
restarting with default settings 10
sending feedback on 10
LibreOffice Basic macro programming 422
LibreOffice options, setting
advanced 475
application colors 474
paths 472
print 472
security 472
user data 472
view 472
line breaks 69
line charts 169
linear programming, solving problems 344
linking images 211
linking to external data 386
Linux keyboard shortcuts 503
load Basic code to edit 445
loading / unloading macro libraries 432
loading and saving options
general 475
HTML compatibility 477
Microsoft Office 476
VBA properties 476

icon sets 12
illustrations, appearance of 11
Image toolbar 215
imagesadding text to 216
additional tools in context menu 223
aligning 219
anchoring 219
arranging (stacking) 218
embedding and linking 212
grouping and ungrouping 220
inserting from clipboard 213
inserting from file 211
inserting from Gallery deck 214
inserting from scanner 214
modifying 215
moving 217
resizing 217
importing XML source data 405
independence test (chi-square) 367
M
Input line
extending 51
macOSoverview 19
keyboard shortcuts 512
Insert menu, options when editing a chart 112
using LibreOffice on 12
insertingmacro examples
columns and rows 33
accessing cells directly 436, 437
images 211
Beanshell 442
page breaks 236
JavaScript 443
sheets 35, 373
Python 445, 446
sheets from another spreadsheet 375
recorded macro 426
special characters 52
sorting 438
Integrated Development Environment (IDE) for Basic
writing your own functions 431, 433, 434, 435
macro programming 429
macrosaccessing cells with 436
Jassigning to events 498
Java JRE (Java Runtime Environment) 14
creating your own functions 427
JavaScript macro programming 442
deleting 435
loading and unloading libraries 432
Kpassing arguments 434
keyboard shortcuts
recording 422
customizing 496
security warnings 431
loading saved configuration 498
sorting with 438
macOS 512
writing in Beanshell 440
resetting to defaults 498
writing in JavaScript 442
saving to a file 497
writing in LibreOffice Basic 422that cannot be modified (macOS) 519
writing in Python 444
that cannot be modified (Windows / Linux) 511
main window, recognizing components of 16
using to run macros 498
Manage Names dialog 452
Windows / Linux 503
manual formatting, removing 184
keyboard, using to navigate spreadsheet 29
mathematical optimization, solving problems 344
maximum numbers of sheets, rows, and columns 16
L
Menu bar 17

526 | Index

menuscustomizing 489
Format, options when editing a chart 113
Help 9Insert, options when editing a chart 112
Styles 185
merging
cells 59
spreadsheets 418
Microsoft Office loading and saving options 476
modifying images 215
movingchart elements 116
charts 156
images 217
sheets 35
Moving Average dialog 358
multi-threading 277
multiple lines of text 69
multiple operations
one formula and one variable 336
overview 336
several formulas simultaneously 339
two variables 341
Multiple Operations dialog 337

N
Name Box 18
named expressions 265
named ranges
creating and managing 451
creating using column or row headers 453
with functions 263
navigating
between cells 27
between sheets 28
using the Enter key 30
using the keyboard 29
Navigator
using to link external data 390
working with scenarios 335
Navigator deck 22
Navigator dialog 28
negative numbers, entering 49
net charts 175
non-linear programming, solving problems 344
notebookbar, customizing 495
numbers, formatting 71

O
ODF (Open Document Format) 25
OLE (Object Linking and Embedding) objects 399
opening
CSV file 23
spreadsheet 23
operatorsarithmetic 257
comparative 257
in formulas 255
reference 258

text 258
order of calculation 265
outlining 88
Oxygen icon set 12P
page breaks, inserting and deleting 236
Page Style dialog 197, 236
page styles
applying 188
overview 185
Page Style dialog 197
printing options 236
Paired t-test dialog 362
parallel processing 277
password protection 27
Paste Names dialog 452
Paste Special dialog 67
PDF Options dialog 241
PDF, exporting tousing the Export Directly as PDF icon 241
using the PDF Options dialog 241
personal data, removing 252
pie charts 166
pivot charts 181
creating 318
deleting 320
differences from other charts 317
editing 319
filtering 320
overview 317
refreshing / updating changed data 319
Pivot Table Layout dialog
additional options 293
column and row field options 299
data field options 296
defining the layout of the pivot table 291
filter field options 302
pivot tables
cell formatting of results 313
changing layout 303
creating 290
data sources 290
database preconditions 289
deleting 314
drilling 310
filtering 311
GETPIVOTDATA function 314
grouping columns or rows 304
grouping date / time values 305
grouping scalar values 304
grouping without intervals 306
refreshing / updating changed values 313
showing details (drilling) 310
sorting results 308
styles 313
Position and Size dialog 157, 217
positioning images 217
preview before printing 230
Print dialog 226

Index | 527

print ranges
defining 230
editing 230
named 232
removing 234
viewing 231
printing
default settings for LibreOffice 226
grayscale on a color printer 229
multiple pages per sheet of paper 228
options for page styles 236
repeat printing of rows or columns 234
selecting what to print 228
using print preview 230
using print ranges 230
using the Print dialog 226
using the Print Directly icon 226
Properties deck
overview 21
using to change chart properties 109
using with drawing objects 221
using with images 216
Properties dialog 41
Python macro programming 444

Rrangesassociating a name 451
database 454
named 451
recording macros 422
reference operatorsconcatenation 259
intersection 260
overview 258
range 258
references, absolute and relative 261
referencing
other documents 379
other sheets 377
registering data sources 393
Regression dialog 359
regular expressions 44, 91, 99, 284
rejecting changes 416
relative hyperlinks 380
relative referencing 261
removing personal data 252
renaming sheets 37, 376
replacing data 66
resizing
charts 156
drawing objects 222
images 217
restarting LibreOffice with default settings 10
reviewing spreadsheets
accepting or rejecting changes 416
adding comments to changes 415
comparing spreadsheets 418
editing comments on changes 416
merging spreadsheets 418

528 | Index

preparing a document for review 412
recording changes 413
using (general) comments 415
Rhino JavaScript debugger 443
rows
deleting 34
freezing 38
inserting 33
maximum number of 16
repeat printing 234
selecting 32

S
Sampling dialog 349
save original Basic code 445
saving spreadsheet 25
scanner, using to insert image 214
scatter charts 171
scenarios
creating 332
modifying properties and cell values 334
overview 332
using the Navigator 335
screen, splitting 38
Search Results dialog 99
searchingusing regular expressions 44, 99
security warnings for macros 431
Select Database Range dialog 456
Select Function icon 19
selectingcells, columns, rows, and sheets 31
chart elements 115
multiple charts 160
selection lists 58
selection modes 20
shared spreadsheets
list of disabled features 411
opening 411
overview 410
saving 411
setting up 410
sharing content between sheets 59
sheet tabs 22
sheetsdefault settings for new sheets 372
inserting as a link 375
inserting from a different spreadsheet 375
inserting new 373
inserting, moving, copying, renaming, anddeleting 35
linking in calculations 265
maximum number of 16
navigating between 28
referencing other sheets 377
renaming 376
selecting 33
sharing content between 59
showing hidden data 88
shrinking text to fit 71

Sidebar
Functions deck 22, 271
Gallery deck 12, 22, 214
Navigator deck 22, 39
overview 20
Properties deck, overview 21
Properties deck, using to change chart properties
109
Properties deck, using with drawing objects 216
Properties deck, using with images 221
Styles deck 21, 185signing documents digitally
applying signature 250
overview 249
signing macros 252
signing multiple times with same signature 251smoothing, exponential 356
Solver dialog 345
Sort dialog 94, 457
sortingdata 93
using macros 438
special characters, inserting 52
splitting cells 59
splitting the screen (or "window") 38
spreadsheets
advice to avoid common pitfalls 254
comparing 418
creating, opening, and saving 23
emailing 249
embedding 399
general layout 16, 22
merging 418
removing personal data 252
reviewing 412
saving versions 418
sharing with other users 410
signing digitally 249
stacking images 218
Standard (Single Mode) toolbar 18
standard filters 90, 460
Standard toolbar 18
statistics tools
analysis of variance (ANOVA) 352
correlation 353
covariance 355
descriptive statistics 350
exponential smoothing 356
F-test 364
Fourier analysis 368
moving average 358
paired t-test 362
regression 359
sampling 349
test of independence (chi-square) 367
z-test 365
Status bar
error codes and messages 521
overview 19
stock charts 176

stylescell 184
copying for cell 84
creating custom styles 188
deleting 200
filtering the list of 200
hiding and showing cell styles 200
modifying 199
page 185
pivot table cells 313
renaming 200
Styles deck 21, 185
Styles menu 185
subtotals
using the SUBTOTAL function 326
using the Subtotals dialog 328

Tt-test, paired 362
Tango icon set 12
templates
adding from other sources 205
categories 207
creating 202
default, setting and resetting 206
deleting 209
editing 203
exporting 209
moving between categories 208
organizing 207
overview 201
Start Center, using to create a spreadsheet 202
Templates dialog, using to create a spreadsheet
201
using to update styles 204
Test of Independence (Chi-Square) dialog 367
text
adding to drawing objects 216
adding to images 216
automatic wrapping 69
changing direction 73
hyperlinks 381
inserting manual line break 71
operators 258
shrinking to fit 71
Text Import dialog 23, 387
themes 78
Tip-of-the-Day 10
Title bar 17
toolbarscustomizing 492
Drawing 220
Drawing Object Properties, options when editinga chart 161
Drawing Object Properties, overview 221
Drawing, options when editing a chart 155
Find 96
Formatting, options when editing a chart 114
Formatting, overview 18
Image 215

Index | 529

overview 18
Standard 18
Standard (Single Mode) 18
tooltips 10, 18
tracking changes 413
Trend Line dialog 146

Uunfreezing columns and rows 38
updating LibreOffice software 11
URLs and hyperlinks 380
user interface, customizing 489

wildcards 98, 284
Windows keyboard shortcuts 503
wrapping text 69

X
XML Source dialog 406
XML, importing source data from 405
XY charts 171Zz-test dialog 365
zooming the Calc window 20

V#validating cell contents 60
Validity dialog 61
value highlighting 78, 280
VBA (Visual Basic for Applications) loading andsaving options 476
versions, saving 418# error codes and messages 521### displayed in cell 522#DIV/0! error 278, 522#NAME? error 522#NUM! error 522#REF! error 279, 522#VALUE! error 279, 522

W

530 | Index

Calc Guide
Working With Spreadsheets
About this book:
This book is for beginners to advanced users of Calc, the spreadsheet componentof LibreOffi ce. 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
MacrosAnd much more
About the authors:
This book was written by volunteers from the LibreOffice community. Profits fromsales of the printed edition will be used to benefit the community.
A PDF version of this book can be downloaded free from:https://documentation.libreoffice.org
About LibreOffice:LibreOffi ce is the free, libre, and open source personal productivity suite from The
Document Foundation. It runs on Windows, macOS, and GNU/Linux. Support anddocumentation 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 thisbook. For guides to Enterprise editions of LibreOffice, please refer to theprofessional partners that produced them.