Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)))
def dump_sheet(sheet, sheet_index, max_rows):
dump_record("s", {
"index": sheet_index,
"name": sheet.name,
"rows": sheet.nrows,
"columns": sheet.ncols,
"visibility": sheet.visibility
})
for rowx in range(max_rows or sheet.nrows):
for colx in range(sheet.ncols):
cell = sheet.cell(rowx, colx)
dump_record("c", [rowx, colx, cellname(rowx, colx), parse_cell_value(sheet, cell)])
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)))
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)))
continue
datemode = book.datemode
for shx in xrange(ref3d.shtxlo, ref3d.shtxhi):
sh = book.sheet_by_index(shx)
print >> f, " Sheet #%d (%s)" % (shx, sh.name)
rowlim = min(ref3d.rowxhi, sh.nrows)
collim = min(ref3d.colxhi, sh.ncols)
for rowx in xrange(ref3d.rowxlo, rowlim):
for colx in xrange(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 >> f, " (%3d,%3d) %-5s: %r" \
% (rowx, colx, xlrd.cellname(rowx, colx), sval)
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: %r" \
% (rowx, colx, xlrd.cellname(rowx, colx), sval), file=f)
def get_cells(sheet, rowx, colx):
return sheet.cell_value(rowx, colx)
# loop over worksheets
for index in range(0,num_sheets):
# find non empty cells
sheet = book.sheet_by_index(index)
outfile.write("=================================\n")
outfile.write("Sheet: " + sheet.name + "[ " + str(sheet.nrows) + " , " + str(sheet.ncols) + " ]\n")
outfile.write("=================================\n")
for row in range(0,sheet.nrows):
for col in range(0,sheet.ncols):
content = get_cells(sheet, row, col)
if content <> "":
outfile.write(" " + unicode(xl.cellname(row,col)) + ": " + unicode(content) + "\n")
print "\n"