Comments (2)
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.
This has been resolved. Excel will pickup the formatting, but additional applyNumberFormat attribute was required for libraOffice.
from axlsx.
Related Issues (20)
- Some formulas do not work in Axlsx
- Title not set in LineChart.
- Mutiple thread error file HOT 2
- Conditionnal formating
- Upgrade Rubyzip 2 HOT 6
- outline_level_rows bag
- Stacked bar chart plotted as staircased HOT 3
- formula1 dont work on add_data_validation HOT 1
- Numbers as text HOT 1
- Low-order non-printable ASCII characters in worksheet name should be escaped or removed HOT 5
- Performance reduction with rails 5.2 HOT 2
- undefined method `downcase' when call the serialize method HOT 2
- rubyzip dependency is old
- Deployment not working (mimemagic (0.3.0) - version could not be found HOT 5
- dependent drop-down list
- Axlsx indent not working HOT 1
- DropDownList selected NAME get ID
- can't modify frozen String when run with --enable=frozen-string-literal flag HOT 1
- Stacked bar chart example not working HOT 1
- Error when opening xlsx file from OneDrive but not from other programs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axlsx.