Applies to openSUSE Leap 42.1

10 LibreOffice Calc

Calc is the LibreOffice spreadsheet and data plotting module. Spreadsheets consist of several sheets, containing cells which can be filled with elements like text, numbers, or formulas. A formula can manipulate data from other cells to generate a value for the cell in which it is inserted. Calc also allows you to define ranges, filter and sort the data or creates charts from the data to present it graphically. By using pivot tables, you can combine, analyze or compare larger amounts of data.

As with the entire LibreOffice suite, Calc can be used across a variety of platforms. It provides several exchange formats (including export to PDF documents), and can also read and save files in Microsoft Excel format. Its interoperability is constantly ameliorated.

This chapter can only introduce some very basic Calc functionality. For more information and for complete instructions, look at the LibreOffice help or at the sources listed in Section 8.10, “For More Information”.

Note: VBA Macros

Calc can process many VBA macros in Excel documents. However, support for VBA macros is not yet complete. When opening an Excel spreadsheet that makes heavy use of macros, you might discover that some do not work.

10.1 Creating a New Document

There are two ways to create a new Calc document:

  • From Scratch.  To create a document from scratch, click File › New › Spreadsheet and a new empty Calc document is created.

  • Templates.  To use a template, click File › New › Templates and open Finances. You can see a list of Spreadsheet templates. Select the one that fits your needs and your new document is created based on the style of your selected template.

Access the individual sheets by clicking the respective tabs at the bottom of the window.

Enter data in the cells as desired. To adjust the appearance, either use the Formatting toolbar or the Format menu—or define styles as described in Section 10.2, “Using Formatting and Styles in Calc”. Use the File menu or the relevant buttons in the toolbar to print and save your document.

10.2 Using Formatting and Styles in Calc

Calc comes with a few built-in cell and page styles to improve the appearance of your spreadsheets and reports. Although these built-in styles are adequate for many uses, you will probably find it useful to create styles for your own frequently used formatting preferences.

Procedure 10.1: Creating a Style
  1. Click Format › Styles and Formatting.

  2. In the Styles and Formatting window, click either the Cell Styles or the Page Styles icon from the top of the window.

  3. Right-click anywhere in the list of styles in the Styles and Formatting window. Then click New.

  4. Specify a name for your style and use the various tabs to set the desired formatting options.

  5. Click OK.

Procedure 10.2: Modifying a Style
  1. Click Format › Styles and Formatting.

  2. In the Formatting and Styles window, click either the Cell Styles or the Page Styles icon.

  3. Right-click the name of the style you want to change, then click Modify.

  4. Change the desired formatting options.

  5. Click OK.

To apply a style to specific cells, select the cells you want to format. Then double-click the style you want to apply in the Styles and Formatting window.

10.3 Working With Sheets

Sheets are a good method to organize your calculations. For example, if you have a business, accounting might be much clearer if you create a sheet for each month.

To insert a new sheet in your spreadsheet, do the following:

Procedure 10.3: Inserting New Sheets
  1. Select Insert › Sheet from the main menu. A dialog opens.

  2. Decide whether the new sheet should be positioned before or after the selected sheet.

  3. If you want to create a new sheet, make sure the New Sheet radio button is activated. Enter the number of sheets and the sheet name. Skip the next step.

  4. If you want to import a sheet from another file, do the following otherwise skip this step:

    1. Select From file and click Browse.

    2. Select the file name and confirm with OK. All the sheet names are now displayed in the list.

    3. Select the sheet names you want to import by holding the Shift key.

    4. Confirm with OK to import the sheet names you selected.

To rename a sheet, right-click a sheet in the sheet tab and select Rename Sheet. To rename, you can also double-click the sheet tab.

To delete the current sheet, select Edit › Sheet › Delete and confirm with Delete Sheets. It is possible to delete more than one sheet by holding the Shift key and selecting the sheets you want to delete in the sheet tab. Right-click and choose Delete Sheet and the same dialog appears. Confirm with Delete Sheets.

10.4 Conditional Formatting

Conditional formatting is a useful feature to highlight certain values in your spreadsheet. For example, define a condition and if the condition is true, a style is applied to each cell that fulfills this condition.

Note: Enable AutoCalculate

Before you apply conditional formatting, choose Tools › Cell Contents › AutoCalculate. You should see a check mark in front of AutoCalculate.

Procedure 10.4: Using Conditional Formatting
  1. Define a style first. This style is applied to each cell when your condition is true. Use Format › Styles and Formatting or press F11. For more information, see Procedure 10.1, “Creating a Style”. Confirm with OK.

  2. Select the cell range where you want to apply your condition.

  3. Select Format › Conditional Formatting › Condition from the main menu. A dialog opens.

  4. You now see a template for a new condition. Conditions can operate in multiple modes:

    Cell value is

    The condition tests if a cell matches a certain value. Beside the first pull-down menu, you can select an operator such as equal to, less than, or greater than.

    Formula is

    The condition tests if a certain formula returns true.

    Date is

    The condition tests if a certain date value is reached.

    All Cells

    This mode allows creating data visualizations that, similarly to Cell value is, depend on the value of a cell. However, the difference here is that you can use one condition to apply an entire range of styles.

  5. For this example, keep the default: Cell value is.

  6. Select an operator and the value of the cell you want to test for.

  7. Choose the style you want to apply when this condition is true or click New Style to define a new appearance.

  8. If you need additional conditions, click Add. Then repeat the previous steps.

  9. Confirm with OK. Now the style of your cells has changed.

10.5 Grouping and Ungrouping Cells

Grouping a cell range helps to fold your spreadsheet into parts. This makes your spreadsheets more readable, as you can hide all the parts you are not currently interested in. It is possible to group rows or columns and nest groups in other groups.

To group a range, proceed as follows:

Procedure 10.5: Grouping a Selected Cell Range
  1. Select a cell range in your spreadsheet.

  2. Select Data › Group and Outline › Group. A dialog appears.

  3. Decide if you want to group your selected range as row or as column. Confirm with OK.

After grouping selected cells, a line indicating the grouped cell range appears in the upper-left margin. Fold or unfold the cell range with the + and - icons. The numbers at the top left of the margins display the depth of your groups and can be clicked too.

To ungroup a cell range, click into a cell which belongs to a group and select Data › Group and Outline › Ungroup. The line in the margin disappears. The innermost group is always deleted first.

10.6 Freezing Rows or Columns as Headers

If you have a spreadsheet with lots of data, scrolling makes your header usually disappear. LibreOffice can lock rows or columns or both, so they remain fixed as you scroll around.

To freeze a single row or a single column, proceed as follows:

Procedure 10.6: Freezing a Single Row or Column
  1. To create a frozen area before a row, click the header of the row (1, 2, 3, ...).

    To create a frozen area above a column, click the header of the column (A, B, C, ...).

  2. Select Window › Freeze. A dark line appears, indicating which area is frozen.

It is also possible to freeze both rows and columns:

Procedure 10.7: Freezing Row and Column
  1. Click into the cell to the right of the column and below the row you want frozen. For example, if your header occupies the space from A1 to B3, click cell C4.

  2. Select Window › Freeze. A dark line appears, indicating which area is frozen.

To unfreeze, select Window › Freeze. The check mark in the menu then disappears.

Print this page