当前位置:首页>python>Python可视化工具,支持自定义分页标签数量基于模板和数据表批量生成打印标签

Python可视化工具,支持自定义分页标签数量基于模板和数据表批量生成打印标签

  • 2026-02-05 01:07:53
Python可视化工具,支持自定义分页标签数量基于模板和数据表批量生成打印标签

要实现一个Python可视化工具,支持自定义分页标签数量、保存10组配置、基于模板和数据表批量生成打印标签,用tkinter做可视化界面,reportlab生成PDF标签(方便打印),json保存配置参数,来满足你的全部需求。

核心功能实现思路

  1. 数据存储:用JSON保存10组配置,支持自定义配置名称。
  2. 可视化界面:提供配置编辑、分页数量设置、模板选择、数据导入、配置保存/加载功能。
  3. 标签生成:基于reportlab批量生成PDF格式标签(可直接打印),支持自定义每页标签数量。
  4. 模板兼容:支持自定义标签尺寸、边距、字体等样式参数。

前置依赖安装

首先安装所需第三方库,打开终端执行:

pip install reportlab pandas tkintertable  # tkinter一般Python自带,pandas用于处理数据表

完整实现代码

import tkinter as tkfrom tkinter import ttk, filedialog, messageboximport jsonimport osfrom reportlab.pdfgen import canvasfrom reportlab.lib.pagesizes import A4, mmfrom reportlab.pdfbase import pdfmetricsfrom reportlab.pdfbase.cidfonts import UnicodeCIDFontimport pandas as pd# 全局配置常量CONFIG_FILE = "label_configs.json"# 配置文件保存路径MAX_CONFIG_COUNT = 10# 最多保存10组配置DEFAULT_CONFIG = {"config_name""默认配置1","label_width"60,  # 标签宽度(mm)"label_height"30,  # 标签高度(mm)"page_margin_x"10,  # 页面左右边距(mm)"page_margin_y"10,  # 页面上下边距(mm)"labels_per_row"3,  # 每页每行标签数量"labels_per_col"8,  # 每页每列标签数量(分页核心参数)"font_size"10,  # 标签字体大小"data_path""",  # 数据表路径(xlsx/csv)"output_pdf""批量标签输出.pdf"# 输出PDF路径}# 初始化配置文件definit_config_file():ifnot os.path.exists(CONFIG_FILE):        default_configs = [DEFAULT_CONFIG.copy() for _ in range(MAX_CONFIG_COUNT)]for i, cfg in enumerate(default_configs):            cfg["config_name"] = f"默认配置{i+1}"with open(CONFIG_FILE, "w", encoding="utf-8"as f:            json.dump(default_configs, f, ensure_ascii=False, indent=4)# 加载所有配置defload_all_configs():ifnot os.path.exists(CONFIG_FILE):        init_config_file()with open(CONFIG_FILE, "r", encoding="utf-8"as f:return json.load(f)# 保存单组配置defsave_single_config(config_index, new_config):    configs = load_all_configs()if0 <= config_index < MAX_CONFIG_COUNT:        configs[config_index] = new_configwith open(CONFIG_FILE, "w", encoding="utf-8"as f:            json.dump(configs, f, ensure_ascii=False, indent=4)returnTruereturnFalse# 生成标签PDF核心函数defgenerate_label_pdf(config):try:# 1. 验证配置参数        required_keys = ["label_width""label_height""page_margin_x""page_margin_y","labels_per_row""labels_per_col""font_size""data_path""output_pdf"]for key in required_keys:if key notin config:raise Exception(f"配置缺失关键参数:{key}")# 2. 加载数据表        data_path = config["data_path"]ifnot os.path.exists(data_path):raise Exception("数据表文件不存在,请检查路径")if data_path.endswith(".xlsx"):            df = pd.read_excel(data_path)elif data_path.endswith(".csv"):            df = pd.read_csv(data_path, encoding="utf-8-sig")else:raise Exception("仅支持xlsx/csv格式数据表")if df.empty:raise Exception("数据表中无有效数据")# 3. 转换单位(mm -> point,reportlab默认单位)        label_width = config["label_width"] * mm        label_height = config["label_height"] * mm        page_margin_x = config["page_margin_x"] * mm        page_margin_y = config["page_margin_y"] * mm        labels_per_row = int(config["labels_per_row"])        labels_per_col = int(config["labels_per_col"])        font_size = int(config["font_size"])# 4. 初始化PDF画布        c = canvas.Canvas(config["output_pdf"], pagesize=A4)        pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))  # 注册中文字体        chinese_font = "STSong-Light"# 5. 计算每页标签总数和标签位置偏移        labels_per_page = labels_per_row * labels_per_col        x_step = label_width  # 横向标签间距(与标签宽度一致,无额外间距)        y_step = label_height  # 纵向标签间距(与标签高度一致,无额外间距)        start_x = page_margin_x# 从页面下方开始绘制(reportlab坐标原点在左下角)        start_y = A4[1] - page_margin_y - label_height# 6. 批量绘制标签        data_list = df.to_dict("records")  # 转换数据为字典列表for idx, record in enumerate(data_list):# 计算当前标签在页面内的位置            page_idx = idx // labels_per_page            label_in_page_idx = idx % labels_per_page            row_idx = label_in_page_idx // labels_per_row            col_idx = label_in_page_idx % labels_per_row# 新建页面(非第一页且为新页面第一个标签时)if label_in_page_idx == 0and idx > 0:                c.showPage()# 计算当前标签的坐标            current_x = start_x + col_idx * x_step            current_y = start_y - row_idx * y_step# 绘制标签边框(方便对齐打印)            c.rect(current_x, current_y, label_width, label_height, stroke=1, fill=0)# 绘制标签内容(拼接所有列数据,换行显示)            text = c.beginText(current_x + 5, current_y + label_height - 10)  # 内边距5pt            text.setFont(chinese_font, font_size)for key, value in record.items():                text.textLine(f"{key}{str(value)}")            c.drawText(text)# 7. 保存PDF        c.save()returnTruef"标签生成成功!共生成{len(data_list)}个标签,保存至:{config['output_pdf']}"except Exception as e:returnFalsef"标签生成失败:{str(e)}"# 可视化界面类classLabelGeneratorApp:def__init__(self, root):        self.root = root        self.root.title("万能批量打印标签生成器(支持自定义分页)")        self.root.geometry("800x600")# 加载配置        self.configs = load_all_configs()        self.current_config_idx = tk.IntVar(value=0)# 创建界面组件        self.create_widgets()defcreate_widgets(self):# 1. 配置选择区域        frame_config_select = ttk.LabelFrame(self.root, text="配置选择(最多保存10组)")        frame_config_select.pack(fill="x", padx=10, pady=5)        ttk.Label(frame_config_select, text="选择配置:").grid(row=0, column=0, padx=5, pady=5)        self.config_combobox = ttk.Combobox(frame_config_select, textvariable=self.current_config_idx,                                            values=list(range(MAX_CONFIG_COUNT)), state="readonly")        self.config_combobox.grid(row=0, column=1, padx=5, pady=5)        self.config_combobox.bind("<<ComboboxSelected>>", self.load_current_config)        ttk.Label(frame_config_select, text="配置名称:").grid(row=0, column=2, padx=5, pady=5)        self.config_name_entry = ttk.Entry(frame_config_select)        self.config_name_entry.grid(row=0, column=3, padx=5, pady=5)        ttk.Button(frame_config_select, text="加载选中配置", command=self.load_current_config).grid(row=0, column=4, padx=5, pady=5)        ttk.Button(frame_config_select, text="保存当前配置", command=self.save_current_config).grid(row=0, column=5, padx=5, pady=5)# 2. 标签样式配置区域        frame_label_style = ttk.LabelFrame(self.root, text="标签样式与分页配置")        frame_label_style.pack(fill="x", padx=10, pady=5)# 2.1 标签尺寸        ttk.Label(frame_label_style, text="标签宽度(mm):").grid(row=0, column=0, padx=5, pady=5)        self.label_width_entry = ttk.Entry(frame_label_style)        self.label_width_entry.grid(row=0, column=1, padx=5, pady=5)        ttk.Label(frame_label_style, text="标签高度(mm):").grid(row=0, column=2, padx=5, pady=5)        self.label_height_entry = ttk.Entry(frame_label_style)        self.label_height_entry.grid(row=0, column=3, padx=5, pady=5)# 2.2 页面边距        ttk.Label(frame_label_style, text="页面左右边距(mm):").grid(row=1, column=0, padx=5, pady=5)        self.page_margin_x_entry = ttk.Entry(frame_label_style)        self.page_margin_x_entry.grid(row=1, column=1, padx=5, pady=5)        ttk.Label(frame_label_style, text="页面上下边距(mm):").grid(row=1, column=2, padx=5, pady=5)        self.page_margin_y_entry = ttk.Entry(frame_label_style)        self.page_margin_y_entry.grid(row=1, column=3, padx=5, pady=5)# 2.3 分页标签数量(核心改进)        ttk.Label(frame_label_style, text="每页每行标签数:").grid(row=2, column=0, padx=5, pady=5)        self.labels_per_row_entry = ttk.Entry(frame_label_style)        self.labels_per_row_entry.grid(row=2, column=1, padx=5, pady=5)        ttk.Label(frame_label_style, text="每页每列标签数:").grid(row=2, column=2, padx=5, pady=5)        self.labels_per_col_entry = ttk.Entry(frame_label_style)        self.labels_per_col_entry.grid(row=2, column=3, padx=5, pady=5)# 2.4 字体大小        ttk.Label(frame_label_style, text="字体大小:").grid(row=3, column=0, padx=5, pady=5)        self.font_size_entry = ttk.Entry(frame_label_style)        self.font_size_entry.grid(row=3, column=1, padx=5, pady=5)# 3. 数据与输出配置区域        frame_data_output = ttk.LabelFrame(self.root, text="数据与输出配置")        frame_data_output.pack(fill="x", padx=10, pady=5)        ttk.Label(frame_data_output, text="数据表路径:").grid(row=0, column=0, padx=5, pady=5)        self.data_path_entry = ttk.Entry(frame_data_output, width=50)        self.data_path_entry.grid(row=0, column=1, padx=5, pady=5)        ttk.Button(frame_data_output, text="选择文件", command=self.select_data_file).grid(row=0, column=2, padx=5, pady=5)        ttk.Label(frame_data_output, text="输出PDF路径:").grid(row=1, column=0, padx=5, pady=5)        self.output_pdf_entry = ttk.Entry(frame_data_output, width=50)        self.output_pdf_entry.grid(row=1, column=1, padx=5, pady=5)        ttk.Button(frame_data_output, text="选择保存位置", command=self.select_output_pdf).grid(row=1, column=2, padx=5, pady=5)# 4. 生成按钮区域        frame_generate = ttk.Frame(self.root)        frame_generate.pack(fill="x", padx=10, pady=10)        ttk.Button(frame_generate, text="批量生成标签PDF", command=self.generate_labels, style="Accent.TButton").pack(side="center")# 5. 初始化加载默认配置        self.load_current_config()defselect_data_file(self):        file_path = filedialog.askopenfilename(title="选择数据表", filetypes=[("Excel/CSV文件""*.xlsx *.csv"), ("所有文件""*.*")])if file_path:            self.data_path_entry.delete(0, tk.END)            self.data_path_entry.insert(0, file_path)defselect_output_pdf(self):        file_path = filedialog.asksaveasfilename(title="保存PDF标签", defaultextension=".pdf", filetypes=[("PDF文件""*.pdf"), ("所有文件""*.*")])if file_path:            self.output_pdf_entry.delete(0, tk.END)            self.output_pdf_entry.insert(0, file_path)defload_current_config(self, event=None):        config_idx = self.current_config_idx.get()        config = self.configs[config_idx]# 填充界面输入框        self.config_name_entry.delete(0, tk.END)        self.config_name_entry.insert(0, config.get("config_name"""))        self.label_width_entry.delete(0, tk.END)        self.label_width_entry.insert(0, config.get("label_width"60))        self.label_height_entry.delete(0, tk.END)        self.label_height_entry.insert(0, config.get("label_height"30))        self.page_margin_x_entry.delete(0, tk.END)        self.page_margin_x_entry.insert(0, config.get("page_margin_x"10))        self.page_margin_y_entry.delete(0, tk.END)        self.page_margin_y_entry.insert(0, config.get("page_margin_y"10))        self.labels_per_row_entry.delete(0, tk.END)        self.labels_per_row_entry.insert(0, config.get("labels_per_row"3))        self.labels_per_col_entry.delete(0, tk.END)        self.labels_per_col_entry.insert(0, config.get("labels_per_col"8))        self.font_size_entry.delete(0, tk.END)        self.font_size_entry.insert(0, config.get("font_size"10))        self.data_path_entry.delete(0, tk.END)        self.data_path_entry.insert(0, config.get("data_path"""))        self.output_pdf_entry.delete(0, tk.END)        self.output_pdf_entry.insert(0, config.get("output_pdf""批量标签输出.pdf"))defsave_current_config(self):try:# 收集界面输入数据            new_config = {"config_name": self.config_name_entry.get().strip(),"label_width": float(self.label_width_entry.get().strip()),"label_height": float(self.label_height_entry.get().strip()),"page_margin_x": float(self.page_margin_x_entry.get().strip()),"page_margin_y": float(self.page_margin_y_entry.get().strip()),"labels_per_row": int(self.labels_per_row_entry.get().strip()),"labels_per_col": int(self.labels_per_col_entry.get().strip()),"font_size": int(self.font_size_entry.get().strip()),"data_path": self.data_path_entry.get().strip(),"output_pdf": self.output_pdf_entry.get().strip()            }# 验证配置名称ifnot new_config["config_name"]:                messagebox.showerror("错误""配置名称不能为空")return# 验证数值合法性if new_config["label_width"] <= 0or new_config["label_height"] <= 0:                messagebox.showerror("错误""标签尺寸必须大于0")returnif new_config["labels_per_row"] <= 0or new_config["labels_per_col"] <= 0:                messagebox.showerror("错误""每页标签数量必须大于0")return# 保存配置            config_idx = self.current_config_idx.get()if save_single_config(config_idx, new_config):                self.configs = load_all_configs()  # 刷新本地配置                messagebox.showinfo("成功""配置保存成功!")else:                messagebox.showerror("错误""配置保存失败,索引超出范围")except ValueError:            messagebox.showerror("错误""请输入合法的数值类型")except Exception as e:            messagebox.showerror("错误"f"保存失败:{str(e)}")defgenerate_labels(self):try:# 先保存当前配置(避免用户未保存直接生成)            self.save_current_config()# 获取当前配置            config_idx = self.current_config_idx.get()            config = self.configs[config_idx]# 生成标签PDF            success, msg = generate_label_pdf(config)if success:                messagebox.showinfo("生成成功", msg)else:                messagebox.showerror("生成失败", msg)except Exception as e:            messagebox.showerror("错误"f"生成过程异常:{str(e)}")# 程序入口if __name__ == "__main__":    root = tk.Tk()    app = LabelGeneratorApp(root)    root.mainloop()

