Apply multiple styles in a spreadhseet row while using axlsx in ruby on rails
up vote
0
down vote
favorite
I am using axlsx gem to generate spreadsheets in rails.
I have around 25 columns in a row and I would like to apply:
- bold font and blue background on column 1
- blue background (WITHOUT bold font) on all the remaining columns 2 to 25.
How can I achieve this without having to write the style 25 times?
This is the current code I am using:
color_style = [gray_col1_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style]
sheet.add_row [treasury_forecast.forecast_item, treasury_forecast.total, treasury_forecast.mtd, treasury_forecast.day1, treasury_forecast.day2, treasury_forecast.day3, treasury_forecast.day4, treasury_forecast.day5, treasury_forecast.day6, treasury_forecast.day7, treasury_forecast.day8, treasury_forecast.day9, treasury_forecast.day10, treasury_forecast.day11, treasury_forecast.day12, treasury_forecast.day13, treasury_forecast.day14, treasury_forecast.day15, treasury_forecast.day16, treasury_forecast.day17, treasury_forecast.day18, treasury_forecast.day19, treasury_forecast.day20, treasury_forecast.day21, treasury_forecast.day22, treasury_forecast.day23], :style => color_style
I have repeated gray_style for all columns except col1. Is there a way to apply a style to col1 and another style to all other columns without having to type the style name multiple times as I have done above?
ruby-on-rails spreadsheet axlsx
add a comment |
up vote
0
down vote
favorite
I am using axlsx gem to generate spreadsheets in rails.
I have around 25 columns in a row and I would like to apply:
- bold font and blue background on column 1
- blue background (WITHOUT bold font) on all the remaining columns 2 to 25.
How can I achieve this without having to write the style 25 times?
This is the current code I am using:
color_style = [gray_col1_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style]
sheet.add_row [treasury_forecast.forecast_item, treasury_forecast.total, treasury_forecast.mtd, treasury_forecast.day1, treasury_forecast.day2, treasury_forecast.day3, treasury_forecast.day4, treasury_forecast.day5, treasury_forecast.day6, treasury_forecast.day7, treasury_forecast.day8, treasury_forecast.day9, treasury_forecast.day10, treasury_forecast.day11, treasury_forecast.day12, treasury_forecast.day13, treasury_forecast.day14, treasury_forecast.day15, treasury_forecast.day16, treasury_forecast.day17, treasury_forecast.day18, treasury_forecast.day19, treasury_forecast.day20, treasury_forecast.day21, treasury_forecast.day22, treasury_forecast.day23], :style => color_style
I have repeated gray_style for all columns except col1. Is there a way to apply a style to col1 and another style to all other columns without having to type the style name multiple times as I have done above?
ruby-on-rails spreadsheet axlsx
1
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using axlsx gem to generate spreadsheets in rails.
I have around 25 columns in a row and I would like to apply:
- bold font and blue background on column 1
- blue background (WITHOUT bold font) on all the remaining columns 2 to 25.
How can I achieve this without having to write the style 25 times?
This is the current code I am using:
color_style = [gray_col1_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style]
sheet.add_row [treasury_forecast.forecast_item, treasury_forecast.total, treasury_forecast.mtd, treasury_forecast.day1, treasury_forecast.day2, treasury_forecast.day3, treasury_forecast.day4, treasury_forecast.day5, treasury_forecast.day6, treasury_forecast.day7, treasury_forecast.day8, treasury_forecast.day9, treasury_forecast.day10, treasury_forecast.day11, treasury_forecast.day12, treasury_forecast.day13, treasury_forecast.day14, treasury_forecast.day15, treasury_forecast.day16, treasury_forecast.day17, treasury_forecast.day18, treasury_forecast.day19, treasury_forecast.day20, treasury_forecast.day21, treasury_forecast.day22, treasury_forecast.day23], :style => color_style
I have repeated gray_style for all columns except col1. Is there a way to apply a style to col1 and another style to all other columns without having to type the style name multiple times as I have done above?
ruby-on-rails spreadsheet axlsx
I am using axlsx gem to generate spreadsheets in rails.
I have around 25 columns in a row and I would like to apply:
- bold font and blue background on column 1
- blue background (WITHOUT bold font) on all the remaining columns 2 to 25.
How can I achieve this without having to write the style 25 times?
This is the current code I am using:
color_style = [gray_col1_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style, gray_style]
sheet.add_row [treasury_forecast.forecast_item, treasury_forecast.total, treasury_forecast.mtd, treasury_forecast.day1, treasury_forecast.day2, treasury_forecast.day3, treasury_forecast.day4, treasury_forecast.day5, treasury_forecast.day6, treasury_forecast.day7, treasury_forecast.day8, treasury_forecast.day9, treasury_forecast.day10, treasury_forecast.day11, treasury_forecast.day12, treasury_forecast.day13, treasury_forecast.day14, treasury_forecast.day15, treasury_forecast.day16, treasury_forecast.day17, treasury_forecast.day18, treasury_forecast.day19, treasury_forecast.day20, treasury_forecast.day21, treasury_forecast.day22, treasury_forecast.day23], :style => color_style
I have repeated gray_style for all columns except col1. Is there a way to apply a style to col1 and another style to all other columns without having to type the style name multiple times as I have done above?
ruby-on-rails spreadsheet axlsx
ruby-on-rails spreadsheet axlsx
edited Nov 10 at 11:13
asked Nov 10 at 7:37
Biju
517
517
1
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14
add a comment |
1
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14
1
1
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236954%2fapply-multiple-styles-in-a-spreadhseet-row-while-using-axlsx-in-ruby-on-rails%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Hi and welcome to Stack Overflow! Your posted question does not appear to include an attempt to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour
– lucascaro
Nov 10 at 8:07
@lucascaro - I have added some code snippets to my question now. Hope it is okay now.
– Biju
Nov 10 at 11:14