profile
viewpoint
Stefan Daschek noniq @die-antwort Vienna, Austria https://noniq.at Hacking all the things!

noniq/meta-noop 14

Because a single implementation of noop() won't do.

noniq/Merge-Markers.tmbundle 6

TextMate bundle for highlighting merge conflict markers

noniq/flipdotwars 5

Star Wars on flipdots!

noniq/pocket-to-pinboard 5

Add items from your (password protected) pocket RSS feed to your pinboard account.

noniq/lichtspiel 4

Software for the “Lichtspiel”

noniq/RuboCop.tmbundle 4

TextMate bundle for the RuboCop Ruby Linter

die-antwort/cologne_phonetics 2

Cologne phonetics algorithm in Ruby.

noniq/arduino-rotary-phone 2

Firmware for my “Put an Arduino into an old Rotary Dial Phone” project

startedpalkan/n_plus_one_control

started time in 4 days

issue closedcaxlsx/caxlsx

Restructure examples folder

There are a lot of snippets in the examples/example.rb (in a hardly readable format). Some of the examples are in separate files (I guess it was easier to create a new file than follow the pattern in the examples.rb). The comments around the snippets not always tell you what it really does, etc. We need to clean up these files to be more helpful.

There are ongoig threads about this topic:

  • #32 Pointing out that some of the files are a bit outdated
  • #41 Solving the previouos issue with some suggestions
  • https://github.com/caxlsx/caxlsx/pull/34#issuecomment-567679024 Describing how we usually want to use the examples during gem development

Based on the above we want to achieve these goals:

  • [ ] Unified code samples (easy to understand and spot the difference when they look the same)
  • [ ] Descriptive examples (descriptions and / or images how the output looks like)
  • [ ] Discoverable examples (categories or easily searchable lists)
  • [ ] Separate files (hard to find anything useful in the big example.rb)
  • [ ] Runnable examples (for manual testing)

closed time in 9 days

kiskoza

issue commentcaxlsx/caxlsx

Restructure examples folder

FIxed by #47.

kiskoza

comment created time in 9 days

pull request commentcaxlsx/caxlsx

Restructure examples folder

I think this is a vast improvement for caxlx’s documentation, so thanks again @kiskoza for your amazing work!

I wonder if we should somehow integrate this into the test suite and/or ci checks? Like designating the current example documents as “known good” state, and having each test run regenerate and compare the documents to make sure there are no inadvertent changes?

kiskoza

comment created time in 9 days

push eventcaxlsx/caxlsx

Zsolt Kozaroczy

commit sha 282eec44ef01746ee25931fa6cd287ad083fd40b

Restructure examples folder (#47) Split examples into separate markdown files, each containing a description, sample code, and a screenshot of the resulting xlsx document. The script `generate.rb` is provided to actually generate the example documents by executing the sample code contained in the markdown files.

view details

push time in 9 days

PR merged caxlsx/caxlsx

Restructure examples folder

This is my next idea to how to solve #46 : Bring the content of the wiki to the examples folder.

  • [x] Unified code samples: Easy to check if new files has a short, informative code snippet
  • [x] Descriptive examples: Easy to check if new files has description and image about the output
  • [x] Discoverable examples: In examples/README.md we could sort the examples by categories, etc
  • [x] Separate files: All examples will be in a separate file
  • [x] Runnable examples: I added a example_runner.rb* that can extract the snippets from the markdown files and run all of them, or specific ones

* I used this name because we already have an example.rb that I didn't want to delete right now, but we could reuse that name if we decide to migrate all examples to this format

+2082 -1875

6 comments

168 changed files

kiskoza

pr closed time in 9 days

issue commenttextmate/GitHub-Markdown.tmbundle

Avoid code symbols showing up in "Jump to Symbols" HuD

Unfortunately I don't have time to investigate this myself, but if someone comes up with a fix I'd be more than happy to merge it.

diethardsteiner

comment created time in 9 days

issue commenttextmate/GitHub-Markdown.tmbundle

Some of the C syntax isn't picked up within code fences

Unfortunately I don't have time to investigate this myself, but if someone comes up with a fix I'd be more than happy to merge it.

KevinSjoberg

comment created time in 9 days

push eventJugendhackt/hackerethik-quiz-linz-2019

Stefan

commit sha f64ed55ef2af4dfe19f0c4ddaac327cebeeeb266

Update Readme

view details

push time in 19 days

create barnchJugendhackt/hackerethik-quiz-linz-2019

branch : jh-at-2020

created branch time in 19 days

issue commentcaxlsx/caxlsx

Ask Github to change caxlsx (and other forked caxlsx gems) to a normal repo

Good question, hm.

I don't have any experience with these things: Are there any other areas where forked and “normal” repos behave differently? Would it be possible to convert the repo back to a fork, if this should ever be necessary?

straydogstudio

comment created time in 25 days

Pull request review commentcaxlsx/caxlsx

Deprecate using `#serialize` with boolean argument

 def assert_zip_file_matches_package(fname, package)     package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }   end +  def test_serialization_with_deprecated_argument+    warnings = capture_warnings do+      @package.serialize(@fname, false)+    end+    assert_equal 1, warnings.size+    assert_includes warnings.first, "confirm_valid as a boolean is deprecated"+  end+

