xlrd 조작 excel

5153 단어
# -*- coding: utf-8 -*-
import xlrd
import numpy as np 


def read_excel(file, sheet_nums, col_num, row_num, cell_index):
    data = xlrd.open_workbook(file)
    for i in range(sheet_nums):
        table = data.sheets()[i] #  
        # table = data.sheet_by_name(u'Sheet1')  #   
        nrows = table.nrows  #  
        ncols = table.ncols  #  
        col_val = table.col_values(col_num)
        row_val = table.row_values(row_num)
        for k in range(nrows):
            print(table.row_values(k))
        for j in range(ncols):
            print(table.col_values(j))
        cell_A1 = table.cell(0, 0).value
        cell_val = table.cell(cell_index[0], cell_index[1]).value  #  


if __name__ == '__main__':
    file = ''
    sheet_nums = num1
    col_num = num2
    row_num = num3
    cell_index = (x, y)
    read_excel(file, sheet_nums, col_num, row_num, cell_index)

좋은 웹페이지 즐겨찾기