|
1 | | -Inserting and deleting rows and columns, moving ranges of cells |
| 1 | +插入删除行或列, 移动范围单元格 |
2 | 2 | =============================================================== |
3 | 3 |
|
4 | 4 |
|
5 | | -Inserting rows and columns |
| 5 | +插入行和列 |
6 | 6 | -------------------------- |
7 | 7 |
|
8 | | -You can insert rows or columns using the relevant worksheet methods: |
| 8 | +你可以使用工作表相关的方法来插入行和列: |
9 | 9 |
|
10 | 10 | * :func:`openpyxl.worksheet.worksheet.Worksheet.insert_rows` |
11 | 11 | * :func:`openpyxl.worksheet.worksheet.Worksheet.insert_cols` |
12 | 12 | * :func:`openpyxl.worksheet.worksheet.Worksheet.delete_rows` |
13 | 13 | * :func:`openpyxl.worksheet.worksheet.Worksheet.delete_cols` |
14 | 14 |
|
15 | | -The default is one row or column. For example to insert a row at 7 (before |
16 | | -the existing row 7):: |
| 15 | +默认是一行或一列。 例如在第七行插入一行 (存在第七行):: |
17 | 16 |
|
18 | 17 | >>> ws.insert_rows(7) |
19 | 18 |
|
20 | 19 |
|
21 | | -Deleting rows and columns |
| 20 | +删除多行或多列 |
22 | 21 | -------------------------- |
23 | 22 |
|
24 | | -To delete the columns ``F:H``:: |
| 23 | +删除 ``F:H`` 列:: |
25 | 24 |
|
26 | 25 | >>> ws.delete_cols(6, 3) |
27 | 26 |
|
28 | 27 |
|
29 | 28 | Moving ranges of cells |
30 | 29 | ---------------------- |
31 | 30 |
|
32 | | -You can also move ranges of cells within a worksheet:: |
| 31 | +你也可以在一个工作表内移动范围单元格:: |
33 | 32 |
|
34 | 33 | >>> ws.move_range("D4:F10", rows=-1, cols=2) |
35 | 34 |
|
36 | | -This will move the cells in the range ``D4:F10`` up one row, and right two |
37 | | -columns. The cells will overwrite any existing cells. |
| 35 | +这会将 ``D4:F10`` 单元格向上移动一行向右移动两列,已存在的单元格将会被覆盖 |
38 | 36 |
|
39 | | -If cells contain formulae you can let openpyxl translate these for you, but |
40 | | -as this is not always what you want it is disabled by default. Also only the |
41 | | -formulae in the cells themselves will be translated. References to the cells |
42 | | -from other cells or defined names will not be updated; you can use the |
43 | | -:doc:`formula` translator to do this:: |
| 37 | +如果单元格包含公式,你可以让 openpyxl 帮你进行translate,但也并非总是你想要的结果,因此默认是禁用的。 |
| 38 | +同时,只有单元格本身的公式将会被translate。其他单元格对该单元格的引用或defined name将不会被更新。你可以使用 :doc:`formula` 来做这件事:: |
44 | 39 |
|
45 | 40 | >>> ws.move_range("G4:H10", rows=1, cols=1, translate=True) |
46 | 41 |
|
47 | | -This will move the relative references in formulae in the range by one row and one column. |
| 42 | +公式中的相对引用移动一行和一列 |
0 commit comments