Bumblebee - Autofit excel columns

Hey,

I’ve been using the awesome Bumblebee package to create a better excel output. Our designers want a one second exporter that takes into account blank lines and ideally some formatting.

I’ve hit a roadblock however: I would like to autofit the columns of the created excel.

My knowledge of python is limited but it seems like Bumblebee is using the Microsoft.Office.Interop classes. I found there’s a function worksheet.Columns.AutoFit(); that one can call to autofit columns but I have no idea how to fit that into the graph. Would you recommand making a new python node for this or should I try to slip it into the Bumblebee node?

Any hints on how to get this project started would be very appreciated.

I have no prior Python experience but have scripted in PHP so I understand basic programming logic. This seems like a fun project to start out with.

A I_Export Schedule.dyn (56.3 KB)

Nobody?

Hey pieter,

That would be very useful as I have come across this as well. My workaround was to use a template excel file with columns sized appropriately to accommodate whatever type of data they take (eg number columns would be smaller than name columns) i then lock the formatting so it doesn’t get overwritten. It’s not perfect but it does maintain a consistency in look across spreadsheets.

Completely agree with Alexis, this has been our go-to solution.

Pieter - I would guess there’s a slight risk with using AutoFit - the problem is that it’s not exactly an intelligent function. For example. if your user inputs 500 characters which is then placed into a cell, you could find that entire column gets stretched massively to accommodate. While this might be what you want, it’s also possible you’d want to use line-breaks or text wrapping to fit the 500 characters into a more sensibly-sized column.

Also, shuffling around your column sizes using an AutoFit approach would mean that if you’re using a template (which needs to fit nicely on an A4-sized report format, for the sake of argument) then you’ll constantly be outputting information which will vary in width, i.e. its format will be impossible to standardise. Perhaps this isn’t important for your needs, but it is for ours!

Thanks for your input!

I can see it wouldn’t be an elegant solution in a lot of contexts. I’ll just advice our users on a fast way to do that in excel.