Cross-platform Generate xlsx Document

I’m getting hung up installing write_xlsx.

The write_xlsx/zip_file_util.srb has a require to some missing file.

require 'zip/zipfilesystem'

Yeah, that is a dependency that also has to be copied over.

1 Like

yes, I essentially do that in

Can you shed a little light on this? I copied the zip rb files from here:

I had to change the write_xlsx/zip_file_utils.rb from Zip::ZipFile to Zip::File

But now I’m still getting an error when closing the workbook. Do I have the wrong Zip library?

I had to use an older version of the zip library.


FYI, with regard to RubyZip.

I had repackaged it into a SketchupExtension archive.
I have them on my disk, but do not find that I’ve posted them here before. (Possibly at SketchUcation?)

Anyway, I RBZ packaged RubyZip versions 1.1.6 and 1.2.0, PM me if you would like one or both.

But generally we’ve discussed it in the past …

A little more on installing and catching errors for loading RubyZip here in …

Disclaimer: I don’t know much about gems as my only Ruby experience in in SketchUp.

I’m assuming that only one version of a gem can be installed at a time? Since the write_xlsx gem requires RubyZip 0.9.xx, wouldn’t I be better off taking the source code of both gems and repackaging it in my own namespace? That would avoid conflict with extensions that rely on other versions.

Yes, gems.

And I also just repacked them into an RBZ but did not purposefully put them into versioned submodules.

I did however package v1.2.0 into a CommuntiyLibraries namespace, so it would be separate from any toplevel installed gem.

This has been the norm when a particular version is required.

Probably why my experiments never gained any traction.

Although why it (write_xlsx) would require a specific older version is very strange.

The NoMethodError you show above may be due to the String#unpack1 method not being in Ruby 2.0.0. It only had Sting#unpack back then (and in some older SketchUp releases.)
Even Ruby 2.2.4 only had Sting#unpack.

So only SketchUp 2019 with Ruby 2.5.1 and higher will have the String#unpack1 method.

But what I find weird is that looking at RubyZip v1.2.0 code for "lib/zip/entry.rb" the read_zip_short() method does not call Sting#unpack1, … it calls the old Sting#unpack:

      def read_zip_short(io) # :nodoc:'v')[0]

Oh and the gemspec for write_xlsx has …

gem.add_runtime_dependency 'rubyzip', '>= 1.0.0'

Where did you see it needed to be exactly 0.9.xx ?

Ah, okay I looked at the newest version RubyZip v2.3.0 on GitHub and it’s read zip methods are now using String#unpack1.

So it isn’t an issue with RubyZip nor write_xlsx, it is SketchUp’s packaged Ruby versions coming with SU2018 and earlier.

Right I tested this in 2018, although I’d like to maintain compatibility back to 2016.


Apparently 1.0 changed Zip::ZipFileSystem to Zip::FileSystem, and Zip::ZipFile to Zip::File
I tried changing the source of write_xlsx, but when I ran into the unpack1 issue I simply downloaded an older version and it worked.

RubyZip requires Ruby >= 2.4.x which means SketchUp >= 2019.0 (Ruby 2.5.1)

RubyZip requires Ruby >= 1.9.2 which means SketchUp >= 2014.0 (Ruby 2.0.0)

All older RubyZip versions require Ruby >= 1.8.7 which does not support SketchUp <= 2013 (Ruby 1.8.6)

1 Like

Also … according to the write_xlsx change log …

2013-09-07 v0.72.2
work well with rubyzip 1.0.0

2013-09-06 v0.72.1
specify rubyzip version : <1.0.0

So …

Yes RubyZip 1.0.0 simplified both some namespaces and files names. (“zip/zip_file.rb” became “zip/file.rb”, etc.)

But if you use write_xlsx greater than or equal v0.72.2 it should not be making old RubyZip calls.

The current write_xlsx version is 0.85.7. What version did you attempt to use ?

1 Like

Hmm… I downloaded the current version, but if you look in the file you’ll see it is using the old names.

Oops I don’t use Github much and apparently I did have an old version (I just downloaded the master branch). Just discovered the releases page, and that has a newer version. Sorry for my ignorance.

1 Like

NO problem, you are now smarter than before! :wink:

Actually I’m looking at the latest and somehow he has the old namespaces etc.
He may have inserted a regression by pasting from an old version ?

ADD: Which also means his change log is erroneous as to RubyZip version support.

I suggest opening an issue, or perhaps forking, fixing and do a pull request.

Looks like it was intentional.

Oh I see now. He’s ALSO using …

… to try and use old code with newer RubyZip.

zip-zip provides a simple adapter to let all your dependencies use RubyZip v1.0.0. It is very simple and light weight, aliasing the old class names to the new.

1 Like

Now the light bulb is starting to turn on!