首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【自动化办公】一键批量格式互转 + excel转pdf,word,图片+word转pdf,excel,图片 + 支持windows系统

【自动化办公】一键批量格式互转 + excel转pdf,word,图片+word转pdf,excel,图片 + 支持windows系统

原创
作者头像
家庭Q秋-3993387644
发布2025-09-11 16:04:00
发布2025-09-11 16:04:00
22300
代码可运行
举报
文章被收录于专栏:小鱼办公小鱼办公
运行总次数:0
代码可运行

视频功能演示

背景痛点

前阵子xx公司有一批excel 需要转成PDF 文件, 且需要保持源样式:

 但是,问题来了,excel有上千份,如果每一份都要手动打开进行转换,需要花费猴年马月的时间!

这里我有一个解决方案:可以指定excel目录, 然后进行批量一键转换即可。

功能概述

专门进行批量转格式的工具,目前支持: xlsx转docx,xlsx转pdf,xlsx转png ,docx转xlsx,docx转pdf,docx转png。

首先我们需要选择要转换格式的目标文件目录,支持拖拽:

 然后选择一个功能:

然后点击开始开始转换,就会自动执行,结果文件在excel目录的out下面:

如果您有疑问可以一起来探讨,功能就介绍到 这里 ,希望能帮助大家,感谢!!!

如果您有疑问可以一起来探讨,功能就介绍到 这里 ,希望能帮助大家,感谢!!!

技术实现原理

软件是基于Python开发的现代化办公自动化软件,主要使用了如下技术架构:

1. PySide6 (Qt6) - 现代化GUI界面框架:

2. springboot: 格式的调整是通过后端java实现的。

3. 文件处理:os.walk() - 递归遍历目录结构。

部分代码解析

项目的 开始 按钮,会开启一个QThread线程去处理,首先是获取移除目录, 然后通过os.walk遍历目录获取到所有文件,然后一个一个进行处理,代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
批量格式转换服务
提供Excel转PDF、Excel转图片、Excel转Word等格式转换功能
"""
import os

from api.excel_api import ExcelAPI


class FormatConvertService:
    """格式转换服务类"""

    def __init__(self):
        self.excel_api = ExcelAPI()

    def get_excel_files(self, directory):
        """获取目录下的所有Excel文件"""
        excel_files = []
        for root, dirs, files in os.walk(directory):
            # 跳过out.error目录
            if "out" in dirs:
                dirs.remove("out")
            if "error" in dirs:
                dirs.remove("error")
            for file in files:
                if file.lower().endswith(('.xlsx', '.xls')):
                    excel_files.append(os.path.join(root, file))
        return excel_files

    def get_word_files(self, directory):
        """获取目录下的所有Excel文件"""
        excel_files = []
        for root, dirs, files in os.walk(directory):
            # 跳过out.error目录
            if "out" in dirs:
                dirs.remove("out")
            if "error" in dirs:
                dirs.remove("error")
            for file in files:
                if file.lower().endswith(('.docx', '.doc')):
                    excel_files.append(os.path.join(root, file))
        return excel_files

    def convert_excel_to_pdf(self, excel_file, output_file):
        """将Excel转换为PDF"""
        self.excel_api.excel_to_pdf(excel_file, output_file)

    def convert_excel_to_image(self, excel_file, output_file):
        """将Excel转换为图片"""
        self.excel_api.excel_to_png(excel_file, output_file)

    def convert_excel_to_word(self, excel_file, output_file):
        """将Excel转换为Word"""
        self.excel_api.excel_to_word(excel_file, output_file)

    def convert_word_to_excel(self, excel_file, output_file):
        self.excel_api.word_to_excel(excel_file, output_file)

    def convert_word_to_pdf(self, excel_file, output_file):
        self.excel_api.word_to_pdf(excel_file, output_file)

    def convert_word_to_png(self, excel_file, output_file):
        self.excel_api.word_to_png(excel_file, output_file)

代码没有开源噢。如果您有疑问可以一起来探讨,今天就介绍到 这里 ,希望能帮助大家,感谢!!!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 视频功能演示
  • 背景痛点
    • 功能概述
  • 技术实现原理
    • 部分代码解析
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档