Please add an additional test case for serialize(@fname, true, zip: "zip") as mentioned above.

rylwin

comment created time in 25 days

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Deprecate using `#serialize` with boolean argument

 def workbook=(workbook) DataTypeValidator.validate :Package_workbook, Workbook,     #   # Serialize to a stream     #   s = p.to_stream()     #   File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }-    def serialize(output, confirm_valid=false, zip_command: nil)+    def serialize(output, options = {})

I think this fails if someone calls the method like this: serialize("foo.xlsx", true, zip: "zip"). Eventhough I suspect this case is highly unlikely, it should nevertheless be handled correctly to make this change really backwards-compatible.

rylwin

comment created time in 25 days

PullRequestReviewEvent

issue commentrandym/axlsx

Low-order non-printable ASCII characters in worksheet name should be escaped

Does it make sense to retain such (escaped) characters in sheet names? In cells for example they are removed, see Cell#clean_value which calls Axlsx.sanitize which removes control characters.

khiav223577

comment created time in 25 days

issue commentcaxlsx/caxlsx

explosion for pie chart throwing error

There have been quite a few changes / fixes since the last release, so let's go for it!

(Having that said, maybe we should wait for #57 and include it also?)

jenn-t

comment created time in a month

pull request commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

@rylwin Would you like to become a member of this project? We’d love to have more people on board making high-quality contributions (like for example this PR)! 😃

rylwin

comment created time in a month

pull request commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

Merged! Thanks for bringing this up and implementing it!

rylwin

comment created time in a month

push eventcaxlsx/caxlsx

Ryan Winograd

commit sha 33a53474a90f1825ce20c66dab481fdcfa1106bf

Remove unnecessary rescue in tests Back in `1e5388ce`, a rescue block was added to `#test_serialization` to prevent the test from breaking on boxes where the file system is not writable. This extra protection doesn't seem necessary anymore, so we are removing the protection in favor of letting the test error in this case.

view details

Ryan Winograd

commit sha e7673f431813cde7aab2d032a4417d4ddeeb9342

Add option to `#serialize` with system zip command Add a `:zip_command` option to `Axlsx::Package#serialize` that allows the user to specify an alternate command to use to perform the zip operation on the XLSX file contents. The default zip operation is provided by RubyZip. On large documents users may experience faster zip times using a zip binary. Resolves #55

view details

Stefan Daschek

commit sha e7fe9f385e9e58c71744b60655e4ba6c620c448f

Merge pull request #56 from rylwin/add-zip-command-option Add option to `#serialize` with system zip command

view details

push time in a month

PR merged caxlsx/caxlsx

Add option to `#serialize` with system zip command

Add a :zip_command option to Axlsx::Package#serialize that allows the user to specify an alternate command to use to perform the zip operation on the XLSX file contents.

The default zip operation is provided by RubyZip. On large documents users may experience faster zip times using a zip binary.

Resolves #55

+118 -13

6 comments

5 changed files

rylwin

pr closed time in a month

issue closedcaxlsx/caxlsx

Improve zipping performance

We're starting to generate some pretty large Excel files with caxlsx and, as our files get larger, so do the resources consumed to generate the file. We're working on ways to decrease the time it takes to render Excel files, part of which is due to slowness in our own app (slow queries, etc) and part of which is due to generating the Excel file.

One area we've found for potentially decreasing the time it takes to generate the Excel file is by using the system zip tool instead of rubyzip. We've hacked together a solution that seems to work for us and yield some pretty great improvements.

We have a gist to demonstrate the performance of the "built-in" rubyzip that's currently used by caxlsx vs. the "system-zip" binary: https://gist.github.com/rylwin/013eaa9768e94b75572d34e1695ac472.

On my personal laptop, the benchmark yields:

$ ruby zip-perf.rb
                  user     system      total        real
built-in:     0.503427   0.258035   0.761462 (  0.597083)
system-zip:   0.169251   0.000000   0.202789 (  0.201150)

And on a Heroku instance:

$ ruby zip-perf.rb
                  user     system      total        real
built-in:     2.760000   2.176000   4.936000 (  4.260702)
system-zip:   0.424000   0.000000   0.452000 (  0.483958)

In both cases, the speed up is quite drastic.

If there's interest in incorporating the use of an alternate zip library, I'd be happy to work on a PR. A couple thoughts:

  • Shelling out to the system zip binary adds a dependency on zip, which may not always be there. Perhaps via config the user could select how they want to render the Excel file, or we could check for the presence of zip
  • I'm on a linux box (I would assume Mac would work fine, not sure about Windows, more exploration would be necessary)
  • I tried using an old gem I found called zipruby that provides libzip bindings, but it's last commit is ~7 years ago and when I load it, it conflicts with rubyzip, so while I'd prefer to use something like zipruby to avoid shelling out to zip, that would be a bigger lift, but perhaps worth it.

So that's where we are as of now. Curious to hear the community's thoughts and whether any of this is of interest.

P.S. Thanks for maintaining this great gem!

closed time in a month

rylwin

startedpiotrmurach/tty-prompt

started time in a month

pull request commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

I think that's a good idea, but let's do this in a separate PR.

We should then cut a release containing both changes, so that users will have to update their code only once.

rylwin

comment created time in a month

pull request commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

Ah, one more thing: Please add an entry to the Changelog, too.

rylwin

comment created time in a month

pull request commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

@rylwin Marvellous! We’re almost there: Please squash the existing commits into a single one, and add a second one that removes the rescue-parts from the other tests (see above). Then it's merge time! 🚀

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

 def test_serialization     assert_nothing_raised do       begin         @package.serialize(@fname)-        zf = Zip::File.open(@fname)-        @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }+        assert_zip_file_matches_package(@fname, @package)         File.delete(@fname)       rescue Errno::EACCES         puts "WARNING:: test_serialization requires write access."       end     end   end +  def test_serialization_with_zip_command+    assert_nothing_raised do+      begin+        @package.serialize(@fname, false, zip_command: "zip")+        assert_zip_file_matches_package(@fname, @package)+        File.delete(@fname)+      rescue Errno::EACCES+        puts "WARNING:: test_serialization requires write access."

