Since this thread is closed I’m creating a new one.
In my extension I currently create spreadsheets using WinOLE.
There are several reasons I’d like to find an alternative.
Excel needs to be installed for this to work.
It only works on windows.
It is slow because Excel needs to be started.
In c# I use ClosedXML which is realy fast, but only works on windows.
I’ve done some searching but it seems most of the methods use gems, and installing gems in SketchUp is not something I want to deal with (unless someone can show a fool proof way of delivering them with an extension).
All of these require installing gems.
Does anyone know of a way to do this in SketchUp Ruby?
The only C# I’ve ever done is WPF which is windows only, and a bit of UWP in Windows IoT for my Raspberry pi. I’ve know that C# was more available cross platform the last while by don’t have any experience with it. Would it be possible to create a cross platform C# library that could be called from Ruby? I did a little searching but wasn’t able to find any 1,2,3 tutorials. I’m looking at write_xlsx right now.
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.
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 String#unpack back then (and in some older SketchUp releases.)
Even Ruby 2.2.4 only had String#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 String#unpack1, … it calls the old String#unpack:
def read_zip_short(io) # :nodoc:
io.read(2).unpack('v')[0]
end
Right I tested this in 2018, although I’d like to maintain compatibility back to 2016.
Here:
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.