The Ruby Spreadsheet

October 20, 2011

Modifying an exiting Workbook with several Worksheets with the Ruby spreadsheet library

Filed under: Workbook, Worksheet — Tags: , , — zdavatz @ 6:22 am

This question has been asked many times on the mailing list:

I have an Excel file (workbook) with many worksheets in it. Now I modify one worksheet but leave the other worksheets untouched. When I write the file and then try to open it with OpenOffice or Microsoft Office the file hangs. What do I have to do?

1. You need to write the modified file to a new file name.

2. If the Workbook contains empty sheets, delete the empty sheets from the source file. There is no point in carrying empty sheets around.

3. If the Workbook contains 1 sheet that you want to modify but you want to leave the other worksheets untouched because they contain data, then read the following post from John Smith (very smart guy).

4. If you find a better solution, let me know via the list – and do not forget to post your sample code to github (please do not post it in the mail).



  1. Hi,

    Have you find any solution to read and write on a same excel file using ruby? If yes please let me know to



    Comment by RoRnetwork — April 12, 2013 @ 1:16 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: