gpt4 book ai didi

node.js - 如何在Windows Server上从Golang或Node.js运行Excel Application?

转载 作者:行者123 更新时间:2023-12-01 22:27:44 24 4
gpt4 key购买 nike

我在Window Server上使用Excel Application将Excel转换为PDF。我想知道是否可以通过Window Server上的GolangNodejs启动Excel Application。我看到一些通过RubyPythonC#运行Excel Application的示例。
例如:

  • Ruby:

  • require 'win32ole'

    class TestDemo < Test::Unit::TestCase
    def testExcelMacro
    # Arrange
    excel = WIN32OLE.new("Excel.Application")
    excel.Visible = true
    excel.Workbooks.Open('C:\temp\Test.xlsm')

    # Act
    excel.run "Sheet1!WriteToA1"

    # Assert
    worksheet = excel.Workbooks.ActiveWorkbook
    assert_equal("blah", worksheet.Range("A1").Value)

    excel.Quit
    end
    end
  • Python

  • from win32com import client
    xlApp = client.Dispatch("Excel.Application")
    books = xlApp.Workbooks.Open('C:\\excel\\trial.xls')
    ws = books.Worksheets[0]
    ws.Visible = 1
    ws.ExportAsFixedFormat(0, 'C:\\excel\\trial.pdf')

    最佳答案

    如果谈论node.js,则可以使用winax库或类似的东西与activex / com / dcom一起使用。但是我相信您可以只在Windows javascript解释器(而不是node.js)中使用它。

    关于node.js - 如何在Windows Server上从Golang或Node.js运行Excel Application?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58914185/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com