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, xlrd2.cellname(rlo, clo), xlrd2.cellname(rhi - 1, chi - 1)))
         for rx in xrange(rlo, rhi):
             for cx in xrange(clo, chi):
                 print("    %s: %r" % (xlrd2.cellname(rx, cx), sh.cell_value(rx, cx)))
Beispiel #2
0
 def count_xfs(bk):
     bk_header(bk)
     for shx in range(bk.nsheets):
         sh = bk.sheet_by_index(shx)
         nrows = sh.nrows
         print("sheet %d: name = %r; nrows = %d; ncols = %d" %
               (shx, sh.name, sh.nrows, sh.ncols))
         # Access all xfindexes to force gathering stats
         type_stats = [0, 0, 0, 0, 0, 0, 0]
         for rowx in xrange(nrows):
             for colx in xrange(sh.row_len(rowx)):
                 xfx = sh.cell_xf_index(rowx, colx)
                 assert xfx >= 0
                 cty = sh.cell_type(rowx, colx)
                 type_stats[cty] += 1
         print("XF stats", sh._xf_index_stats)
         print("type stats", type_stats)
         print()
         if bk.on_demand: bk.unload_sheet(shx)
Beispiel #3
0
 def show(bk, nshow=65535, printit=1):
     bk_header(bk)
     if 0:
         rclist = xlrd2.sheet.rc_stats.items()
         rclist = sorted(rclist)
         print("rc stats")
         for k, v in rclist:
             print("0x%04x %7d" % (k, v))
     if options.onesheet:
         try:
             shx = int(options.onesheet)
         except ValueError:
             shx = bk.sheet_by_name(options.onesheet).number
         shxrange = [shx]
     else:
         shxrange = range(bk.nsheets)
     # print("shxrange", list(shxrange))
     for shx in shxrange:
         sh = bk.sheet_by_index(shx)
         nrows, ncols = sh.nrows, sh.ncols
         colrange = range(ncols)
         anshow = min(nshow, nrows)
         print("sheet %d: name = %s; nrows = %d; ncols = %d" %
               (shx, REPR(sh.name), sh.nrows, sh.ncols))
         if nrows and ncols:
             # Beat the bounds
             for rowx in xrange(nrows):
                 nc = sh.row_len(rowx)
                 if nc:
                     sh.row_types(rowx)[nc - 1]
                     sh.row_values(rowx)[nc - 1]
                     sh.cell(rowx, nc - 1)
         for rowx in xrange(anshow - 1):
             if not printit and rowx % 10000 == 1 and rowx > 1:
                 print("done %d rows" % (rowx - 1, ))
             show_row(bk, sh, rowx, colrange, printit)
         if anshow and nrows:
             show_row(bk, sh, nrows - 1, colrange, printit)
         print()
         if bk.on_demand: bk.unload_sheet(shx)
Beispiel #4
0
 def show_fonts(bk):
     print("Fonts:")
     for x in xrange(len(bk.font_list)):
         font = bk.font_list[x]
         font.dump(header='== Index %d ==' % x, indent=4)