Ruby + Excel. Autofit cell content

Pasha Kalashnikov
1 min readMar 8, 2020

author @no___tea

Just upgraded my Ruby gem xls-exporter https://github.com/kalashnikovisme/xls-exporter/

Now we have an opportunity to autofit cell content in Excel document. You should explore a Readme to find out how it works.

I want to share with you a couple of methods that implement autofit in Excel. I took some examples from Stackoverflow (SOP — StackOverFlow-oriented programming, my favourite methodology 😉 ). All methods in the Styler module. Link.

You can find autofit function in axlsx gem. My gem is based on the spreadsheet gem, which doesn’t have such function.

Why am I using spreadsheet gem?

I use xls-exporter gem in cases when I need to write Excel file to StringIO (or another) stream. You can’t do it with axlsx .

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (1)

Write a response

Looks nice, but XLS-format is almost dead. What about XLSX?