Skip to content

Commit

Permalink
Improved the documentation about Table Shapes and cell width - GH-104
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jun 24, 2015
1 parent 27089ae commit 97d4ea7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
### Miscellaneous
- Improved the sample 04-Table for having a Text Run in a Cell - @Progi1984 GH-84
- Improved the sample 04-Table for having two links in a Cell - @Progi1984 GH-93
- Improved the documentation about Table Shapes and cell width - @Progi1984 GH-104
- Some parts of code shared between PHPOffice projects have been moved to PhpOffice/Common - @Progi1984

## 0.3.0 - 2014-09-22
Expand Down
8 changes: 8 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ PHPPowerPoint is a library written in pure PHP that provides a set of classes to
faq
credits
references

.. _shapes-docs:

.. toctree::
:maxdepth: 2
:caption: Shapes

shapes_table

Indices and tables
==================
Expand Down
7 changes: 2 additions & 5 deletions docs/shapes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ To create a drawing, use `createDrawingShape` method of slide.
->setDescription('Description of the drawing')
->setPath('/path/to/drawing.filename');
Drawing
Table
-------

To create a table, use `createTableShape` method of slide.

.. code-block:: php
$table = $slide->createTableShape($columns);
The Table has now :shapes_table:`its own page`.
57 changes: 57 additions & 0 deletions docs/shapes_table.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.. _shapes:

Tables
======

To create a table, use `createTableShape` method of slide.

Example:

.. code-block:: php
$tableShape = $slide->createTableShape($columns);
Rows
-------

A row is a child of a table. For creating a row, use `createRow` method of a Table shape.

.. code-block:: php
$tableShape = $slide->createTableShape($columns);
$row = $tableShape->createRow();
Cells
-------
A cell is a child of a row.

You can access cell objects with `nextCell` method of a Row object.
.. code-block:: php
$tableShape = $slide->createTableShape($columns);
$row = $tableShape->createRow();
// Get the first cell
$cellA1 = $row->nextCell();
// Get the second cell
$cellA2 = $row->nextCell();
You can access cell object directly
.. code-block:: php
$tableShape = $slide->createTableShape($columns);
$row = $tableShape->createRow();
// Get the first cell
$cellA1 = $row->getCell(0);
// Get the second cell
$cellA2 = $row->getCell(1);
Define the width of a cell
~~~~~~~~~~~~~~~~~~~~~~~~~~
The width of cells are defined by the width of cell of the first row.
If not defined, all cells widths are calculated from the width of the shape and the number of columns.

For defining the width of cell, you can use the `setWidth` method of a Cell object.
The width is in pixels.

.. code-block:: php
$tableShape = $slide->createTableShape($columns);
$row = $tableShape->createRow();
$cellA1 = $row->nextCell();
$cellA1->setWidth(100);

0 comments on commit 97d4ea7

Please sign in to comment.