Thanks a lot for researching this! I think we should delete these statements from the other tests, too. It's not directly in the scope of this PR, but let's include it here for the sake of simplicity. Make this a separate commit, the text from your comment above can be used more or less 1:1 as commit message, I think.

rylwin

comment created time in a month

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

 def validate     private      # Writes the package parts to a zip archive.-    # @param [Zip::OutputStream] zip-    # @return [Zip::OutputStream]+    # @param [Zip::OutputStream, ZipCommand] zip+    # @return [Zip::OutputStream, ZipCommand]

My bad, sorry! The syntax is indeed correct.

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

+# encoding: UTF-8+require 'open3'+require 'shellwords'++module Axlsx++  # The ZipCommand class supports zipping the Excel file contents using+  # a binary zip program instead of RubyZip's `Zip::OutputStream`.+  #+  # The methods provided here mimic `Zip::OutputStream` so that `ZipCommand` can+  # be used as a drop-in replacement. Note that method signatures are not+  # identical to `Zip::OutputStream`, they are only sufficiently close so that+  # `ZipCommand` and `Zip::OutputStream` can be interchangeably used within+  # `caxlsx`.+  class ZipCommand+    # Raised when the zip command exits with a non-zero status.+    class ZipError < StandardError; end++    def initialize(zip_command)+      @current_file = nil+      @files = []+      @zip_command = zip_command+    end++    # Create a temporary directory for writing files to.+    #+    # The directory and its contents are removed at the end of the block.+    def open(output, &block)+      Dir.mktmpdir do |dir|+        @dir = dir+        block.call(self)+        write_file+        zip_parts(output)+      end+    end++    # Closes the current entry and opens a new for writing.+    def put_next_entry(entry)+      write_file+      @current_file = "#{@dir}/#{entry.name}"+      @files << entry.name+      `mkdir -p $(dirname #{@current_file})`+    end++    # Write to a buffer that will be written to the current entry+    def write(content)+      @buffer << content+    end+    alias << write++    private++    def write_file+      if @current_file+        @buffer.rewind+        File.open(@current_file, "wb") { |f| f.write @buffer.read }+      end+      @current_file = nil+      @buffer = StringIO.new+    end++    def zip_parts(output)+      output = Shellwords.shellescape(File.absolute_path(output))+      inputs = Shellwords.shelljoin(@files)+      command = "cd #{@dir} && #{@zip_command} #{output} #{inputs}"+      stdout_and_stderr, status = Open3.capture2e(command)+      if !status.success?+        raise(ZipError.new(stdout_and_stderr))+      end+    end+  end+end

