Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for format_code or num_fmt #8

Closed
westonganger opened this issue May 4, 2016 · 7 comments

Comments

Projects
None yet
2 participants
@westonganger
Copy link
Contributor

commented May 4, 2016

I was having no success getting a format_code or num_fmt so that I can get number and currency formats. Is this supported or do you know how we can add it?

This is my code:

sheet.add_style "B2:E5", format_code: "$#,##0.00"
@sakovias

This comment has been minimized.

Copy link
Collaborator

commented May 4, 2016

Please make sure this is something axlsx can handle. If it doesn't, this gem won't either.

How do you open your Excel files? I've noticed that apps like LibreOffice may have problems supporting everything MS Excel supports.

@westonganger

This comment has been minimized.

Copy link
Contributor Author

commented May 4, 2016

I have successfully been using this in my gem SpreadsheetArchitect. It works like this.

sheet.add_row row_data, style: package.workbook.styles.add_style({b: true, format_code: "$#,##0.00"}), types: options[:types]

However I only know how to apply it to the whole row except for string cells.

Yes, I have been using LibreOffice. But like I say the above works for the formatting for the whole row.

@sakovias

This comment has been minimized.

Copy link
Collaborator

commented May 5, 2016

Hmm, I can't reproduce... I need the whole piece of code to see where you problem is.

sheet.add_row ['A1', 'B1', 'C1']
sheet.add_row ['A2', 10002.23, 873984723]
sheet.add_row ['A3', 328982.26, 373570240.82]
sheet.add_row ['A4', 87234972, 980824.1]
sheet.add_style 'B2:C4', format_code: "$#,##0.00"

num-fmt

@westonganger

This comment has been minimized.

Copy link
Contributor Author

commented May 5, 2016

Is that in LibreOffice or Excel?

@sakovias

This comment has been minimized.

Copy link
Collaborator

commented May 5, 2016

That's in LibreOffice.

@sakovias sakovias self-assigned this May 5, 2016

@sakovias sakovias closed this May 7, 2016

@westonganger

This comment has been minimized.

Copy link
Contributor Author

commented Jun 18, 2016

The problem here was that I was not calling the method workbook.apply_styles.

@sakovias

This comment has been minimized.

Copy link
Collaborator

commented Jun 18, 2016

Agreed, some more emphasis should be put on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.