Need help - How to identify the cell display format?

Larry Martell larry.martell at gmail.com
Tue Dec 15 09:04:24 EST 2015


On Tue, Dec 15, 2015 at 2:29 AM, Ezhilarasan Chandrasekar
<aezhil90 at gmail.com> wrote:
> Hi folks,
>
> I just want to find the cell display format in Excel. I have a Expected
> excel file and Actual Excel file.
>
> I have some knowledge about, how to check the cell value, cell font,
> alignment. But I also want to know about what type of cell format is being
> used.
>
> For example: If the cell value has "*04:05:00 AM*", but it displays as "
> *04:05:00*"(AM notation not needed) which is of format "*hh:mm:ss*"
>
> I want to identify the cell format *(hh:mm:ss)* from Expected Excel file
> and compare with the Actual Excel file

You can do this with openpyxl, for example:

from openpyxl.reader.excel import load_workbook

book = load_workbook(filename='transactions.xlsx')
sheet = book.get_sheet_by_name('transactions')
print sheet.cell("A12").style.number_format
print sheet.cell("A13").style.number_format



More information about the Python-list mailing list