Altogether this is wonderfully written code 😍

rylwin

comment created time in a month

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

 def test_serialization     assert_nothing_raised do       begin         @package.serialize(@fname)-        zf = Zip::File.open(@fname)-        @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }+        assert_zip_file_matches_package(@fname, @package)         File.delete(@fname)       rescue Errno::EACCES         puts "WARNING:: test_serialization requires write access."       end     end   end +  def test_serialization_with_zip_command+    assert_nothing_raised do+      begin+        @package.serialize(@fname, false, zip_command: "zip")+        assert_zip_file_matches_package(@fname, @package)+        File.delete(@fname)+      rescue Errno::EACCES+        puts "WARNING:: test_serialization requires write access."

Is this necessary to make the test run on CI?

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

+# encoding: UTF-8+require 'open3'+require 'shellwords'++module Axlsx++  # The ZipCommand class supports zipping the Excel file contents using+  # a binary zip program instead of RubyZip's `Zip::OutputStream`.+  #+  # The methods provided here mimic `Zip::OutputStream` so that `ZipCommand` can+  # be used as a drop-in replacement. Note that method signatures are not+  # identical to `Zip::OutputStream`, they are only sufficiently close so that+  # `ZipCommand` and `Zip::OutputStream` can be interchangeably used within+  # `caxlsx`.+  class ZipCommand+    # Raised when the zip command exits with a non-zero status.+    class ZipError < StandardError; end++    def initialize(zip_command)+      @current_file = nil+      @files = []+      @zip_command = zip_command+    end++    # Create a temporary directory for writing files to.+    #+    # The directory and its contents are removed at the end of the block.+    def open(output, &block)+      Dir.mktmpdir do |dir|+        @dir = dir+        block.call(self)+        write_file+        zip_parts(output)+      end+    end++    # Closes the current entry and opens a new for writing.+    def put_next_entry(entry)+      write_file+      @current_file = "#{@dir}/#{entry.name}"+      @files << entry.name+      `mkdir -p $(dirname #{@current_file})`+    end++    # Write to a buffer that will be written to the current entry+    def write(content)+      @buffer << content+    end+    alias << write++    private++    def write_file+      if @current_file+        @buffer.rewind+        File.open(@current_file, "wb") { |f| f.write @buffer.read }+      end+      @current_file = nil+      @buffer = StringIO.new+    end++    def zip_parts(output)+      output = Shellwords.shellescape(File.absolute_path(output))+      inputs = Shellwords.shelljoin(@files)+      command = "cd #{@dir} && #{@zip_command} #{output} #{inputs}"

Do we need to shellescape @dir also?

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

+# encoding: UTF-8+require 'open3'+require 'shellwords'++module Axlsx++  # The ZipCommand class supports zipping the Excel file contents using+  # a binary zip program instead of RubyZip's `Zip::OutputStream`.+  #+  # The methods provided here mimic `Zip::OutputStream` so that `ZipCommand` can+  # be used as a drop-in replacement. Note that method signatures are not+  # identical to `Zip::OutputStream`, they are only sufficiently close so that+  # `ZipCommand` and `Zip::OutputStream` can be interchangeably used within+  # `caxlsx`.+  class ZipCommand+    # Raised when the zip command exits with a non-zero status.+    class ZipError < StandardError; end++    def initialize(zip_command)+      @current_file = nil+      @files = []+      @zip_command = zip_command+    end++    # Create a temporary directory for writing files to.+    #+    # The directory and its contents are removed at the end of the block.+    def open(output, &block)+      Dir.mktmpdir do |dir|+        @dir = dir+        block.call(self)+        write_file+        zip_parts(output)+      end+    end++    # Closes the current entry and opens a new for writing.+    def put_next_entry(entry)+      write_file+      @current_file = "#{@dir}/#{entry.name}"+      @files << entry.name+      `mkdir -p $(dirname #{@current_file})`

