引言
我有一个带有GUI的坞容器,在其中我通过LibreOffice Calc注册了宏。使用docker容器提供的GUI,我可以通过命令行成功地运行宏。但是,当我在Kubernetes Pod中加载映像时,当我试图运行它时,宏将无限期地挂起。
以下是宏:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM ***** BASIC *****
Sub FitToPage
Dim document As Object, pageStyles As Object
document = ThisComponent
pageStyles = document.StyleFamilies.getByName("PageStyles")
For i = 0 To Document.Sheets.Count - 1
Dim sheet As Object, Style As Object
sheet = document.Sheets(i)
style = pageStyles.getByName(sheet.PageStyle)
style.ScaleToPagesX = 1
style.ScaleToPagesY = 999
Next
On Error Resume Next
document.storeSelf(Array())
document.close(true)
End Sub
</script:module>
命令来运行宏:
soffice --headless --nologo --nofirststartwizard --norestore macro://Standard.Module1.FitToPage <file>.xlsx
奇怪的是,我能够运行其他无头libreoffice命令。例如,如果我尝试将文件转换为pdf,而不使用soffice --headless --nologo --nofirststartwizard --norestore --convert-to pdf --outdir . <file>.xlsx
更改缩放,那么soffice运行得非常好。
其他资料:
~/.config/libreoffice/4/user/basic/Standard/Module1.xba
.
15Gi mem, 15 CPU
)
H 115
我还没有为集群H 216<代码>H 117
中的码头映像配置GUI,而是将资源转储到它中。
结论
任何帮助都将不胜感激。如有需要,我可以提供更多的资料。
更新
对我来说,在运行宏之前在后台运行soffice &
似乎是可行的。它可能与libreoffice如何处理其状态有关?
无论如何,这不是一个完美的解决方案,所以我将打开它,以防有人有更好的解决方案。
发布于 2022-06-06 16:55:35
宏的调用缺少一个斜杠/
。
命令行应该是
$ soffice --headless --nologo --nofirststartwizard --norestore macro:///Standard.Module1.FitToPage <file>.xlsx
在无头模式下运行会掩盖任何关于运行宏的安全消息,只要删除--headless
就可以检查是否有任何安全消息。
https://stackoverflow.com/questions/71244677
复制相似问题