python xlrd对excel的读取功能

工作簿

  • xlrd.open_workbook('test.xls')
    • workbook.dump()
    • workbook.nsheets
    • workbook.sheets()
    • workbook.sheet_names()
    • wookbook.sheet_by_index(0)
    • workbook.sheet_by_name(u'Sheet1')

工作表

  • wookbook.sheet_by_index(0)
    • sheet.dump()
    • sheet.name
    • sheet.nrows
    • sheet.ncols
    • sheet.row(0)
    • sheet.col(0)
    • row_slice(0, start_colx=0, end_colx=None)
    • col_slice(0, start_rowx=0, end_rowx=None)
    • row_values(0, start_colx=0, end_colx=None)
    • col_values(0, start_rowx=0, end_rowx=None)

单元格

  • sheet.cell(0, 0)
    • cell.dump()
    • cell.ctype
      • XL_CELL_EMPTY 0
      • XL_CELL_TEXT 1
      • XL_CELL_NUMBER 2
      • XL_CELL_DATE 3
      • XL_CELL_BOOLEAN 4
      • XL_CELL_ERROR 5
      • XL_CELL_BLANK 6
    • cell.value

xlError单元格

error_text_from_code = {
0x00: '#NULL!', # Intersection of two cell ranges is empty
0x07: '#DIV/0!', # Division by zero
0x0F: '#VALUE!', # Wrong type of operand
0x17: '#REF!', # Illegal or deleted cell reference
0x1D: '#NAME?', # Wrong function or range name
0x24: '#NUM!', # Value range overflow
0x2A: '#N/A', # Argument or function not available
}

Excel单元格命名

  • cellname(0, 0)
  • cellnameabs(0, 0)
  • colname(0)

相关链接

上一篇:cf581F 依赖背包+临时数组 好题


下一篇:2.25