Why not use FileUtils.mkdir_p and File.dirname? (This would also solve any issues regarding escaping the filename.)

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

 def validate     private      # Writes the package parts to a zip archive.-    # @param [Zip::OutputStream] zip-    # @return [Zip::OutputStream]+    # @param [Zip::OutputStream, ZipCommand] zip+    # @return [Zip::OutputStream, ZipCommand]

Looks like leftovers from a different implementation?

rylwin

comment created time in a month

PullRequestReviewEvent

Pull request review commentcaxlsx/caxlsx

Add option to `#serialize` with system zip command

 def workbook=(workbook) DataTypeValidator.validate :Package_workbook, Workbook,     #   # ......add cool stuff to your workbook......     #   p.serialize("example.xlsx")     #+    #   # Serialize to a file, using a system zip binary+    #   p.serialize("example.xlsx", false, zip_command: "zip")+    #   p.serialize("example.xlsx", false, zip_command: "/path/to/zip")+    #   p.serialize("example.xlsx", false, zip_command: "zip -1")+    #     #   # Serialize to a stream     #   s = p.to_stream()     #   File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }-    def serialize(output, confirm_valid=false)+    def serialize(output, confirm_valid=false, zip_command: nil)

That’s perfect. (We should also change the confirm_valid argument to a keyword argument at some point, but this needs to go through a deprecation cycle first.)

rylwin

comment created time in a month

PullRequestReviewEvent

issue commentcaxlsx/caxlsx

Improve zipping performance

Then let's go for zip_command! 🚀

rylwin

comment created time in a month

issue commentcaxlsx/caxlsx

Improve zipping performance

👍

I’d say let’s keep this issue / PR focused on the external zip option for now.

