spreadsheet_architect icon indicating copy to clipboard operation
spreadsheet_architect copied to clipboard

Time cell in ODS file

Open mmagn opened this issue 7 years ago • 8 comments

Hi, first of all thank you for your work on Spreadsheet Architect, you make life easier for thousands of developers.

I am using the 2.0.2 version of the gem and I have an issue while trying to create a ODS file with a Time in a cell. Here is my code :

SpreadsheetArchitect.to_ods(data: [[Time.now]], header: false)

When i open with LibreOffice the produced file the cell value is 0 (displayed 30/12/1899) and the format is set to date.

Am I missing something ?

Thanks for your help

mmagn avatar Jan 29 '18 15:01 mmagn

What happens when you do this?

SpreadsheetArchitect.to_ods(data: [[Time.now]], header: false, column_types: [:time])

That may fix it in the meantime however its likely an issue with the rodf gem. Time cells may need some additional work and tests added.

westonganger avatar Jan 29 '18 16:01 westonganger

The cell displays 2018-01-29, the value is '2018-01-29. The cell seems to be formatted as Number (default format I suppose).

Thanks for you help, I will try to investigate rodf as soon as possible.

mmagn avatar Jan 29 '18 17:01 mmagn

I am the maintainer of rodf as well. I have been working on a solution this morning. I should have something for you to test soon.

westonganger avatar Jan 29 '18 18:01 westonganger

Related rodf issue: thiagoarrais/rodf#19

westonganger avatar Jan 29 '18 18:01 westonganger

Improvements have been made to the cell types on the develop branch of rodf.

Please try the following in your Gemfile to test the changes:

gem 'rodf', github: 'thiagoarrais/rodf', branch: :develop
gem 'spreadsheet_architect'

If you wouldnt mind testing all column types for any bugs: :string, :float, :date, :time, :currency, :percentage

westonganger avatar Jan 29 '18 18:01 westonganger

Thank you for your speed. I will test this soon and comment on the rodf related issue.

mmagn avatar Jan 30 '18 14:01 mmagn

Turns out date/time formatting is kind of complicated in ODS. Until the bug is dealt with in some way over in RODF, I am going to convert all :date / :time cells to :string using to_s as a sensible default

westonganger avatar Mar 09 '18 20:03 westonganger

As of v2.1.0 (Released today), All date or time cells in ODS spreadsheets will be converted to strings using to_s until the situation is properly fixed in RODF.

westonganger avatar Jun 20 '18 20:06 westonganger