Julia using openpyxl to change column width & row height

Hi all,

I am using Julia 1.5.0 with openpyxl and I want to change the column width in an excel worksheet.

The python way to this is depicted here:

However in Julia when I use openpyxl and try to do the same it does not work, because ws.column_dimensions is an empty dictionary

using Conda
Conda.add("openpyxl")
using PyCall
xl = pyimport("openpyxl")

# create a workbook
wb = xl.Workbook()

# select active worksheet
ws = wb.active

# try to change the width of the column A --> NOT working
ws.column_dimensions["A"].width = 25

The same problem exists if I try to change the height of the first row using

ws.row_dimensions[1].height = 30 

Any hints?
Thanks

1 Like

Hi have you fixed it?

Unfortunately no (last attempt with Julia 1.5.2)

Hey :slight_smile: I had the same problem and I managed to solve it this way (for an existing .xlsx file):

from openpyxl.reader.excel import load_workbook
wb = load_workbook('output.xlsx')
sheet_ranges = wb['sheet1']
sheet_ranges.column_dimensions["A"].width = 40
wb.save('output.xlsx')

I hope it helps :slight_smile:

1 Like

@raph this is python, not julia… or am I missing something?