0

我想使用 RDCOMClient 从 R 运行 Excel,它工作得很好,除了加载项,最重要的是“求解器”加载项,将不起作用。

有谁知道如何解决这个问题?

提前致谢!

EDIT:

为了防止出现真正的文字墙,这里有一些来自 VBA 和 R 代码的代码。请注意,VBA 代码要复杂得多,但它在 Excel 中运行良好。我可以像在这里一样通过 RDCOM 运行其他 makros。所以这就是为什么我猜这个问题是来自 Excel 的实际求解器插件。

VBA:

Sub solve()
    SolverReset
    SolverOptions precision:=0.001
    SolverOk SetCell:="$I$44", MaxMinVal:=3, ValueOf:=0#,...

        SolverAdd CellRef:="$E$43", Relation:=1, FormulaText:="$E$32"
        SolverAdd CellRef:="$F$43:$G$43", Relation:=3, ...
        SolverAdd CellRef:="$H$43", Relation:=1, FormulaText:="$H$32"

    SolverSolve userfinish:=True

endsub

回复:

xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("...xlsb")
xlSht <- xlApp$Sheets("sheet")

xlApp$Run("solve")
4

0 回答 0