How to set style on openpyxl? - phpexcel

I would to set style for a whole sheet in openpyxl.
I have this code:
ws_names= wb.get_sheet_names()
for wsname in ws_names :
ws= wb.get_sheet_by_name(wsname)
cr= ws.get_squared_range('A1)
for coli in xrange(1, 100) :
# issues, does not work
col = ws.column_dimensions[da.gcol(coli)]
col.font= Font(name='Arial', bold=False, size=8, italic=False, color="000000")
which does not work.
How can I set the style and none border for the whole sheet.
Thanks

This is covered in the documentation: you need to apply the styles to individual cells.

Related

Adjust c3 axis labels with css

I am using R's c3 package which is a wrapper for the C3 javascript charting library by Masayuki Tanaka.
My c3 chart below cuts off the last date on the x-axis.
Using Chrome Inspector I can manually adjust the text-anchor: middle to text-anchor: end
and that seems to work.
However, I do not understand how to do this with css.
Here's my R Script and related css though I don't think that R is relevant to the issue here.
R Script
library(shiny)
library(c3)
data <- data.frame(a = abs(rnorm(20) * 10),
b = abs(rnorm(20) * 10),
date = seq(as.Date("2014-01-01"), by = "month", length.out = 20))
ui <- fluidPage(
includeCSS("c3.css"),
c3Output("chart", height = "100%")
)
server <- function(input, output, session) {
output$chart <- renderC3({
data %>%
c3(x = 'date') %>%
tickAxis('x', count = 5, format = '%Y-%m-%d')
})
}
shinyApp(ui, server)
css
.c3-line {
stroke-width: 4px !important;
}
.c3-axis-x-label {
text-anchor: end;
}
You haven't pasted any actual code, but it's highly likely that the code below will help:
.c3-axis-x g.tick:nth-last-child(3) text {
transform:translateX(-5%);
}
You need to target the text correctly and adjust value to your needs.
Edit: Actually it's not :last-child - adjusted, based on some actual code. In essence you need to target your selector properly and apply the transform property.
Edit2: So it was actually the .c3-axis-x group that includes the tick texts. Code updated (yet again)
One thing that popps to my head immediately:
With your css you are only targeting the 'date' element.
You other 'text' element doesnt have a class, therefore the css for '.c3-axis-x-label' will only target the first text element.
Try adding 'c3-axis-x-label' class also to your other 'text' element.
Another thing:
The 'text' tag that you want to adjust has its styles written in the tag
When you set styles like this it will always override the applied CSS.
One solution i can think of, is to add !important in your CSS to override the style. I do not recommend using !important, but if its too difficult to actually change the css directly then this might be a solution.
If you can add a class to the other text element the try applying styles to 'text' in your css:
g > text {
text-anchor: end;
}
Let me know if any of that helped. Otherwise some code would come in handy to help you out

how to change color of background, row , row selection and header in angular 4 with bootstrap 4 data-table

I have implemented bootstrap 4 data table 4 in angular 4 but not able to change or modify row color. row selection color and header color as well.
I am using the data table 4 example : https://github.com/afermon/angular-4-data-table-bootstrap-4
and in this examples demo go through the demo 1 of link: https://afermon.github.io/angular-4-data-table-bootstrap-4-demo/
Considering the below code snippet present in data-table-component-demo1.ts got by the Git project you downloaded:
<data-table id="persons-grid"
[header] = "false"
[multiSelect] = "false"
[substituteRows]="false"
[indexColumn]="false"
[items]="items"
[itemCount]="itemCount"
(reload)="reloadItems($event)"
[pagination]="false"
(rowClick)="rowClick($event)"
[rowColors] = "callBackForChangineRowColors"
>
<data-table-column
[property]="'name'"
[header]="'Name'"
[sortable]="true"
[styleClass]="someExplicitClass"
In this, we can assign the value 'someExplicitClass' to [styleClass] as shown above and define the class someExplicitClass in our data-table-component-demo1.css file as below:
:host /deep/ .someExplicitClass{
background-color:red;
}
However, this is applied to the whole of the DataColumn and not controllable on a granular level.
We can indirectly apply only background-color using the rowEvent variable available within the rowClick(rowEvent) function of 'data-table-component-demo1.ts'
On click of the row, I will set the selected property of the row to true and thereby will trigger the onRowSelectChanged function of table.component.ts file
Now, once I set [rowColors] value to "callBackForChangineRowColors" as shown above and make the below changes in my data-table-component-demo1.component.ts file:
rowClick(rowEvent) {
console.log('Clicked: ' + rowEvent.row.item.name);
rowEvent.row.selected = true;
}
callBackForChangineRowColors(a,b,c)
{
if(b.selected)
return 'blue';
}
This way, I will be able to apply the color of blue explicitly for the selected Row.
*I could'nt unfortunately find any solution to apply any other styles on a granular level using a readily available input parameter like [styleClass] for it wasnt exposed as an #Input within our column.component.ts. If anyone has an idea, please do help me know it.

Change font color of a column in rhandsontable

I have a table rendered using rhandsontable in R. I want to change the font color to red of a specific column. How can I do it ? I tried the following code, but it does not work
output$hot=renderRHandsontable({
rhandontable (table)%>%
hot_col("colum1", color = "red")
})
If you want to change the style of elements inside of your table (in your case it is the font color of each cell of a given column), you will need to use a bit of Javascript and write a renderer function that will do the job, like so:
# Toy data frame
table <- data.frame(a = 1:10, b = letters[1:10])
# Custom renderer function
color_renderer <- "
function(instance, td) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.color = 'red';
}
"
rhandsontable(table) %>%
hot_col("b", renderer = color_renderer)
The function color_renderer() is saved as a string and will be used as the renderer argument of the hot_col()-function. Note the argument td I am using refers to the cell object of your table. td has several attributes, one is the style, which in turn has the attribute color.
Also make certain that you are using the correct Handsontable renderer. In my case, it is a TextRenderer but you may use different renderers based on the data type your column has.
For more information, refer to the Handsontable documentation.
I hope this helps.
Cheers

