顾名思义,该项目是 Python 用来处理 Excel 文档的开发包,无需 Windows 以及 Excel 环境的支持。
该项目包含五个子项目:
示例代码:
from openpyxl import Workbook wb = Workbook() # grab the active worksheet ws = wb.active # Data can be assigned directly to cells ws['A1'] = 42 # Rows can also be appended ws.append([1, 2, 3]) # Python types will automatically be converted import datetime ws['A2'] = datetime.datetime.now() # Save the file wb.save("sample.xlsx")