Skip to content

Instantly share code, notes, and snippets.

@secsilm
Last active August 1, 2019 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secsilm/a6cfa1addab089df23b242893e50f1f2 to your computer and use it in GitHub Desktop.
Save secsilm/a6cfa1addab089df23b242893e50f1f2 to your computer and use it in GitHub Desktop.
Python 读取 excel 文件并保留格式
from openpyxl import load_workbook
def read_color(f):
wb = load_workbook(f)
ws = wb.active
for row in ws.iter_rows():
for cell in row:
print(f"cell value={cell.value}, cell color={cell.fill.start_color.index}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment