绿软下载站:请安心下载,绿色无病毒!

最近更新热门排行
您现在的位置:首页应用软件文件处理→PDF To Excel
PDF To Excel免费版
0
0

PDF To Excel免费版

扫描下载到手机
请输入预约的手机号码
3182人已预约此游戏
确定取消
  • 软件介绍
  • 软件截图
  • 相关下载

Tags:pdf转换成excel表格,pdf导出excel,比较好一点的Excel转PDF

PDF To Excel是一款免费在线PDF转换成Excel转换器,根据pdf转excel的轮子,优化的小工具添加了几个选项。直接上代码,我直接pyinstaller打包了,做了个UI!

PDF To Excel

代码说明

#-*-coding:utf-8-*-
import tkinter as tk
import tkinter.messagebox 
import pdfplumber
import xlwt
from tkinter import filedialog
import os
def file_browse():
    file_path=filedialog.askopenfilename(parent=main_win,initialdir='./',initialfile='tmp',filetypes=[("PDF","*.pdf"),("All files","*")])
    #获取文件路径
    #a=os.path.split(file_path)
    my_file_name.set(file_path)
def page_tran():
    workbook = xlwt.Workbook()  #定义workbook
    sheet = workbook.add_sheet('Sheet1')  #添加sheet
    i = 0 # Excel起始位置
    path = my_file_name.get()
    print(path)    # 导入PDF路径
    
    with pdfplumber.open(path) as pdf:
        w_label4.insert('end','开始读取数据...')
        p=my_page.get()-1 #页数从0开始
     # 获取当前页面的全部文本信息,包括表格中的文字
        page=pdf.pages[p]
     # 获取当前页面的全部文本信息,包括表格中的文字
        for table in page.extract_tables():
                 for row in table:
                     for j in range(len(row)):
                         sheet.write(i, j, row[j])
                     i += 1
                 print('---------- 分割线 ----------')
    path = my_file_name.get()
    a=os.path.split(path)
    b=a[1].split('.')   
    ex_name=a[0]+'/'+b[0]+'-p'+str(p+1)+'.xls'
    workbook.save(ex_name)
    w_label4.insert('end','excel转换成功\n')
    
def index_tran():
    workbook = xlwt.Workbook()  #定义workbook
    sheet = workbook.add_sheet('Sheet1')  #添加sheet
    i = 0 # Excel起始位置
    path = my_file_name.get()
    #print(path)    # 导入PDF路径
    
    with pdfplumber.open(path) as pdf:
        w_label4.insert('end', '开始读取数据...')
        first=my_index1.get()-1
        last=my_index2.get()
        ind_list=list(range(first,last))
        for k in ind_list:
     # 获取当前页面的全部文本信息,包括表格中的文字
            page=pdf.pages[k]
             # 获取当前页面的全部文本信息,包括表格中的文字
            for table in page.extract_tables():
                 for row in table:
                     for j in range(len(row)):
                         sheet.write(i, j, row[j])
                     i += 1
                 print('---------- 分割线 ----------')
    path = my_file_name.get()
    a=os.path.split(path)
    b=a[1].split('.')   
    ex_name=a[0]+'/'+b[0]+'-p'+str(first+1)+'-'+str(last)+'.xls'
    workbook.save(ex_name)
    w_label4.insert('end','excel转换成功\n')
                
def all_tran():
    workbook = xlwt.Workbook()  #定义workbook
    sheet = workbook.add_sheet('Sheet1')  #添加sheet
    i = 0 # Excel起始位置
    path = my_file_name.get()
    print(path)    # 导入PDF路径
    
    with pdfplumber.open(path) as pdf:
        w_label4.insert('end', '开始读取数据...')
        for page in pdf.pages:
             # 获取当前页面的全部文本信息,包括表格中的文字
            for table in page.extract_tables():
                 for row in table:
                     for j in range(len(row)):
                         sheet.write(i, j, row[j])
                     i += 1
                 print('---------- 分割线 ----------')
    path = my_file_name.get()
    a=os.path.split(path)
    b=a[1].split('.')   
    ex_name=a[0]+'/'+b[0]+'.xls'
    workbook.save(ex_name)
    w_label4.insert('end','excel转换成功\n')
def tran2ex(): 
    print(chkVar1.get())
    if chkVar1.get()==1:
        print(chkVar1.get())
        page_tran()    
    if chkVar1.get()==2:
        print(chkVar2.get())
        index_tran()    
    if chkVar1.get()==3:
        print(chkVar3.get())
        all_tran()
main_win=tk.Tk()
main_win.title('PDF to EXCEL                    Created by Wolf')
main_win.geometry('450x240')
main_win.resizable(width=True, height=True)
w_label1=tk.Label(main_win,text='请选择PDF文件:')
w_label3=tk.Label(main_win,text='到')
w_label4=tk.Text(main_win,width=40,height=1)
#标签
my_file_name=tk.StringVar()
my_entry=tk.Entry(main_win,width=30,textvariable=my_file_name)
#输入kuang
my_page=tk.IntVar()
my_entry_numb3=tk.Entry(main_win,width=5,textvariable=my_page)
my_index1=tk.IntVar()
my_entry_numb1=tk.Entry(main_win,width=5,textvariable=my_index1)
my_index2=tk.IntVar()
my_entry_numb2=tk.Entry(main_win,width=5,textvariable=my_index2)
chkVar1=tk.IntVar()
my_chk3=tk.Radiobutton(main_win,text='全部',variable=chkVar1,value=3)
my_chk1=tk.Radiobutton(main_win,text='单页 ',variable=chkVar1,value=1)
my_chk2=tk.Radiobutton(main_win,text='页数从',variable=chkVar1,value=2)
#单选按钮
my_button3=tk.Button(main_win,text='浏览',command=file_browse)
#浏览文件按钮
my_button1=tk.Button(main_win,width=10,text='转换',command=tran2ex)
my_button2=tk.Button(main_win,width=10,text='退出',command=main_win.quit)
w_label1.place(x=50,y=40)
my_entry.place(x=140,y=40)
my_button3.place(x=360,y=40)
my_chk2.place(x=50,y=100)
my_entry_numb1.place(x=120,y=100)
w_label3.place(x=160,y=100)
my_entry_numb2.place(x=180,y=100)
my_chk1.place(x=50,y=75)
my_entry_numb3.place(x=120,y=75)
my_chk3.place(x=50,y=130)
w_label4.place(x=60,y=160)
my_button1.place(x=120,y=200)
my_button2.place(x=280,y=200)
main_win.mainloop()

使用方法

1、在本极速下载下载解压文件,解压后找到“PDF2excel.exe”双击打开

2、稍等片刻就会出现下图的界面,欢迎使用

PDF To Excel免费版

普通下载地址:
电信下载
移动下载

文件处理

软件评论 请自觉遵守互联网相关政策法规,评论内容只代表网友观点,与本站立场无关!

 
网友评论