功能使用说明

  1. 初始化运行:直接运行代码,会自动生成label_configs.json配置文件(保存10组默认配置),并弹出可视化界面。
  2. 配置编辑
    • 选择左侧配置索引(0-9,对应10组配置),可自定义配置名称。
    • 填写标签尺寸、页面边距、每页每行/每列标签数量(核心分页参数,比如填写"每行4、每列10",则每页生成40个标签)。
    • 选择数据表(xlsx/csv格式,表头会作为标签内容的字段名)。
  3. 配置保存:点击"保存当前配置",可将当前填写的参数存入对应索引的配置组,下次可直接加载使用。
  4. 生成标签:点击"批量生成标签PDF",会自动生成PDF格式标签(包含边框方便打印对齐),可直接用打印机打印。
  5. 数据表格式要求
    • Excel/csv文件,第一行为表头(如"商品名称"、"规格"、"条形码"),后续行为具体数据。
    • 示例csv内容:
      商品名称,规格,条形码矿泉水,550ml,6901234567890方便面,140g,6909876543210

核心功能亮点

  1. 自定义分页:通过"每页每行/每列标签数量"精准控制单页标签总数,适配不同规格打印纸。
  2. 10组配置保存:配置持久化到JSON文件,无需重复填写参数,支持自定义配置名称方便区分。
  3. 自定义样式:支持标签尺寸、边距、字体大小的自由调整,适配不同场景的标签模板。
  4. 中文支持:内置中文字体,标签内容可正常显示中文。
  5. 可视化操作:无需编写代码,通过图形界面即可完成所有操作,对非技术人员友好。

总结

  1. 该工具通过tkinter实现可视化界面,reportlab生成可打印的PDF标签,json持久化保存10组配置。
  2. 核心分页功能由"每页每行/每列标签数量"控制,可灵活调整单页标签总数,满足不同打印需求。
  3. 支持xlsx/csv数据表导入,中文显示正常,配置操作简单,生成的PDF可直接打印使用。

扩展建议

  1. 可增加标签内容自定义排版(比如指定显示某些字段、调整字段位置)。
  2. 可增加条形码/二维码生成功能,适配商品标签场景。
  3. 可增加标签背景图导入功能,支持更复杂的模板样式。
中间可能回报错,解决方法如如下

你现在的报错核心是 pandas 读取 .xlsx 文件缺少 openpyxl 依赖,而且我们可以在代码中做两层优化:一是明确指定 openpyxl 作为 Excel 读取引擎,二是增加依赖缺失的友好提示,同时确保安装后能正常运行。

修复方案(修改两处核心代码)

1. 修复 pd.read_excel() 调用(指定引擎,避免歧义)

在读取 .xlsx 文件时,明确指定 engine="openpyxl",这是 pandas 新版本读取 Excel 的强制要求(旧版本默认引擎已废弃)。

2. 增加 openpyxl 导入检测(友好提示依赖缺失)