Reconsidering the name and usage of the option: I just realized that we can probably always require a string – either the full path to a specific zip executable, or simply "zip" to use the first zip executable found in the search path. (I imagine we could simply pass the command name to #system and let the shell do all lookups and path handling.)

Here’s how it would look like for the case when just using "zip":

serialize(external_zip: "zip")
serialize(zip_provider: "zip")
serialize(zip_command: "zip")
serialize(zip_binary: "zip")
serialize(zip_executable: "zip")
serialize(zip: "zip")

I think I’d prefer zip_command: "zip", eventhough this somehow implies that arguments can also be specified. But why not? Maybe it would even make sense performancewise to use zip_command: "zip -1" (“compress faster”)? Or is this too confusing or hard to implement?

rylwin

comment created time in a month

issue commentcaxlsx/caxlsx

Improve zipping performance

Regarding #to_stream I think you already pointed out the problem that it could be surprising if (temporary) files are created when using this method. But I’m not sure: Maybe Rubyzip creates temporary files anyway? In this case (which probably should be documented) it wouldn’t be very much of a difference to use an external zip program. Would you like to investigate this further?

Or maybe we should add another way of serializing a package to better fit these use-cases. Maybe something like

package.serialize do |temporary_package_file|
  # do something with the file
end # temporary package file cleaned up automatically
rylwin

comment created time in a month

issue commentcaxlsx/caxlsx

Improve zipping performance

Good point about the problem with #to_stream supporting this option. Out of curiosity: Wouldn’t it be possible to implement your usecase like this (untested)?

Tempfile.open do |tempfile|
  package.serialize(tempfile.path, external_zip: true)
  send_data tempfile.rewind.read # or even `send_file tempfile.path`
end

I’m not against a config option per se, but I’m a bit hesitant because so far Axlsx has no configuration at all – not sure if it's worth introducing one for a single option only.

rylwin

comment created time in a month

push eventdie-antwort/dotfiles

Stefan Daschek

commit sha c0c3a1c28d2039db9f0b5bbab5faa53d25e5d734

Git: pull with rebase by default

view details

Stefan Daschek

commit sha bf33670d95f9300c94a12e2d435b15833b32b056

Git: recurse into submodules by default

view details

push time in a month

issue commentnextcloud/desktop

Latest Nextcloud Mac Client still does not synchronize files in subfolders

I also encounter this bug. (And forcing a sync by restarting the desktop client fixes also fixes it for me.)

One additional note: Some macOS files (“packages”) are actually folders under the hood (Pixelmator documents for example). These files are affected by this bug, too – which can be quite surprising at the first moment, because in Finder they look like normal files, and they have the green checkmark showing that they’ve been synced successfully. Only after using “Show package contents” in Finder (or looking at the file in the webinterface) one notices that the actual contents have not been synced.

DerHOgi

comment created time in a month

issue commentcaxlsx/caxlsx

Improve zipping performance

I think that's a great idea! Maybe this could be an option in Axlsx::Package#serialize? Here's a spontaneous idea:

package.serialize("test.xlsx", external_zip: true) # uses zip executable in path
package.serialize("test.xlsx", external_zip: "/my/special/zip") # uses specified executable

Thoughts?

rylwin

comment created time in a month

push eventdie-antwort/dotfiles

Stefan Daschek

commit sha bd557d000432800284c1be71472281e17004378d

Git: Add `pulls` as alias for `pull --recurse-submodules`

view details

push time in a month

push eventcaxlsx/caxlsx

Stefan Daschek

commit sha 40efd8444ee6b1b0509a5eb766d1dbf518b1dfe9

Update CHANGELOG.md

view details

push time in 2 months

delete branch caxlsx/caxlsx

delete branch : fix-incorrect-number-detection

delete time in 2 months

push eventcaxlsx/caxlsx

Stefan Daschek

commit sha b5092ea58f15e265f6a444cd5037d148a90d66a4

Fix type detection for floats with out-of-rage exponents (#54) Prior to this change, strings like "1e12345" would be interpreted as float values, regardless of the actual value of the exponent (which easily could be out of range for Ruby). In case the exponent was greater than `Float::MAX_10_EXP` (usually 308), this would result in a cell of type `:float` containing the literal string `"Infinity"`. Excel can not parse such cells and therefore gives a “corrupt data” error. In case the exponent was less than `Float::MIN_10_EXP` (usually -307) the cell would contain `0.0`. This does not result in Excel throwing an error, but probably isn't the expected result either. Note that this problem is quite likely to happen when creating a worksheet with hexadecimal strings, because e.g. "1234e567" is a perfectly valid hex value. The additional range check of the exponent introduces a slight performance overhead, so I decided to split the code path: I presume parsing floats with exponents < 100 (or no exponents at all) is way more common, so this code path behaves exactly like before. Only in the case of a 3 digit exponent the additional range check is introduced.

view details

push time in 2 months

PR merged caxlsx/caxlsx

Fix type detection for floats with out-of-rage exponents

Prior to this change, strings like "1e12345" would be interpreted as float values, regardless of the actual value of the exponent (which easily could be out of range for Ruby).

In case the exponent was greater than Float::MAX_10_EXP (usually 308), this would result in a cell of type :float containing the literal string "Infinity". Excel can not parse such cells and therefore gives a “corrupt data” error.

In case the exponent was less than Float::MIN_10_EXP (usually -307) the cell would contain 0.0. This does not result in Excel throwing an error, but probably isn't the expected result either.

Note that this problem is quite likely to happen when creating a worksheet with hexadecimal strings, because e.g. "1234e567" is a perfectly valid hex value.

The additional range check of the exponent introduces a slight performance overhead, so I decided to split the code path: I presume parsing floats with exponents < 100 (or no exponents at all) is way more common, so this code path behaves exactly like before. Only in the case of a 3 digit exponent the additional range check is introduced.

+11 -2

1 comment

3 changed files

noniq

pr closed time in 2 months

pull request commentcaxlsx/caxlsx

Fix type detection for floats with out-of-rage exponents

Here is a quick benchmark:

require "benchmark"
require "axlsx"

row = Axlsx::Workbook.new.add_worksheet.add_row
Benchmark.bm(11) do |x|
  x.report("no exp     "){ 1000000.times{ Axlsx::Cell.new(row, "123.23") } }
  x.report("valid exp  "){ 1000000.times{ Axlsx::Cell.new(row, "123.23e45") } }
  x.report("invalid exp"){ 1000000.times{ Axlsx::Cell.new(row, "123.23e456") } }
end

Before this change:

                  user     system      total        real
no exp        2.670989   0.015253   2.686242 (  2.713402)
valid exp     2.838740   0.014406   2.853146 (  2.871085)
invalid exp   2.743406   0.013243   2.756649 (  2.777175)

After this change:

                  user     system      total        real
no exp        2.587773   0.008056   2.595829 (  2.602749)
valid exp     2.744830   0.006783   2.751613 (  2.759950)
invalid exp   4.219549   0.013698   4.233247 (  4.248091)
noniq

comment created time in 2 months

PR opened caxlsx/caxlsx

Fix type detection for floats with out-of-rage exponents

Prior to this change, strings like "1e12345" would be interpreted as float values, regardless of the actual value of the exponent (which easily could be out of range for Ruby).

In case the exponent was greater than Float::MAX_10_EXP (usually 308), this would result in a cell of type :float containing the literal string "Infinity". Excel can not parse such cells and therefore gives a “corrupt data” error.

In case the exponent was less than Float::MIN_10_EXP (usually -307) the cell would contain 0.0. This does not result in Excel throwing an error, but probably isn't the expected result either.

Note that this problem is quite likely to happen when creating a worksheet with hexadecimal strings, because e.g. "1234e567" is a perfectly valid hex value.

The additional range check of the exponent introduces a slight performance overhead, so I decided to split the code path: I presume parsing floats with exponents < 100 (or no exponents at all) is way more common, so this code path behaves exactly like before. Only in the case of a 3 digit exponent the additional range check is introduced.

+11 -2

0 comment

3 changed files

pr created time in 2 months

create barnchcaxlsx/caxlsx

branch : fix-incorrect-number-detection

created branch time in 2 months

issue commentcaxlsx/caxlsx

Images don't work

I think there have been two or three small fixes since the last release, but they are already merged and mentioned in the Changelog (section “Unreleased”). Nothing else on my radar, currently. Let's do a release! 🚀

palmaste

comment created time in 2 months

issue commentcaxlsx/caxlsx

Images don't work

Maybe changing line 167 like this fixes the problem?

zip.write IO.read(part[:path], mode: "rb")
palmaste

comment created time in 2 months

push eventcaxlsx/caxlsx

Stefan Daschek

commit sha b13c999045411a97a9687a95a3055c809e9428f7

Update CHANGELOG.md

view details

push time in 2 months

pull request commentcaxlsx/caxlsx

Set column width to the maximum allowed value

Merged, thanks!

sponomarev

comment created time in 2 months

push eventcaxlsx/caxlsx

Sergey Ponomarev

commit sha 515177c03121b2ebb5920fd9b673d7da1ebe028d

Set column width to the maximum allowed value (#53) Maximum column width limit in MS Excel is 255 characters https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3 If this value is exceeded, MS Excel gets stuck and doesn't allow column resizing.

view details

push time in 2 months

PR merged caxlsx/caxlsx

Set column width to the maximum allowed value

Maximum column width limit in MS Excel is 255 characters https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3

If this value is exceeded, MS Excel gets stuck and doesn't allow column resizing.

Ported from https://github.com/randym/axlsx/pull/653

+24 -5

0 comment

2 changed files

sponomarev

pr closed time in 2 months

pull request commentrandym/axlsx

Set column width to the maximum allowed value

That looks great! This repo isn‘t actively maintained at the moment though, but I’d love to merge this into the community continued version at https://github.com/caxlsx/caxlsx – could you open a PR over there?

sponomarev

comment created time in 2 months

pull request commentcaxlsx/caxlsx

Fix typo in documentation for label_position

Thanks!

viktorpo

comment created time in 2 months

push eventcaxlsx/caxlsx

Viktor Polyakov

commit sha 6639f3cd5d1f64c2e947bd4f39a62d2d1d21bd7b

fix typo in documentation for label_position (#52)

view details

push time in 2 months

PR merged caxlsx/caxlsx

Fix typo in documentation for label_position
+1 -1

0 comment

1 changed file

viktorpo

pr closed time in 2 months

startedpichsenmeister/WienerScript

started time in 3 months

more