Difference between revisions of "Documentation/OOo3 User Guides/Writer Guide/Creating a table"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Create a table from formatted text)
m (Create a table from formatted text)
Line 64: Line 64:
 
[[Image:TextToTable.png|thumb|none|500px|''Dialog box to configure the text to table conversion'']]
 
[[Image:TextToTable.png|thumb|none|500px|''Dialog box to configure the text to table conversion'']]
  
In the top part of the dialog box, select the symbol that separates the columns. This would normally be a tab, but it could be a semicolon or comma if you are importing a CSV file. The other options in this dialog are the same as those in the dialog used to insert a table shown in above.
+
In the top part of the dialog box, select the symbol that separates the columns. This would normally be a tab, but it could be a semicolon or comma if you are importing a CSV file. The other options in this dialog are the same as those in the dialog used to insert a table shown [[#WG9-2.png|above]].
  
 
=== Example ===
 
=== Example ===

Revision as of 14:26, 30 May 2010


Before you insert a table into a document, it helps to have an idea of the visual result you want to obtain as well as an estimate of the number of rows and columns required. Every parameter can be changed at a later stage; however, thinking ahead can save a large amount of time as changes to fully formatted tables often require a significant effort.

Inserting a new table

To insert a new table, position the cursor where you want the table to appear, then use any of the following methods to open the Insert Table dialog box:

  • From the main menu, select Table > Insert > Table.
  • Press Control+F12.
  • From the Standard toolbar, click the Table icon TableIcon.png
Inserting a new table using the Insert Table dialog box.

Here you can specify the properties for the new table.

Under Name, you can enter a different name than the OOo-generated default for the table. This might come in handy when using the Navigator to quickly jump to a table.

Under Size, specify the initial number of columns and rows for the new table. You can change the size of the table later, if necessary.

Under Options, set up the initial table characteristics. Selecting the options in this section of the dialog produces the following results:

  • Heading — Defines the first row(s) in the table as headings. The default Table Heading paragraph style is applied to the heading rows and thus makes the text centered, bold, and italic. You can edit the OOo-predefined Table Heading paragraph style in the Styles and Formatting window to change these default settings. When splitting a table into two tables, the Heading row(s) are copied in the second table.
  • Repeat heading — Repeats the heading row(s) of the table at the top of subsequent pages if the table spans more than one page.
    The first ... rows —Specifies the number of rows to be repeated. Default is 1.
  • Don’t split table — Prevents the table from spanning more than one page. This can be useful if the table starts near the end of a page, and would look better if it were completely located on the following page. If the table becomes longer than would fit on one page, you will need to either deselect this option or manually split the table.
  • Border — Surrounds each cell of the table with a border. This border can be modified or deleted later.

The AutoFormat button opens a dialog from where it is possible to select one of the many predefined table layouts. See Automatic formatting of tables for more information.

After making your choices, click OK. Writer creates a table as wide as the text area (from the left page margin to the right page margin), with all columns the same width and all rows the same height. You can then adjust the columns and rows later to suit your needs.

Template:Documentation/Tip

Creating nested tables

You can create tables within tables, nested to a depth only limited by imagination and practicality. The figure below demonstrates a simple, two-level example.

To achieve this, simply click in a cell of an existing table and use any of the methods mentioned in Inserting a new table above.

Nested table example. The shaded table is nested in a cell of the larger table.

Using AutoCorrect to create a table

You can also create a table by typing a series of hyphens (-) or tabs separated by plus signs. Use the plus signs to indicate column dividers, while hyphens and tabs are used to indicate the width of a column.

For example, this character sequence:

+-----------------+---------------+------+

creates a table like this:

WG9-x.png

Template:Documentation/Note

Documentation caution.png When using tabs instead of a table to line up your data, always make sure that you know how wide they are set and remember that default tabs may be different when the document is displayed on a different computer or even when copying the same data in a new document.

Create a table from formatted text

It is possible to create a table starting from plain text by means of the Table > Convert > Text to Table menu. In order for this command to work effectively, the starting text needs to have clear demarcation between what will become the columns of the table. Paragraph marks indicate the end of a row.

To convert text to a table, start by selecting the text you want to convert and select Table > Convert > Text to Table to open the dialog box shown below.

Dialog box to configure the text to table conversion

In the top part of the dialog box, select the symbol that separates the columns. This would normally be a tab, but it could be a semicolon or comma if you are importing a CSV file. The other options in this dialog are the same as those in the dialog used to insert a table shown above.

Example

In this example we will convert the following text into a table.

Row 1 Column 1; Row 1 Column 2; Row 1 Column 3

Row 2 Column 1; Row 2 Column 2; Row 2 Column 3

In this case, the separator between elements is a semicolon. By selecting the text and applying the conversion, we obtain the following result.

Row 1 Column 1 Row 1 Column 2 Row 1 Column 3
Row 2 Column 1 Row 2 Column 2 Row 2 Column 3

Note that, unlike when creating a table with other mechanisms, the conversion from text to table preserves the paragraph style applied to the original text.

You can also use the Convert menu to perform the opposite operation; that is, to transform a table into plain text. This may be useful when you want to export the table contents into a different program.

To transform a table into text, place the cursor anywhere in the table, select Table > Convert > Table to Text in the main menu, pick the preferred row separator, and click OK to finish.


Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools