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

Docker Ubuntu环境下无法执行LibreOffice宏的问题求助

Docker Ubuntu环境下无法执行LibreOffice宏的问题求助

我现在碰到一个棘手的问题:我用Docker基于Ubuntu 22.04构建了一个镜像,目的是用它来执行LibreOffice宏处理XLSX文件。这套流程在Windows上能正常跑起来,但到了Docker环境里就完全卡住,shell停在那儿没任何反应。

先贴一下我的Dockerfile内容:

from ubuntu:22.04

run apt-get update \
&& apt-get -y install --no-install-recommends \
default-jre \
libreoffice-calc libreoffice-java-common \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

run libreoffice --headless --terminate_after_init

之后我执行了以下操作来给XLSX文件应用宏:
首先复制宏文件到指定目录:

cp ./Module1.xba ~/.config/libreoffice/4/user/basic/Standard/

然后执行LibreOffice命令:

soffice --nolockcheck --nologo --headless --norestore --language=ja --nofirststartwizard ./docs/test.xlsx "macro:///Standard.Module1.Main?language=Basic&location=application"

我的宏文件Module1.xba内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
*   Licensed to the Apache Software Foundation (ASF) under one or more
*   contributor license agreements. See the NOTICE file distributed
*   with this work for additional information regarding copyright
*   ownership. The ASF licenses this file to you under the Apache
*   License, Version 2.0 (the "License"); you may not use this file
*   except in compliance with the License. You may obtain a copy of
*   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM  *****  BASIC  *****

Sub Main

ThisComponent.calculateAll()
ThisComponent.store()
ThisComponent.close(True)
StarDesktop.terminate()

End Sub
</script:module>

请问各位,我是不是需要安装额外的依赖包,或者调整什么配置才能让宏在Docker环境里正常运行呢?

备注:内容来源于stack exchange,提问作者Issei Morita

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 10:07:36