Code Monkey home page Code Monkey logo

Comments (14)

westonganger avatar westonganger commented on May 18, 2024

I have been attempting to add support for types (:string or :number) which is successful and I think will be in the next release.

As for the date I have been having troubles getting axlsx to output anything except the integer representation of the Date or Time. In ODS I had date and time working mostly but we now run into issues with date formatting which could get pretty specific to xlsx or ods formats. If someone creates a pull request to add full support for dates & formatting for both ods & xlsx that would be great. But I don't want to add a half baked solution to this.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

The numeric cells should now be formatted correctly in v1.2.2

from spreadsheet_architect.

robbytobby avatar robbytobby commented on May 18, 2024

First of all, thanks for your fast response.

I just tested v1.2.2 and at least on my system (Linux with LibreOffice) numeric values are now allways text, even in an xls export.
This my be partly related to a german LibreOffice, where decimal seperator is ',' and floats are (of course) exported with a '.'
But integer values are now preceded with a hyphen even in xls and ods

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

I just released v1.2.3 which fixes the cell type logic. So the integers should be working correctly. I could possibly make a branch where you can test out manual cell types which you could use to test your german floats and dates if you want to play around with it.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

I created a branch that supports manual cell types. The supported types are:
:date, :time, :integer, :float, :string

Feel free to test this out and see if it fixes any of your problems and as a base point to create a pull request for this feature if you are so inclined.

from spreadsheet_architect.

robbytobby avatar robbytobby commented on May 18, 2024

Just tested the new versions

on branch manual_cell_types:

with format xls:

  • integer: works
  • float: works (no problems with german format)
  • string: works
  • date: does not work - resulting in integer representation

with format ods:

  • integer: does not work - empty cells
  • float: works (no problems with german format)
  • string: works
  • date: works (shows date_time)

on branch master

with format xls or ods

  • integer: does not work => preceded with " ' " e.g. '4
  • float: does not work => preceded with " ' " e.g. '1.2 ; even with english localization in LibreOffice
  • date: does not work => comes as string in english format e.g. 2015-12-30

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

For me on master using LibreoOffice on OSX with ods and xlsx I am not getting the ' on integers or floats numbers.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

Are you using the defining spreadsheet_columns method or just using default active record columns?

from spreadsheet_architect.

robbytobby avatar robbytobby commented on May 18, 2024

I'm using defined spreadsheet_columns, but all the numeric and date values are just database attributes.
But it just came to my mind, that actually my "floats" aren't floats but decimals. But that woud not explain the integer problem. Gonna try it with default active record columns tomorrow.

from spreadsheet_architect.

robbytobby avatar robbytobby commented on May 18, 2024

Sorry for the delay. I just did set up a new rails app (ruby-2.2.3, rails 4.2.6, sqlite, spreadsheet_architect-1.2.3) with just a standard scaffold for testing. Here's what I found:

Everything works well (in .ods and .xlsx, with german and english localization) for all numeric values (integer, float, decimal), as long as I'm not defining spreadsheet_columns. As soon as I define spreadsheet_columns, all numeric values are strings in the spreadsheets, preceded with a '.
With both methds dates come as strings in english format.

When using the branch manual_cell_types, the problem becomes even more interesting:
If I do not define spreadsheed_columns, ods-export is rather broken: Integers result in empty cells, floats and even dates are exported correctly. xlsx-export fails with:
Invalid Data: decimal. Cell.type must be one of [:date, :time, :float, :integer, :string, :boolean, :iso_8601].

If I define spreadsheet colums without setting the type explicitly, all numeric values are strings again, and date is again a string in english format (Integers are not empty) for ods and xlsx.
If I set the type for each value explicitly, xlsx-export works fine for all numeric values, but date switches to the integer representation. Ods-export delivers empty cells for integers, floats and decimals are handled correctly, even the date is a date.

That's my findings so far. Just tell me if you need more information.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

Can you include some samples of your spreadsheet_columns methods that you used for testing the various branches?

from spreadsheet_architect.

robbytobby avatar robbytobby commented on May 18, 2024
class Foo < ActiveRecord::Base
  include SpreadsheetArchitect

  def computed_float
    int_number.to_f / 100
  end

  #def spreadsheet_columns
  #  [:id, :int_number, :float_number, :decimal_number, :date, :name, :computed_float]
  #end

  #def spreadsheet_columns
  #  [
  #    ['Id', :id, :integer], 
  #    ['Int Number', :int_number, :integer], 
  #    ['Float Number', :float_number, :float],
  #    ['Decimal Number', :decimal_number, :float],
  #    ['Date', :date, :date],
  #    ['Name', :name, :string],
  #    ['Computed Float', :computed_float, :float]
  #  ]
  #end
end

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

I just released v1.2.4 which should fix the determination of cell type for symbol methods ex :computed_float. The manual cell types branch has been updated as well with the symbol method fix and should work correctly for ODS integers. Im not sure why XLSX failed because it shouldn't be setting the :decimal type automatically it should convert it to :float, see if it works with the new version. Thanks for all your help with testing by the way.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 18, 2024

v2.0.0 was just released which includes support for manual types.

from spreadsheet_architect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.