Sheet
Write a value and get a reference back, so you never retype a coordinate.
Sheet is a thin wrapper over an openpyxl worksheet -- it holds no state of its
own beyond the worksheet, and .ws is always there when you want plain openpyxl::
s = Sheet(ws)
rev = s.put("B2", 1000)
cost = s.put("B3", 600)
s.put("B4", (rev - cost) / rev) # =(B2-B3)/B2
References come back unqualified, because most formulas stay on one sheet. When
one crosses sheets, .qualified() supplies the sheet name for you.
Sheet
A write-and-remember wrapper around an openpyxl worksheet.
openpyxl is never imported: the worksheet is duck-typed on .title and
.cell(row=, column=, value=).
Source code in src/pycountant/excel/sheet.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
cell(row, col, **kw)
A reference by position, without writing anything.
Source code in src/pycountant/excel/sheet.py
72 73 74 | |
column(ref_or_letter)
The whole column a reference sits in: s.column(rev) -> B:B.
Source code in src/pycountant/excel/sheet.py
80 81 82 83 | |
put(*args, number_format=None, **style)
Write a value and return a reference to the cell it landed in.
Called either as put("B2", value) or as put(row, col, value).
value may be an expression, in which case the formula is written.
number_format and any further keywords are applied to the openpyxl
cell as attributes, so font=, fill=, alignment= and border=
all pass straight through.
Source code in src/pycountant/excel/sheet.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
ref(key)
A reference into this sheet without writing anything.
Source code in src/pycountant/excel/sheet.py
66 67 68 | |
span(start, end)
The range between two references written on this sheet.
Source code in src/pycountant/excel/sheet.py
76 77 78 | |