Reading particular cell value from excelsheet in python

后端 未结 4 1362
一整个雨季
一整个雨季 2020-12-15 12:02

I want to get particular cell values from excelsheet in my python script. I came across xlrd, xlwt, xlutils modules for reading/writin

相关标签:
4条回答
  • 2020-12-15 12:08

    This code is to select certain cells from Excel using Python:

    import openpyxl
    
    wb = openpyxl.load_workbook(r'c:*specific destination of file*.xlsx')
    sheet = wb.active
    x1 = sheet['B3'].value
    x2 = sheet['B4'].value
    y1 = sheet['C3'].value
    y2 = sheet['C4'].value
    print(x1,x2,y1,y2)
    
    0 讨论(0)
  • 2020-12-15 12:10

    The code below will help you in solving the problem:

    worksheet = workbook.sheet_by_name('Sheet1')
    num_rows = worksheet.nrows - 1
    curr_row = 0
    while curr_row < num_rows:
            curr_row += 1
            row = worksheet.row(curr_row)
            print row[0].value
    
    0 讨论(0)
  • 2020-12-15 12:23

    To access the value for a specific cell:

    cell_value = worksheet.cell(row_number, column_number).value
    
    0 讨论(0)
  • 2020-12-15 12:29

    To access the value for a specific cell you would use:

    value = worksheet.cell(row, column)

    0 讨论(0)
提交回复
热议问题