Currently I am able to apply custom background color for odd number rows. My code to do is
$("tr.jqgrow:odd").css("background", "#FCF9E6");
on loadComplete, i am executing this code. By default on mouse over and on select of a row, I am getting background color as yellow only for even numbered rows not for odd numbered rows. How to apply custom background color along with mouse over & row selection background color functionality?
Can anyone help me?
It seems to me that you will find the answer on your question here with the corresponding demo.
Related
As the title says, I would like to create a dropdown with no text only color options to fill the cell. I'd like to give only a few specific options to the user, for convenience and simplicity.
It would also facilitate my VBA coding because I'm using cells().Interior.ColorIndex to identify the color and do certain tasks depending on the color chosen. So, I suppose I'm restricted by the 56 colors in the index color pallet of Excel.
Is this possible?
Well, I didn't accomplish what I wanted 100% but with the help of Stackoverflow developers I got to a pretty cool result which works perfectly for what I wanted and it could probably be useful for someone else.
So what I did was a drop down menu with the colour names and a Conditiontal Formatting which converts the text and fill of the cell to the specific colour. I downsized the font size to 1, so I can use them as small rectangles.
I'm using Microsoft Excel 2016 to construct a forecast model with a range of outputs. I have used Excel's built-in Conditional Formatting setting (Graded Color Scale, to be precise) to make the outputs visually informative, setting a green gradient scale to distinguish between low-valued outputs and high-valued outputs.
The minimum-valued cell background is set to 'Green, Accent 6, Lighter 80%' and the maximum-valued cell background is set to 'Green, Accent 6'. This has worked well. The cell values near the maximum, however, can sometimes be difficult to read, since they are 'Black, Text 1' (not a great contrast with the darker Green).
I am hoping to add the same type of conditional formatting to the cell texts in the range of outputs to generate a color contrast: for example, in the lighter end of the gradient, the cell texts will be 'Black, Text', and in the darker end of the gradient, the cells texts will be 'White, Background.' Visually, that would solve my contrast issue.
Unfortunately, after reading through this forum and searching for conditional formatting guides on Google, I haven't found a solution on how to apply the two types of formatting (background and font) to the same range of cells. I am not practiced in VBA, so I am hoping for any pointer that involves Excel's native functionality, if that's possible.
To boil all this down into a one-liner: "How do I add gradient conditional formatting to both font and background to a range of cells?"
Thank you for the help!
I have done this in the past by creating a number of rules that give the appearance of a gradient on both. To do this however you would create as many rules you need to get the resolution you want. For example:
Suppose you want to assign font and background fill for each value in increments of 10% from 0 to 100%.
For this you need to get 10 font colors in rgb format that gradually shift in the gradient that you want here is a site that can help:
http://www.colorizer.org/
Then do the same with for you background colors.
Now pair a font and background color with the range that you want that rule to apply to and write the excel rule.
While this method is a pain to set up it avoids vba at all costs and if you use the sheet as a template for other sheets you won't have to mess with it much.
Creating your own sets of custom rules as per #rahicks answer in the most comprehensive way of doing this. If you have a fairly stable range of values, then a quick and dirty solution is to use Custom Number Formats.
On top of your current conditional formatting, apply a Custom Number Format using a condition. This example sets the colour to white if the value is greater than 50, and then uses the existing colour otherwise.
[White][>50]General;General
You'll need to replace 50 with the mid-point of your data range and you'll also need to replace both instances of General with whatever number format you currently have on the range.
Requirement: I want to read an excel sheet and perform some action on the cells that are highlighted in the sheet i.e the cells which have their background colour as yellow.
I went through all the other similar posts but could not get the required information.
I tried using getFillBackgroundColor() which returns me value 64 each time for every colour. I tried using getFillBackgroundColorColor() which returns a colour object but I could not find a way to resolve it to the color name.
Please If anyone can help me with this
Take a look at the samples at http://poi.apache.org/spreadsheet/quick-guide.html#FillsAndFrills, you might need to use getFillForegroundColor()
Fills feel a bit unnatural to me, but it is just the nature of the beast. The fill itself is the cell background, but the fill itself has a foreground and background. So our typical two layer view of the world (foreground/background) doesn't work. In Excel we have three layers: Text color, Fill Foreground color, and Fill Background color. The Solid Fill happens to use the Fill Foreground color rather than the Fill Background color. Only two color fills have a Fill Background Color.
So if you have a solid "background", that means you have a solid fill which means you need to use getFillForegroundColor().
I want to highlight/fill a specific cell with color in a table generated using jsPDF, which is output to PDF.
Open this JSFiddle. As a base case, it draws a single table cell and sets both the fill colour and text colour to black. Uncomment line 12 and run it, which causes a PDF containing a single table cell to be saved to your download location. Open it and look - the text colour is black, but the cell fill colour is white.
The important line is line 6 - no matter which RGB values I feed in, the cell colour doesn't change.
doc.setFillColor(0,0,0);
How do I set a cell's fill colour? I've had a look through jspdf.plugin.cell.js, and there isn't anything overriding the fill colour. setFillColor is used in the function jsPDFAPI.printHeaderRow, which I followed as an example for my code.
Has anyone encountered this before?
Please let me know if I can provide any more details or explanation.
I haven't debugged it fully, but it works if I set doc.printingHeaderRow to true - http://jsfiddle.net/sp5qr4fd/4/
doc.printingHeaderRow = true;
I'm using Excel 2010.
Does anyone have a quicker way of implementing this?:
I have a table, with 2 columns; all I want is a green arrow (upwards) or red arrow (downwards) if the value on the right is bigger/smaller than the value on the left.
Unfortunately I can only get condition formatting to work on each individual cell (so when I have 15+ rows, in theory I would have to create 15 'rules'. Is there a quicker way of creating some sort of series that can be easily replicated?
Thank you!
You can use a helper cell to with something like =IF(A1>B1,1,0) and then apply the conditional formatting for the arrows for the whole table. You might need to adjust when what arrow shows up but when I threw it in a sample sheet it worked by default. You can set it to show the icon only too.