本文整理汇总了Python中xlrd.cellname方法的典型用法代码示例。如果您正苦于以下问题:Python xlrd.cellname方法的具体用法?Python xlrd.cellname怎么用?Python xlrd.cellname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlrd
的用法示例。
在下文中一共展示了xlrd.cellname方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_corner
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def _get_corner(df, startcol=0, startrow=0, index=False, header=True, **kw):
import json
import xlrd
ref = {}
if header:
i = _index_levels(df.columns)
ref['header'] = list(range(i))
startrow += i
import pandas as pd
if index and isinstance(df.columns, pd.MultiIndex):
ref['skiprows'] = [i + 1]
startrow += 1
if index:
i = _index_levels(df.index)
ref['index_col'] = list(range(i))
startcol += i
landing = xlrd.cellname(startrow, startcol)
ref = json.dumps(ref, sort_keys=True)
ref = '{}(L):..(DR):LURD:["df", {}]'.format(landing, ref)
return startrow, startcol, ref
示例2: show_name_object
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def show_name_object(book, nobj, show_contents=0, f=sys.stdout):
print("\nName: %s, scope: %s (%s)" \
% (REPR(nobj.name), REPR(nobj.scope), scope_as_string(book, nobj.scope)), file=f)
res = nobj.result
print("Formula eval result: %s" % REPR(res), file=f)
if res is None:
return
# result should be an instance of the Operand class
kind = res.kind
value = res.value
if kind >= 0:
# A scalar, or unknown ... you've seen all there is to see.
pass
elif kind == xlrd.oREL:
# A list of Ref3D objects representing *relative* ranges
for i in range(len(value)):
ref3d = value[i]
print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3drel(book, ref3d))), file=f)
elif kind == xlrd.oREF:
# A list of Ref3D objects
for i in range(len(value)):
ref3d = value[i]
print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3d(book, ref3d))), file=f)
if not show_contents:
continue
datemode = book.datemode
for shx in range(ref3d.shtxlo, ref3d.shtxhi):
sh = book.sheet_by_index(shx)
print(" Sheet #%d (%s)" % (shx, sh.name), file=f)
rowlim = min(ref3d.rowxhi, sh.nrows)
collim = min(ref3d.colxhi, sh.ncols)
for rowx in range(ref3d.rowxlo, rowlim):
for colx in range(ref3d.colxlo, collim):
cty = sh.cell_type(rowx, colx)
if cty == xlrd.XL_CELL_EMPTY and show_contents == 1:
continue
cval = sh.cell_value(rowx, colx)
sval = showable_cell_value(cty, cval, datemode)
print(" (%3d,%3d) %-5s: %s"
% (rowx, colx, xlrd.cellname(rowx, colx), REPR(sval)), file=f)
示例3: print_labels
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def print_labels(sh, labs, title):
if not labs:return
for rlo, rhi, clo, chi in labs:
print("%s label range %s:%s contains:"
% (title, xlrd.cellname(rlo, clo), xlrd.cellname(rhi-1, chi-1)))
for rx in xrange(rlo, rhi):
for cx in xrange(clo, chi):
print(" %s: %r" % (xlrd.cellname(rx, cx), sh.cell_value(rx, cx)))
示例4: show_name_object
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def show_name_object(book, nobj, show_contents=0, f=sys.stdout):
print("\nName: %s, scope: %s (%s)"
% (REPR(nobj.name), REPR(nobj.scope), scope_as_string(book, nobj.scope)), file=f)
res = nobj.result
print("Formula eval result: %s" % REPR(res), file=f)
if res is None:
return
# result should be an instance of the Operand class
kind = res.kind
value = res.value
if kind >= 0:
# A scalar, or unknown ... you've seen all there is to see.
pass
elif kind == xlrd.oREL:
# A list of Ref3D objects representing *relative* ranges
for i in range(len(value)):
ref3d = value[i]
print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3drel(book, ref3d))), file=f)
elif kind == xlrd.oREF:
# A list of Ref3D objects
for i in range(len(value)):
ref3d = value[i]
print("Range %d: %s ==> %s"% (i, REPR(ref3d.coords), REPR(xlrd.rangename3d(book, ref3d))), file=f)
if not show_contents:
continue
datemode = book.datemode
for shx in range(ref3d.shtxlo, ref3d.shtxhi):
sh = book.sheet_by_index(shx)
print(" Sheet #%d (%s)" % (shx, sh.name), file=f)
rowlim = min(ref3d.rowxhi, sh.nrows)
collim = min(ref3d.colxhi, sh.ncols)
for rowx in range(ref3d.rowxlo, rowlim):
for colx in range(ref3d.colxlo, collim):
cty = sh.cell_type(rowx, colx)
if cty == xlrd.XL_CELL_EMPTY and show_contents == 1:
continue
cval = sh.cell_value(rowx, colx)
sval = showable_cell_value(cty, cval, datemode)
print(" (%3d,%3d) %-5s: %s"
% (rowx, colx, xlrd.cellname(rowx, colx), REPR(sval)), file=f)
示例5: cell
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def cell(self,rdrowx,rdcolx,wtrowx,wtcolx):
cell = self.rdsheet.cell(rdrowx,rdcolx)
if cell.ctype == xlrd.XL_CELL_EMPTY:
return
if cell.ctype == xlrd.XL_CELL_ERROR:
logger.error("Cell %s of sheet %r contains a bad value: %s" % (
xlrd.cellname(rdrowx, rdcolx),
quoted_sheet_name(self.rdsheet.name),
cell_display(cell,self.rdbook.datemode),
))
return
BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx)
示例6: _chart2excel
# 需要导入模块: import xlrd [as 别名]
# 或者: from xlrd import cellname [as 别名]
def _chart2excel(writer, sheet, charts):
import xlrd
from openpyxl.chart import ScatterChart, Series
sn = writer.book.sheetnames
named_ranges = {'%s!%s' % (sn[d.localSheetId], d.name): d.value
for d in writer.book.defined_names.definedName}
m, h, w = 3, 7.94, 13.55
for i, (k, v) in enumerate(sorted(charts.items())):
chart = ScatterChart()
chart.height = h
chart.width = w
_map = {
('title', 'name'): ('title',),
('y_axis', 'name'): ('y_axis', 'title'),
('x_axis', 'name'): ('x_axis', 'title'),
}
_filter = {
('legend', 'position'): lambda x: x[0],
}
it = {s: _filter[s](o) if s in _filter else o
for s, o in sh.stack_nested_keys(v['set'])}
for s, o in sh.map_dict(_map, it).items():
c = chart
for j in s[:-1]:
c = getattr(c, j)
setattr(c, s[-1], o)
for s in v['series']:
xvalues = named_ranges[_data_ref(s['x'])]
values = named_ranges[_data_ref(s['y'])]
series = Series(values, xvalues, title=s['label'])
chart.series.append(series)
n = int(i / m)
j = i - n * m
sheet.add_chart(chart, xlrd.cellname(15 * j, 8 * n))