certflow.handlers.styled_excel_importer module

带样式 Excel 导入处理器

提供销售计划 Excel 的带格式读取、样式解析和格式信息合并功能。 从 SalePlanService 中拆分出来,作为独立的 Handler 层工具。

功能: - 读取带样式的 Excel(背景色、字体色、批注) - 行隐藏状态检测 - 表头解析和行跳过 - 字体颜色 → 发货状态映射 - 背景颜色 → 产品状态映射 - 格式信息合并到数据记录

class certflow.handlers.styled_excel_importer.StyledExcelImporter[源代码]

基类:object

带样式 Excel 导入处理器

负责读取和解析 Excel 单元格的格式信息, 并将格式信息合并到数据记录中。 所有方法均为静态方法,无状态依赖。

static read_styled_excel(file_path, header_row, sheet_name=0, skip_rows=0)[源代码]

读取带样式的Excel并设置列名

参数:
  • file_path (str) -- Excel文件路径

  • header_row (int | None) -- 用户指定的表头行号,None则自动检测

  • sheet_name (Any) -- 工作表名称或索引,默认为0

  • skip_rows (int) -- 表头之后额外跳过的数据行数(跳过已导入的行)

返回:

(df_data, bg_colors, font_colors, comments, statuses, hidden_rows)

返回类型:

tuple

static merge_format_info(df_data, bg_colors, font_colors, comments, statuses, hidden_rows=None)[源代码]

将格式信息合并到数据记录中

参数:
  • df_data (DataFrame) -- 数据DataFrame

  • bg_colors (DataFrame | None) -- 背景色DataFrame

  • font_colors (DataFrame | None) -- 字体色DataFrame

  • comments (DataFrame | None) -- 批注DataFrame

  • statuses (DataFrame | None) -- 状态DataFrame

  • hidden_rows (list[bool] | None) -- 隐藏行列表

返回:

合并格式信息后的记录列表

返回类型:

list[dict[str, Any]]