pyexcel.Sheet.cut

Sheet.cut(topleft_corner, bottomright_corner)

Get a rectangle shaped data out and clear them in position

Parameters:
  • topleft_corner (slice) – the top left corner of the rectangle
  • bottomright_corner (slice) – the bottom right corner of the rectangle

example:

>>> import pyexcel as pe
>>> data = [
...     # 0 1  2  3  4 5   6
...     [1, 2, 3, 4, 5, 6, 7], #  0
...     [21, 22, 23, 24, 25, 26, 27],
...     [31, 32, 33, 34, 35, 36, 37],
...     [41, 42, 43, 44, 45, 46, 47],
...     [51, 52, 53, 54, 55, 56, 57]  # 4
... ]
>>> s = pe.Sheet(data)
>>> s
Sheet Name: pyexcel
+----+----+----+----+----+----+----+
| 1  | 2  | 3  | 4  | 5  | 6  | 7  |
+----+----+----+----+----+----+----+
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
+----+----+----+----+----+----+----+
| 31 | 32 | 33 | 34 | 35 | 36 | 37 |
+----+----+----+----+----+----+----+
| 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+----+----+----+----+----+----+----+
| 51 | 52 | 53 | 54 | 55 | 56 | 57 |
+----+----+----+----+----+----+----+
>>> # cut  1<= row < 4, 1<= column < 5
>>> data = s.cut([1, 1], [4, 5])
>>> s
Sheet Name: pyexcel
+----+----+----+----+----+----+----+
| 1  | 2  | 3  | 4  | 5  | 6  | 7  |
+----+----+----+----+----+----+----+
| 21 |    |    |    |    | 26 | 27 |
+----+----+----+----+----+----+----+
| 31 |    |    |    |    | 36 | 37 |
+----+----+----+----+----+----+----+
| 41 |    |    |    |    | 46 | 47 |
+----+----+----+----+----+----+----+
| 51 | 52 | 53 | 54 | 55 | 56 | 57 |
+----+----+----+----+----+----+----+