Giter VIP home page Giter VIP logo

Comments (2)

randym avatar randym commented on July 17, 2024

Hi Ochko

What you are seeing is a pre-formatted excel date. (Yes, indeed - excel does dates like that...)
You should also be sure to set workbook.date1904 = true if you are on generating dates on a Mac. The epoc is different between windows and mac platforms.

The first thing I would recommend is taking a look at this reference:
http://office.microsoft.com/en-us/excel-help/number-format-codes-HP005198679.aspx

Date formats in excel are a little bit different that you would expect coming from ruby/pgsql

Additionally, unless all of your datum are date values, applying that format code could adversely affect other values in your worksheet.

If you are looking to style just on column, there are a couple of options.
When adding a row you have two choices.
You can add a single style to all cells (which is what you have done)
Or you can pass in an array of styles like [nil, nil, date_style] which will set the third cell's style to the value provided.

Alternatively, and I find this useful as I can do it after I have build the entire sheet, you can:

date_style = workbook.styles.add_style(:format_code = 'yyyy-mm-dd hh:mm:ss')
sheet.col[n].each { |c| c.style = date_style }

Finally, there is a pre-build number constant for this type of formatting, so you can also do
:format_code = Axlsx::NUM_FMT_YYYYMMDDHHMMSS

Before I close this, I'd like to take a look at your sheet. Can you post the xlsx file here? (If there is private data in there lets exchange it via a different route)

from axlsx.

randym avatar randym commented on July 17, 2024

This has been resolved. Excel will pickup the formatting, but additional applyNumberFormat attribute was required for libraOffice.

from axlsx.

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.