Using openpyxl is pretty straightforward:

from openpyxl import load_workbook
wb = load_workbook(spreadsheet_path)
sheet = wb.active

# Reading the values in cells:
print('Cell A1 contains', sheet['A1'].value)
print('Cell A2 contains', sheet['A2'].value)
print('Cell B1 contains', sheet['B1'].value)

# Alternatively:
print('Cell A1 contains', sheet.cell(1, 1).value)
print('Cell A2 contains', sheet.cell(1, 2).value)
print('Cell B1 contains', sheet.cell(2, 1).value)

"""
The cell numbers (A1 or A2 or A3 or A4……… ) are not fixed they can be any. I 
don't know what the cell number is going to be that's what the problem is.

The user is going to enter the book name in an HTML form present on a website 
then it will be checked whether the book user has entered is present or not in 
the Excel file. If the book is present in the book bank and the user requires 
that book then one will be issued to the user and the total number of books 
will be reduced by 1 (one) and the user or borrower’s name will be entered in 
the Excel’s table row in which the book name is present separated by a comma by 
other borrower names. The borrower's name can be more than one because more 
than one copies of the book are there as these are the books that are taught in 
schools. 
"""
 
# Changing the value in a cell:
sheet.cell(1, 20).value = 'TEST'

# A value of None means that the cell is empty.

wb.save(spreadsheet_path)
wb.close()
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to