From python numpy array or list to COM SAFEARRAY

535 views Asked by At

Is there any built in method or any other way to translate a python numpy array/list to COM SAFEARRAY?

There is a similar method in R: R Matrix to COMSAFEARRAY

Quite weirdly I have not found anything in python.

I want to use it in order to pass an array into a VBA function which I call from python.

Thank you

1

There are 1 answers

3
Felix Zumstein On BEST ANSWER

xlwings takes care of this:

import xlwings as xw
import numpy as np

book = xw.Book()
book.sheets[0]['A1'].value = np.array([[1, 2], [3, 4]])