|
@@ -183,12 +183,6 @@ class ExcelProcessor:
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
pd.DataFrame: 包含新列的DataFrame
|
|
pd.DataFrame: 包含新列的DataFrame
|
|
|
-
|
|
|
|
|
- example:
|
|
|
|
|
- processor.insert_column('B', '翻译结果')
|
|
|
|
|
- ref_column_list = [match[1] for match in matches]
|
|
|
|
|
- for ref_column in ref_column_list:
|
|
|
|
|
- processor.insert_column(ref_column, '翻译结果')
|
|
|
|
|
"""
|
|
"""
|
|
|
df = self.df
|
|
df = self.df
|
|
|
try:
|
|
try:
|
|
@@ -206,7 +200,14 @@ class ExcelProcessor:
|
|
|
# 插入新列
|
|
# 插入新列
|
|
|
df.insert(insert_index, new_column_name, '')
|
|
df.insert(insert_index, new_column_name, '')
|
|
|
|
|
|
|
|
- logger.info(f"成功在列 '{ref_column}' 的 '{position}' 插入新列 '{new_column_name}' ")
|
|
|
|
|
|
|
+ # 调整表头行数据
|
|
|
|
|
+ if self.header_row > 0:
|
|
|
|
|
+ # 将新列的表头行设置为空
|
|
|
|
|
+ df.iloc[:self.header_row, insert_index] = ''
|
|
|
|
|
+ # 在表头行设置新列名
|
|
|
|
|
+ df.iloc[self.header_row, insert_index] = new_column_name
|
|
|
|
|
+
|
|
|
|
|
+ logger.info(f"成功在列 '{ref_column}' 的 '{position}' 插入新列 '{new_column_name}'")
|
|
|
return df
|
|
return df
|
|
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|