excel操作xls xlsx¶
提示
openpyxl 封装的excel操作
需要安装 openpyxl
pip install openpyxl
- class pyefun.excel.excel_openpyxl.Excel[源代码]¶
基类:
object
- 置单元格字体风格(行: int, 列: int, 字体名称='微软雅黑', 字体大小=11, 加粗=False, 斜体=False, 删除线=False, 颜色='ffffff')[源代码]¶
白=ffffff 红=ff0000 黄=ffff00 绿=33ff00 蓝=0000ff 黑=000000 紫=9900ff
- 置单元格对齐方式(行: int, 列: int, 对齐方式=<openpyxl.styles.alignment.Alignment object> Parameters: horizontal='justify', vertical='justify', textRotation=0, wrapText=None, shrinkToFit=None, indent=0.0, relativeIndent=0.0, justifyLastLine=None, readingOrder=0.0)[源代码]¶
horizontal代表水平方向,可以左对齐left,还有居中center和右对齐right,分散对齐distributed,跨列居中centerContinuous,两端对齐justify,填充fill,常规general
vertical代表垂直方向,可以居中center,还可以靠上top,靠下bottom,两端对齐justify,分散对齐distributed
另外还有自动换行:wrap_text,这是个布尔类型的参数,这个参数还可以写作wrapText
- 置单元格背景颜色(行: int, 列: int, 颜色='ffffff')[源代码]¶
# 1开始 注意:fill_type为填充类型,如果不写的话,则没有效果。 默认纯色填充 颜色代号 白=ffffff 红=ff0000 黄=ffff00 绿=33ff00 蓝=0000ff 黑=000000 紫=9900ff
- 置单元格边框(行: int, 列: int, left=<openpyxl.styles.borders.Side object> Parameters: style='thin', color=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', right=<openpyxl.styles.borders.Side object> Parameters: style='thin', color=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', top=<openpyxl.styles.borders.Side object> Parameters: style='thin', color=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', bottom=<openpyxl.styles.borders.Side object> Parameters: style='thin', color=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb')[源代码]¶