Skip to content Skip to sidebar Skip to footer

How To 'format Cells' With Openpyxl?

I want to format the column cells in my excel sheet using openpyxl to have their numbers decimal places at '0'. Example Sheet: B C 63245634566 NAME 63562341234

Solution 1:

Try

from openpyxl import load_workbook
wb = load_workbook( 'so_12387212.xlsx' )
ws = wb[ wb.sheetnames[0] ]
cell11 = ws.cell(1, 1)
cell11.number_format = '0'
wb.save( 'so_12387212.xlsx' )
wb.close()

Adapt it as needed.

Solution 2:

Select all the rows in column B and change it to Numeric. 1- select all the numbers - go to the home tab - change from general to numeric. 2- select all of the numbers - right-click the mouse - select change format - change it to numeric and change it to number.

Post a Comment for "How To 'format Cells' With Openpyxl?"