Skip to content

Commit

Permalink
fix system default setting
Browse files Browse the repository at this point in the history
  • Loading branch information
itlubber committed Apr 29, 2024
1 parent bb78cd4 commit 00507b6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scorecardpipeline/excel_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@Author : itlubber
@Site : itlubber.art
"""
import sys
import warnings

warnings.filterwarnings("ignore")
Expand All @@ -27,7 +28,7 @@

class ExcelWriter:

def __init__(self, style_excel=None, style_sheet_name="初始化", mode="replace", fontsize=10, font='楷体', theme_color='2639E9', opacity=0.85, system="mac"):
def __init__(self, style_excel=None, style_sheet_name="初始化", mode="replace", fontsize=10, font='楷体', theme_color='2639E9', opacity=0.85, system=None):
"""excel 写入方法
:param style_excel: 样式模版文件,默认安装包路径下的 template.xlsx ,如果路径调整需要进行相应的调整
Expand All @@ -40,6 +41,10 @@ def __init__(self, style_excel=None, style_sheet_name="初始化", mode="replace
:param opacity: 写入dataframe时使用颜色填充主题色的透明度设置,默认 0.85
"""
self.system = system

if self.system is None:
self.system = "mac" if sys.platform == "darwin" else "windows"

self.english_width = 0.12
self.chinese_width = 0.21
self.mode = mode
Expand Down Expand Up @@ -204,7 +209,7 @@ def insert_pic2sheet(self, worksheet, fig, insert_space, figsize=(600, 250)):
image.width, image.height = figsize
worksheet.add_image(image, f"{start_col}{start_row}")

return start_row + int(figsize[1] / (17.5 if self.system != 'windows' else 16.0)), column_index_from_string(start_col) + 8
return start_row + int(figsize[1] / (16.0 if self.system != 'mac' else 17.5)), column_index_from_string(start_col) + 8

def insert_rows(self, worksheet, row, row_index, col_index, merge_rows=None, style="", auto_width=False, style_only=False, multi_levels=False):
"""
Expand Down

0 comments on commit 00507b6

Please sign in to comment.