在代码开头增加导入检测,避免用户看到晦涩的报错信息。

完整修复后代码(直接替换即可运行)

import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import json
import os
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4, mm
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.cidfonts import UnicodeCIDFont
import pandas as pd

# 新增:检测 openpyxl 依赖是否安装
try:
import openpyxl
except ImportError:
    openpyxl_available = False
else:
    openpyxl_available = True

# 全局配置常量
CONFIG_FILE = "label_configs.json"# 配置文件保存路径
MAX_CONFIG_COUNT = 10# 最多保存10组配置
DEFAULT_CONFIG = {
"config_name""默认配置1",
"label_width"60,  # 标签宽度(mm)
"label_height"30,  # 标签高度(mm)
"page_margin_x"10,  # 页面左右边距(mm)
"page_margin_y"10,  # 页面上下边距(mm)
"labels_per_row"3,  # 每页每行标签数量
"labels_per_col"8,  # 每页每列标签数量(分页核心参数)
"font_size"10,  # 标签字体大小
"data_path""",  # 数据表路径(xlsx/csv)
"output_pdf""批量标签输出.pdf"# 输出PDF路径
}


# 初始化配置文件
definit_config_file():
ifnot os.path.exists(CONFIG_FILE):
        default_configs = [DEFAULT_CONFIG.copy() for _ in range(MAX_CONFIG_COUNT)]
for i, cfg in enumerate(default_configs):
            cfg["config_name"] = f"默认配置{i + 1}"
with open(CONFIG_FILE, "w", encoding="utf-8"as f:
            json.dump(default_configs, f, ensure_ascii=False, indent=4)


# 加载所有配置
defload_all_configs():
ifnot os.path.exists(CONFIG_FILE):
        init_config_file()
with open(CONFIG_FILE, "r", encoding="utf-8"as f:
return json.load(f)


# 保存单组配置
defsave_single_config(config_index, new_config):
    configs = load_all_configs()
if0 <= config_index < MAX_CONFIG_COUNT:
        configs[config_index] = new_config
with open(CONFIG_FILE, "w", encoding="utf-8"as f:
            json.dump(configs, f, ensure_ascii=False, indent=4)
returnTrue
returnFalse


# 生成标签PDF核心函数
defgenerate_label_pdf(config):
try:
# 1. 验证配置参数
        required_keys = ["label_width""label_height""page_margin_x""page_margin_y",
"labels_per_row""labels_per_col""font_size""data_path""output_pdf"]
for key in required_keys:
if key notin config:
raise Exception(f"配置缺失关键参数:{key}")

# 2. 加载数据表
        data_path = config["data_path"]
ifnot os.path.exists(data_path):
raise Exception("数据表文件不存在,请检查路径")

if data_path.endswith(".xlsx"):
# 修复点1:检测 openpyxl 是否可用,且明确指定 engine="openpyxl"
ifnot openpyxl_available:
raise Exception("缺少读取Excel文件的依赖库!请在终端执行:pip install openpyxl")
            df = pd.read_excel(data_path, engine="openpyxl")  # 明确指定引擎,解决报错核心
elif data_path.endswith(".csv"):
            df = pd.read_csv(data_path, encoding="utf-8-sig")
else:
raise Exception("仅支持xlsx/csv格式数据表")

if df.empty:
raise Exception("数据表中无有效数据")

# 3. 转换单位(mm -> point,reportlab默认单位)
        label_width = config["label_width"] * mm
        label_height = config["label_height"] * mm
        page_margin_x = config["page_margin_x"] * mm
        page_margin_y = config["page_margin_y"] * mm
        labels_per_row = int(config["labels_per_row"])
        labels_per_col = int(config["labels_per_col"])
        font_size = int(config["font_size"])

# 4. 初始化PDF画布
        c = canvas.Canvas(config["output_pdf"], pagesize=A4)
        pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))  # 注册中文字体
        chinese_font = "STSong-Light"

# 5. 计算每页标签总数和标签位置偏移
        labels_per_page = labels_per_row * labels_per_col
        x_step = label_width  # 横向标签间距(与标签宽度一致,无额外间距)
        y_step = label_height  # 纵向标签间距(与标签高度一致,无额外间距)
        start_x = page_margin_x
# 从页面下方开始绘制(reportlab坐标原点在左下角)
        start_y = A4[1] - page_margin_y - label_height

# 6. 批量绘制标签
        data_list = df.to_dict("records")  # 转换数据为字典列表
for idx, record in enumerate(data_list):
# 计算当前标签在页面内的位置
            page_idx = idx // labels_per_page
            label_in_page_idx = idx % labels_per_page
            row_idx = label_in_page_idx // labels_per_row
            col_idx = label_in_page_idx % labels_per_row

# 新建页面(非第一页且为新页面第一个标签时)
if label_in_page_idx == 0and idx > 0:
                c.showPage()

# 计算当前标签的坐标
            current_x = start_x + col_idx * x_step
            current_y = start_y - row_idx * y_step

# 绘制标签边框(方便对齐打印)
            c.rect(current_x, current_y, label_width, label_height, stroke=1, fill=0)

# 绘制标签内容(拼接所有列数据,换行显示)
            text = c.beginText(current_x + 5, current_y + label_height - 10)  # 内边距5pt
            text.setFont(chinese_font, font_size)
for key, value in record.items():
                text.textLine(f"{key}{str(value)}")
            c.drawText(text)

# 7. 保存PDF
        c.save()
returnTruef"标签生成成功!共生成{len(data_list)}个标签,保存至:{config['output_pdf']}"
except Exception as e:
returnFalsef"标签生成失败:{str(e)}"


# 可视化界面类
classLabelGeneratorApp:
def__init__(self, root):
        self.root = root
        self.root.title("万能批量打印标签生成器(支持自定义分页)")
        self.root.geometry("800x600")

# 加载配置
        self.configs = load_all_configs()
        self.current_config_idx = tk.IntVar(value=0)

# 创建界面组件
        self.create_widgets()

defcreate_widgets(self):
# 1. 配置选择区域
        frame_config_select = ttk.LabelFrame(self.root, text="配置选择(最多保存10组)")
        frame_config_select.pack(fill="x", padx=10, pady=5)

        ttk.Label(frame_config_select, text="选择配置:").grid(row=0, column=0, padx=5, pady=5)
        self.config_combobox = ttk.Combobox(frame_config_select, textvariable=self.current_config_idx,
                                            values=list(range(MAX_CONFIG_COUNT)), state="readonly")
        self.config_combobox.grid(row=0, column=1, padx=5, pady=5)
        self.config_combobox.bind("<<ComboboxSelected>>", self.load_current_config)

        ttk.Label(frame_config_select, text="配置名称:").grid(row=0, column=2, padx=5, pady=5)
        self.config_name_entry = ttk.Entry(frame_config_select)
        self.config_name_entry.grid(row=0, column=3, padx=5, pady=5)

        ttk.Button(frame_config_select, text="加载选中配置", command=self.load_current_config).grid(row=0, column=4,
                                                                                                    padx=5, pady=5)
        ttk.Button(frame_config_select, text="保存当前配置", command=self.save_current_config).grid(row=0, column=5,
                                                                                                    padx=5, pady=5)

# 2. 标签样式配置区域
        frame_label_style = ttk.LabelFrame(self.root, text="标签样式与分页配置")
        frame_label_style.pack(fill="x", padx=10, pady=5)

# 2.1 标签尺寸
        ttk.Label(frame_label_style, text="标签宽度(mm):").grid(row=0, column=0, padx=5, pady=5)
        self.label_width_entry = ttk.Entry(frame_label_style)
        self.label_width_entry.grid(row=0, column=1, padx=5, pady=5)

        ttk.Label(frame_label_style, text="标签高度(mm):").grid(row=0, column=2, padx=5, pady=5)
        self.label_height_entry = ttk.Entry(frame_label_style)
        self.label_height_entry.grid(row=0, column=3, padx=5, pady=5)

# 2.2 页面边距
        ttk.Label(frame_label_style, text="页面左右边距(mm):").grid(row=1, column=0, padx=5, pady=5)
        self.page_margin_x_entry = ttk.Entry(frame_label_style)
        self.page_margin_x_entry.grid(row=1, column=1, padx=5, pady=5)

        ttk.Label(frame_label_style, text="页面上下边距(mm):").grid(row=1, column=2, padx=5, pady=5)
        self.page_margin_y_entry = ttk.Entry(frame_label_style)
        self.page_margin_y_entry.grid(row=1, column=3, padx=5, pady=5)

# 2.3 分页标签数量(核心改进)
        ttk.Label(frame_label_style, text="每页每行标签数:").grid(row=2, column=0, padx=5, pady=5)
        self.labels_per_row_entry = ttk.Entry(frame_label_style)
        self.labels_per_row_entry.grid(row=2, column=1, padx=5, pady=5)

        ttk.Label(frame_label_style, text="每页每列标签数:").grid(row=2, column=2, padx=5, pady=5)
        self.labels_per_col_entry = ttk.Entry(frame_label_style)
        self.labels_per_col_entry.grid(row=2, column=3, padx=5, pady=5)

# 2.4 字体大小
        ttk.Label(frame_label_style, text="字体大小:").grid(row=3, column=0, padx=5, pady=5)
        self.font_size_entry = ttk.Entry(frame_label_style)
        self.font_size_entry.grid(row=3, column=1, padx=5, pady=5)

# 3. 数据与输出配置区域
        frame_data_output = ttk.LabelFrame(self.root, text="数据与输出配置")
        frame_data_output.pack(fill="x", padx=10, pady=5)

        ttk.Label(frame_data_output, text="数据表路径:").grid(row=0, column=0, padx=5, pady=5)
        self.data_path_entry = ttk.Entry(frame_data_output, width=50)
        self.data_path_entry.grid(row=0, column=1, padx=5, pady=5)
        ttk.Button(frame_data_output, text="选择文件", command=self.select_data_file).grid(row=0, column=2, padx=5,
                                                                                           pady=5)

        ttk.Label(frame_data_output, text="输出PDF路径:").grid(row=1, column=0, padx=5, pady=5)
        self.output_pdf_entry = ttk.Entry(frame_data_output, width=50)
        self.output_pdf_entry.grid(row=1, column=1, padx=5, pady=5)
        ttk.Button(frame_data_output, text="选择保存位置", command=self.select_output_pdf).grid(row=1, column=2, padx=5,
                                                                                                pady=5)

# 4. 生成按钮区域
        frame_generate = ttk.Frame(self.root)
        frame_generate.pack(fill="x", padx=10, pady=10)
        ttk.Button(frame_generate, text="批量生成标签PDF", command=self.generate_labels).pack()

# 5. 初始化加载默认配置
        self.load_current_config()

defselect_data_file(self):
        file_path = filedialog.askopenfilename(title="选择数据表",
                                               filetypes=[("Excel/CSV文件""*.xlsx *.csv"), ("所有文件""*.*")])
if file_path:
            self.data_path_entry.delete(0, tk.END)
            self.data_path_entry.insert(0, file_path)

defselect_output_pdf(self):
        file_path = filedialog.asksaveasfilename(title="保存PDF标签", defaultextension=".pdf",
                                                 filetypes=[("PDF文件""*.pdf"), ("所有文件""*.*")])
if file_path:
            self.output_pdf_entry.delete(0, tk.END)
            self.output_pdf_entry.insert(0, file_path)

defload_current_config(self, event=None):
        config_idx = self.current_config_idx.get()
        config = self.configs[config_idx]

# 填充界面输入框
        self.config_name_entry.delete(0, tk.END)
        self.config_name_entry.insert(0, config.get("config_name"""))

        self.label_width_entry.delete(0, tk.END)
        self.label_width_entry.insert(0, config.get("label_width"60))

        self.label_height_entry.delete(0, tk.END)
        self.label_height_entry.insert(0, config.get("label_height"30))

        self.page_margin_x_entry.delete(0, tk.END)
        self.page_margin_x_entry.insert(0, config.get("page_margin_x"10))

        self.page_margin_y_entry.delete(0, tk.END)
        self.page_margin_y_entry.insert(0, config.get("page_margin_y"10))

        self.labels_per_row_entry.delete(0, tk.END)
        self.labels_per_row_entry.insert(0, config.get("labels_per_row"3))

        self.labels_per_col_entry.delete(0, tk.END)
        self.labels_per_col_entry.insert(0, config.get("labels_per_col"8))

        self.font_size_entry.delete(0, tk.END)
        self.font_size_entry.insert(0, config.get("font_size"10))

        self.data_path_entry.delete(0, tk.END)
        self.data_path_entry.insert(0, config.get("data_path"""))

        self.output_pdf_entry.delete(0, tk.END)
        self.output_pdf_entry.insert(0, config.get("output_pdf""批量标签输出.pdf"))

defsave_current_config(self):
try:
# 收集界面输入数据
            new_config = {
"config_name": self.config_name_entry.get().strip(),
"label_width": float(self.label_width_entry.get().strip()),
"label_height": float(self.label_height_entry.get().strip()),
"page_margin_x": float(self.page_margin_x_entry.get().strip()),
"page_margin_y": float(self.page_margin_y_entry.get().strip()),
"labels_per_row": int(self.labels_per_row_entry.get().strip()),
"labels_per_col": int(self.labels_per_col_entry.get().strip()),
"font_size": int(self.font_size_entry.get().strip()),
"data_path": self.data_path_entry.get().strip(),
"output_pdf": self.output_pdf_entry.get().strip()
            }

# 验证配置名称
ifnot new_config["config_name"]:
                messagebox.showerror("错误""配置名称不能为空")
return

# 验证数值合法性
if new_config["label_width"] <= 0or new_config["label_height"] <= 0:
                messagebox.showerror("错误""标签尺寸必须大于0")
return

if new_config["labels_per_row"] <= 0or new_config["labels_per_col"] <= 0:
                messagebox.showerror("错误""每页标签数量必须大于0")
return

# 保存配置
            config_idx = self.current_config_idx.get()
if save_single_config(config_idx, new_config):
                self.configs = load_all_configs()  # 刷新本地配置
                messagebox.showinfo("成功""配置保存成功!")
else:
                messagebox.showerror("错误""配置保存失败,索引超出范围")
except ValueError:
            messagebox.showerror("错误""请输入合法的数值类型")
except Exception as e:
            messagebox.showerror("错误"f"保存失败:{str(e)}")

defgenerate_labels(self):
try:
# 先保存当前配置(避免用户未保存直接生成)
            self.save_current_config()

# 获取当前配置
            config_idx = self.current_config_idx.get()
            config = self.configs[config_idx]

# 生成标签PDF
            success, msg = generate_label_pdf(config)
if success:
                messagebox.showinfo("生成成功", msg)
else:
                messagebox.showerror("生成失败", msg)
except Exception as e:
            messagebox.showerror("错误"f"生成过程异常:{str(e)}")


# 程序入口
if __name__ == "__main__":
    root = tk.Tk()
    app = LabelGeneratorApp(root)
    root.mainloop()

后续必做步骤(安装依赖)

打开你的项目虚拟环境终端,执行以下命令安装 openpyxl

# 激活虚拟环境(如果未激活)
C:\Users\PC\PycharmProjects\PythonProject\.venv\Scripts\activate

# 安装 openpyxl
pip install openpyxl

验证是否修复成功

  1. 安装完成后,重新运行程序。
  2. 选择一个 .xlsx 或 .csv 数据表,填写配置并生成标签。
  3. 若能成功生成 PDF 且无报错,说明修复完成;生成的 PDF 可直接打开并打印。

总结

  1. 核心报错原因是 pandas 读取 .xlsx 缺少 openpyxl 依赖,且未指定读取引擎。
  2. 代码修复两点:增加 openpyxl 依赖检测、pd.read_excel() 明确指定 engine="openpyxl"
  3. 必须通过 pip install openpyxl 安装依赖,才能正常读取 Excel 文件。
  4. 修复后程序会给出友好的依赖缺失提示,方便后续排查问题。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 15:20:26 HTTP/2.0 GET : https://f.mffb.com.cn/a/473037.html
  2. 运行时间 : 0.199431s [ 吞吐率:5.01req/s ] 内存消耗:4,711.56kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f0eeb1e2cad92ca074db21e7aaac9368
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000844s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001537s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.053676s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.010109s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001574s ]
  6. SELECT * FROM `set` [ RunTime:0.003934s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001698s ]
  8. SELECT * FROM `article` WHERE `id` = 473037 LIMIT 1 [ RunTime:0.001314s ]
  9. UPDATE `article` SET `lasttime` = 1770448826 WHERE `id` = 473037 [ RunTime:0.014985s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.002458s ]
  11. SELECT * FROM `article` WHERE `id` < 473037 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.004177s ]
  12. SELECT * FROM `article` WHERE `id` > 473037 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001610s ]
  13. SELECT * FROM `article` WHERE `id` < 473037 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.009438s ]
  14. SELECT * FROM `article` WHERE `id` < 473037 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001977s ]
  15. SELECT * FROM `article` WHERE `id` < 473037 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.007799s ]
0.200954s