You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

XLSX.jl中keep_empty_rows参数无法使用的问题咨询

XLSX.jl中keep_empty_rows参数报错问题

我尝试在XLSX.gettable或XLSX.readtable函数中使用参数keep_empty_rows=true,两种情况均报错:“got unsupported keyword argument "keep_empty_rows"”。该参数在XLSX.jl的API参考文档中有记录,但实际无法生效。相关代码如下:

for (i, fn) in enumerate(df.fname)
    xf = XLSX.readxlsx(joinpath(pilot_dir, fn))
    for sn in XLSX.sheetnames(xf)
        if (xf[sn]["C2"] == "Good Causes Summary - Catalogue Entry Form")
            println("Processing file ", fn)
            template = DataFrame(XLSX.gettable(xf[sn], "C:N", stop_in_empty_row=false, keep_empty_rows=true))
            push!(CSVrows, readtemplate(template))
        end
    end
end

请问我是否操作有误?


问题分析与解决

  • 核心原因是版本兼容:你查阅的稳定版API文档里的keep_empty_rows参数,是在XLSX.jl的较新版本中才新增的功能,而你本地安装的是旧版本,因此不支持该关键字参数。
  • 具体解决步骤:
    1. 打开Julia终端,按]进入包管理器模式,输入status XLSX查看当前安装的版本。
    2. 如果版本低于参数引入的版本(比如v0.8.0及以后版本才支持该参数,可通过项目更新日志确认),执行update XLSX将包升级到最新稳定版。
    3. 升级完成后重新运行代码,即可正常使用keep_empty_rows参数。
  • 额外说明:你的代码写法本身没有问题,gettable函数中stop_in_empty_row和keep_empty_rows都是合法的关键字参数,报错本质是旧版本包不支持该参数。

内容的提问来源于stack exchange,提问作者Tim Gebbels

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 23:07:41