PC_excel异常大

原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明以下出处,否则追究版权法律责任。

深蓝的blog:http://blog.youkuaiyun.com/huangyanlong/article/details/44974723

 

        近日在汇总某些信息的EXCEL的统计表时,发现文字类的excel文档在粘贴了几个“工作页”后,大小由300kb变成30M以上。

 

       这种异常的大,感觉是不正常的,因为添加的工作页都是数据结构信息,信息量并不大。开始纠错,发现如下:

        空单元格到1048576,猜测有可能是工程师在粘贴某些结构时把公式或空单元格引入到文档里了。于是,将这些无用的单元格进行删除。

        删除后,excel大小有30M变成333kb,在打开文档效率和邮件发送上都变得便捷了!

        这算不算excel的优化?!O(_)O~

 

小知识,简而记之。

 

原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明以下出处,否则追究版权法律责任。

深蓝的blog:http://blog.youkuaiyun.com/huangyanlong/article/details/44974723 

 

merge_root_path = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_MERGE_NAME) translation_excel_folder_path = os.path.join(merge_root_path, 'Translation_Excel') if not os.path.exists(translation_excel_folder_path): print('目标翻译文件 {0} 路径不存在'.format(translation_excel_folder_path)) exit(1) merge_android_src_path = os.path.join(merge_root_path, 'Android', 'values-old') merge_android_dst_path = os.path.join(merge_root_path, 'Android', 'values-new') merge_ios_src_path = os.path.join(merge_root_path, 'iOS', 'strings-old') merge_ios_dst_path = os.path.join(merge_root_path, 'iOS', 'strings-new') merge_flutter_src_path = os.path.join(merge_root_path, 'Flutter', 'l10n-old') merge_flutter_dst_path = os.path.join(merge_root_path, 'Flutter', 'l10n-new') merge_pc_src_path = os.path.join(merge_root_path, 'PC', 'old') merge_pc_dst_path = os.path.join(merge_root_path, 'PC', 'new') enable_android_merge = os.path.exists(merge_android_src_path) enable_ios_merge = os.path.exists(merge_ios_src_path) enable_flutter_merge = os.path.exists(merge_flutter_src_path) enable_pc_merge = os.path.exists(merge_pc_src_path) if not os.path.exists(merge_android_dst_path): os.makedirs(merge_android_dst_path) if not os.path.exists(merge_ios_dst_path): os.makedirs(merge_ios_dst_path) if not os.path.exists(merge_flutter_dst_path): os.makedirs(merge_flutter_dst_path) if not os.path.exists(merge_pc_dst_path): os.makedirs(merge_pc_dst_path) if enable_android_merge or enable_ios_merge or enable_flutter_merge or enable_pc_merge: refer_excel_file = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_COMMON_NAME, 'Refer_Standard.xls') if os.path.exists(refer_excel_file): refer_tuple = TranslateInfoExcelReader.read_excel_content_list(refer_excel_file) else: refer_tuple = [] translation_excel_file_list = os.listdir(translation_excel_folder_path) translation_excel_file_list = [x for x in translation_excel_file_list if x.endswith(".xlsx")] curr_time = time.strftime('%Y-%m-%d-%X', time.localtime(time.time())).replace(":", '') android_log_file_name = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_MERGE_NAME, 'Translation_Log', "AndroidLog" + str(curr_time) + ".txt") flutter_log_file_name = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_MERGE_NAME, 'Translation_Log', "FlutterLog" + str(curr_time) + ".txt") pc_log_file_name = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_MERGE_NAME, 'Translation_Log', "PCLog" + str(curr_time) + ".txt") ios_log_file_name = os.path.join(Config.CURRENT_WORKSPACE_ROOT_PATH, Config.CURRENT_WORKSPACE_MERGE_NAME, 'Translation_Log', "Log-漏翻记录.txt") extract_root_path = os.path.join(Config.WORKSPACE_BASE_PATH ) locale_json_dst_file = os.path.join(os.path.join(extract_root_path), 'all_englist_translate_dict.text') all_english_translate_dict = dict() with open(locale_json_dst_file, 'r', encoding='utf-8') as f: all_english_translate_dict = json.load(f) if os.path.exists(ios_log_file_name): os.remove(ios_log_file_name) for excel in translation_excel_file_list: excel_file = os.path.join(translation_excel_folder_path, excel) print(excel_file) excel_dict = TranslateInfoExcelReader.read_excel_content_dict(excel_file) for item in excel_dict.values(): check_formatter(item.english, item.translate_result) for refer in refer_tuple: if refer.translate_result in excel_dict: english = refer.english platform = refer.platform no = refer.no note = refer.note translate = FormatSpecifierParser.build_format_char(refer.english, refer.translate_result, excel_dict[ refer.translate_result].translate_result) excel_dict[english] = TranslateInfo(english, translate, platform, no, note) locale = excel.replace('.xlsx', '') for item in excel_dict.values(): # print(excel, item.english, item.translate_result) if item.english in all_english_translate_dict: all_english_translate_dict[item.english][locale] = item.translate_result else: tmp_translate_dict = dict() tmp_translate_dict[locale] = item.translate_result all_english_translate_dict[item.english] = tmp_translate_dict if enable_android_merge and locale in Config.ANDROID_LOCALE_DICT: locale_path = 'values-' + Config.ANDROID_LOCALE_DICT[locale] merge_android_src_english_file = os.path.join(merge_android_src_path, 'values', 'strings.xml') merge_android_src_locale_file = os.path.join(merge_android_src_path, locale_path, 'strings.xml') merge_android_dst_locale_path = os.path.join(merge_android_dst_path, locale_path) XmlMerger(excel_dict, merge_android_src_english_file, merge_android_src_locale_file, merge_android_dst_locale_path, android_log_file_name).merge(1) if enable_ios_merge and locale in Config.IOS_LOCALE_DICT: locale_path = Config.IOS_LOCALE_DICT[locale] + '.lproj' merge_ios_src_english_path = os.path.join(merge_ios_src_path, 'en.lproj') merge_ios_dst_english_path = os.path.join(merge_ios_dst_path, 'en.lproj') merge_ios_src_locale_path = os.path.join(merge_ios_src_path, locale_path) merge_ios_dst_locale_path = os.path.join(merge_ios_dst_path, locale_path) StringsMerger(locale, excel_dict, merge_ios_src_english_path, merge_ios_dst_english_path, merge_ios_src_locale_path, merge_ios_dst_locale_path).merge() if enable_flutter_merge and locale in Config.FLUTTER_LOCALE_DICT: locale_path = Config.FLUTTER_LOCALE_DICT[locale] merge_flutter_src_english_file = os.path.join(merge_flutter_src_path, 'intl_en.arb') merge_flutter_src_locale_file = os.path.join(merge_flutter_src_path, 'intl_' + locale_path + '.arb') merge_flutter_dst_locale_path = os.path.join(merge_flutter_dst_path, 'intl_' + locale_path + '.arb') FlutterMerger(excel_dict, merge_flutter_src_english_file, merge_flutter_src_locale_file, merge_flutter_dst_locale_path, flutter_log_file_name).merge(1) if enable_pc_merge and locale in Config.PC_LOCALE_DICT: locale_path = Config.PC_LOCALE_DICT[locale] merge_pc_src_english_file = os.path.join(merge_pc_src_path, 'en.json') merge_pc_src_locale_file = os.path.join(merge_pc_src_path, locale_path + '.json') merge_pc_dst_locale_path = os.path.join(merge_pc_dst_path, locale_path + '.json') FlutterMerger(excel_dict, merge_pc_src_english_file, merge_pc_src_locale_file, merge_pc_dst_locale_path, pc_log_file_name).merge(1) locale_json_dst_file = os.path.join(os.path.join(extract_root_path), 'all_englist_translate_dict_new.text') with open(locale_json_dst_file, 'w', encoding='utf8') as f2: json.dump(all_english_translate_dict, f2, ensure_ascii=False, indent=2) 代码解析
最新发布
06-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值