1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 def get_sheet_from_doc(document
, index
=None, name
=None):
9 """ Returns a sheet object for a Spreadsheet document
12 index -- the 0-based index of the sheet (may not be used together with name)
13 name -- the name of the sheet (may not be used together with index)
15 return document
.getSheets().getByIndex(index
)
17 def get_cell_by_position(document
, tab
, column
, row
):
18 """ Get the cell object through its position in a document
21 document -- The document that should be used
22 tab -- The 0-based sheet number
23 column -- The 0-based column number
24 row -- The 0-based row number
26 sheet
= get_sheet_from_doc(document
, tab
)
27 return sheet
.getCellByPosition(column
, row
)
29 def get_column(document
, column
, tab
= 0):
30 """ Get the column object through the column index
33 document -- The document that should be used
34 tab -- The 0-based sheet number
35 column -- The 0-based column number
37 sheet
= get_sheet_from_doc(document
, tab
)
38 return sheet
.getColumns().getByIndex(column
)
40 def get_row(document
, row
, tab
= 0):
41 """ Get the row object through the row index
44 document -- The document that should be used
45 tab -- The 0-based sheet number
46 column -- The 0-based row number
48 sheet
= get_sheet_from_doc(document
, tab
)
49 return sheet
.getRows().getByIndex(row
)
51 # vim: set shiftwidth=4 softtabstop=4 expandtab: