xlwings is an open-source library created by Zoomer Analytics to manipulate Microsoft Excel with Python. In my opinion, xlwings is probably one of the best libraries out there to interact with Excel application beside win32com.
In this tutorial, I will cover xlwings Options and default Converters.
Converters are the sets of property that you can use to change the data type from the range object. Options method is the underlying method from the range object, and within the options method, you will provide the converter value to convert the data from the range method.
Hello Jie Jenn!
I posted on your youtube channel and I love your content. Thanks for creating something that people who are discovering python for excel can learn from.
I had a problem following along your 4th lesson for xlwings. when i try to replicate what you had for the numpy array example, i got a couple of errors. i posted the snippet of the code below with the errors commented to the side. Do you have any idea what could be causing this?
import xlwings as xw
import numpy as np
import pandas as pd
#https://docs.xlwings.org/en/stable/datastructures.html
wb = xw.Book()
# Dict (can only read a 2X2 table)
wsDict = wb.sheets[‘Dict’]
wsDict.range(“A1:B2”).value
wsDict.range(“A1:B2”).options(dict, transpose = True).value
wsDict.range(“B5:C6”).options(dict, transpose = True).value
wsDict.range(“B10:C12”).options(dict, transpose = True).value # throws assertionerror because is a 2X3 table
# Numpy array converter
wsNumpy = wb.sheets[‘numpy’]
array1 = np.array([10, 20, 30])
wsNumpy.range(‘A1’).value = array1 ###### When I run this portion of the code, it only populates “A1” and not “B1” or “C1”
wsNumpy.range(“A1”).options(np.array).value #### When I run this portion of the code, it errors with “built_in_converters module doesn’t have the attribute ‘reader'”
Hey Lee,
I just checked your code and it seems incomplete. Would it be possible to send me your Python script to YouTube@LearnDataAnalysis.org and I can take a look at it.