Is there something like pywin32 in Julia?

Here is my example to use PyCall to open and modify an existing Excel-file via a COM server:

# Create COM server via Python Interface
# first: install "pywin32" via conda:
# using Conda; Conda.add("pywin32")

using PyCall
using XLSX
pw = pyimport("win32com")
pwc = pyimport("win32com.client")


FN_excel = raw"C:\tmp\MyTest.xlsx";
if ~isfile(FN_excel)
    XLSX.writetable(FN_excel)
end

xlApp = pwc.Dispatch("Excel.Application")
xlApp.Visible = 1
if isfile(FN_excel)
    workBook = xlApp.Workbooks.Open(FN_excel)
else
    error("file \"" * FN_excel * "\" does not exist!\n")
end
workBook.ActiveSheet.Cells(1, 1).Value = "hello world"
workBook.Close(SaveChanges = 1)
xlApp.Quit()

I hope it helps others to get started.

3 Likes