How to set min width on GtkScrollbar?

I want to develop new features in Quod Libet music player.
I need to increase size of specific scrollbar.
There's a function already exists to apply css to a widget:
def add_css(widget, css):
"""Add css for the widget, overriding the theme.
Can raise GLib.GError in case the css is invalid
"""
if not isinstance(css, bytes):
css = css.encode("utf-8")
provider = Gtk.CssProvider()
provider.load_from_data(css)
context = widget.get_style_context()
context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
So I try to apply css as this:
self.scrollwin = sw = ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
#get scrollbar
vscrollbar = sw.get_vscrollbar()
# 1rst attempt
# qltk.add_css(vscrollbar, '* slider {min-width: 20px;}')
#2nd attempt
qltk.add_css(vscrollbar, 'scrollbar.vertical slider {min-width: 20px;}')
I've got same error with 2 attempts:
'min-width' is not a valid property name (3)
Update 1
I try #Herbalist solution, scrollbar component is resized but "slider" always have same size. It add spaces on right and on left of "slider".
vscrollbar.set_size_request(50,-1)
Is it possible to resize slider of scrollbar ?
Screenshot of result (I outline part of scrollbar in green):
I'm not able to success with css, so I use deprecated method:
GtkRange:slider-width has been deprecated since version 3.20 and
should not be used in newly-written code.
Use the min-height/min-width CSS properties on the slider element. The
value of this style property is ignored.
As this:
qltk.add_css(vscrollbar, '* {-GtkRange-slider-width:40px}')
get_vscrollbar() returns a Gtk.Widget so you could try setting the "width-request" property

TTTAttributedLabel setbackground color

I am using TTTAttributedLabel and need to set background color. I can set text color like this.
[mutableAttributedString addAttribute:NSForegroundColorAttributeName
value:color
range:range];
self.lblContent.attributedText = mutableAttributedString;
But it is not working for background color.
[mutableAttributedString addAttribute:NSBackgroundColorAttributeName
value:color
range:range];
self.lblContent.attributedText = mutableAttributedString;
May I know what is wrong?
You should use kTTTBackgroundFillColorAttributeName. See TTTAttributedLabel.h for details on that constant and several other attribute constants that are specific to TTTAttributedLabel.

Resources