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:



  1. bold font and blue background on column 1

  2. 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?










share|improve this question



















  • 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














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:



  1. bold font and blue background on column 1

  2. 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?










share|improve this question



















  • 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












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:



  1. bold font and blue background on column 1

  2. 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?










share|improve this question















I am using axlsx gem to generate spreadsheets in rails.



I have around 25 columns in a row and I would like to apply:



  1. bold font and blue background on column 1

  2. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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














































































Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党