Is it possible to add borders to an excel range automatically by using datanitro? - datanitro

Is it possible to add borders to an excel range automatically by using datanitro?
i.e. something like:
>>> CellRange("A1:A5").upper_border= True

You can't do it directly, but there are two workarounds:
Write a VBA function to do it and call that from DataNitro: https://datanitro.com/docs/vba.html#calling-vba-from-datanitro
Copy the formatting from a cell that has it already: https://datanitro.com/docs/cellrange.html?highlight=format#copy_format_from

Related

Replicating conditional formatting Google Sheets

I am trying to create a simple table that I can just replicate over and over when needed. Although in my sheet, I have the first range, B3:D12 working exactly as I want, I am finding it a challenge to then copy the formatting across to E3:G12 and for it to work subsequently.
Is the formula wrong? Is there an easier way that I can do this to make it simple each time I copy + paste the table across?
Thanks
Google Sheet Conditional Formatting
apply this:
=(B3=D3)*(B3<>"")
to B3:12, C3:12 and D3:12 as green
then as red use:
=(B3<>D3)*(B3<>"")
on B3:12

I have a google sheets cell with 5 different texts (from a dropdown) - how can I make another cell return a value based on the text

The 5 values in J4 are Studio, 1, 2, 3, 4.
Mortgage! is another sheet where I want to take B2*(52/12) if studio, B3*(52/12) if 1 and so on
Here is what I have been working with. I think I am close I just can't get it together to work
If
$J$4='Studio',(Mortgage!B2*(52/12)
$J$4='1',(Mortgage!B3*(52/12)
$J$4='2',(Mortgage!B3*(52/12)
$J$4='3',(Mortgage!B4*(52/12)
$J$4='4',(Mortgage!B5*(52/12)
Your logic is acceptable. You need to use the correct syntax.
=IF(
$J$4='Studio',Mortgage!B2*(52/12),
IF($J$4='1',Mortgage!B3*(52/12),
IF($J$4='2',Mortgage!B3*(52/12),
IF($J$4='3',Mortgage!B4*(52/12),
$J$4='4',Mortgage!B5*(52/12)
))))
By the way, it is customary to post a link to a public Google Sheet showing sample data when asking questions about Google Sheets.
Firstly, I think you have an errory in your sample code as you say I want to take B2*(52/12) if studio, B3*(52/12) if 1 and so on, but your sample is doing (Mortgage!B3*(52/12) for both $J$4='1' and $J$4='2'.
Therefor, I will assumne you are instead expecting...
if
$J$4='Studio',(Mortgage!B2*(52/12)
$J$4='1',(Mortgage!B3*(52/12)
$J$4='2',(Mortgage!B4*(52/12)
$J$4='3',(Mortgage!B5*(52/12)
$J$4='4',(Mortgage!B6*(52/12)
As others suggested, you can achive this by applying a nested IF() function with correct syntax,
but other than standard IF() funciont, you can use IFS() function for these kinds of cases:
=IFS(
$J$4='Studio',Mortgage!B2*(52/12),
$J$4='1',Mortgage!B3*(52/12),
$J$4='2',Mortgage!B4*(52/12),
$J$4='3',Mortgage!B5*(52/12),
$J$4='4',Mortgage!B6*(52/12)
)
There is also a SWITCH() function in google sheet that do similar things:
=SWITCH($J$4,
'Studio',Mortgage!B2*(52/12),
'1',Mortgage!B3*(52/12),
'2',Mortgage!B4*(52/12),
'3',Mortgage!B5*(52/12),
'4',Mortgage!B6*(52/12)
)
You may even create your own array to lookup for result:
=LAMBDA(DATA,
VLOOKUP($J$4,DATA,2,FALSE)
)({
'Studio',Mortgag!B2*(52/12);
'1',Mortgage!B3*(52/12);
'2',Mortgage!B4*(52/12);
'3',Mortgage!B5*(52/12);
'4',Mortgage!B6*(52/12)
})
where the array part:
{
'Studio',Mortgag!B2*(52/12);
'1',Mortgage!B3*(52/12);
'2',Mortgage!B4*(52/12);
'3',Mortgage!B5*(52/12);
'4',Mortgage!B6*(52/12)
}
can be shortened into something like this:
ArrayFormula({{'Studio';'1';'2';'3';'4'},Mortgage!B2:6*(52/12)})
or
ArrayFormula({{'Studio';TO_TEXT(SEQUENCE(4))},Mortgage!B2:6*(52/12)})
Combine this with the VLOOKUP(), you get this:
=ArrayFormula(VLOOKUP($J$4,{{'Studio';TO_TEXT(SEQUENCE(4))},Mortgage!B2:6*(52/12)},2,FALSE))
XLOOKUP() function also works in a similar way as VLOOKUP():
=ArrayFormula(XLOOKUP($J$4,{'Studio';TO_TEXT(SEQUENCE(4))},Mortgage!B2:6*(52/12)))

Remove all diacritics without script with a single formula for use in all cells without making calls to Google API

I created a formula that removes diacritics but needs to make calls through an ImportDATA. If I use this formula on every cell I need, it will exceed the call limit I can make. And it will lock the spreadsheet.
=ArrayFormula(if(exact(A1,Upper(A1)),Upper(VLOOKUP(A1,split(trim(transpose(split(query(SUBSTITUTE(regexreplace(regexreplace(query(IMPORTDATA("https://docs.oracle.com/cd/E29584_01/webhelp/mdex_basicDev/src/rbdv_chars_mapping.html"),"Select Col1 where Col1 contains '<td'",),"<td class=.+>","")&"~"&MOD(ROW(A:A),4),".+~[01]$",""),"~3","#"),"",9^6),"#"))),"~2"),2,0)),split(trim(transpose(split(query(SUBSTITUTE(regexreplace(regexreplace(query(IMPORTDATA("https://docs.oracle.com/cd/E29584_01/webhelp/mdex_basicDev/src/rbdv_chars_mapping.html"),"Select Col1 where Col1 contains '<td'",),"<td class=.+>","")&"~"&MOD(ROW(A:A),4),".+~[01]$",""),"~3","#"),"",9^6),"#"))),"~2")))
Instead of making this call to ImportDATA, I would like to use column A to put the diacritics and column B the corresponding common letters ... So make changes without having to make calls outside the spreadsheet and also without having to of creating a new Script function that is also often used, has a google limit that blocks usage ... But as I created this formula with the help of 3 answers here from StackOverflow, now to make this change I'm not succeeding.
And preferably that this formula already made the changes in a complete column instead of converting one cell only.
=ARRAYFORMULA(PROPER(IFERROR(REGEXREPLACE(L2:L, TEXTJOIN("|", 1, J2:J),
VLOOKUP(REGEXEXTRACT(L2:L, TEXTJOIN("|", 1, J2:J)), J2:K, 2*
SIGN(ROW(A2:A)), 0)&""), L2:L)))

Text wrap with box in Basemap

I'd like to write some text on a world map pointing to several locations. The text to be written for each location is short, a few lines, with one or two words/numbers (i.e earthquake magnitude, location, date). Is there a pythonic way to perform this?
Since matplotlib-basemap is based on matplotlib, you can simply use
plt.text(x,y,'yourtext')
to write text onto your map. If you want to have it boxed, add something like:
plt.text(x,y,'yourtext',bbox={'pad':10})
See also http://matplotlib.org/users/text_intro.html.

use uno (openoffice api) to open spreadsheet *without* recalculation

I'm using pyuno to read an excel spreadsheet (running on linux.) Many cells have formulas referring to addins that are, obviously, not available. However the cell values are what I want.
But when I load and read the sheet, it seems those formulas are being evaluated and thus the values are being overwritten with errors.
I've tried several things, none of which have worked:
set flags AutomaticCalculation=False, MacroExecutionMode=NEVER_EXECUTE in the call to desktop.loadComponentFromURL
call document.enableAutomaticCalculation(False) on the loaded document
Any suggestions?
If formluas aren't a matter, you might circumvent the problem by processing a copy of your spreadsheet in which only the values (not the formulas) are present.
To achieve this quickly, select the whole sheet content, copy, special paste; then remove everything except "value". Save to a new file (make sure you don't overwrite the original file or every formula will be lost!). Your script should then be able to process this file.
This is an ugly solution, as there must be a way to do it programmaticaly.
Calc does not yet support using the cached results after loading the document. Libreoffice Calc does now use cached results for xls documents. The results are also stored in ods but are ignored while loading the document and the formula result is evaluated by compiling and interpreting the saved formula.
There are some plans to add this for ods and xlsx too but there are many ods producers out there writting incorrect results in the file. So till now the only solution is to have a second version of the document only saving the results (or implementing it inside calc).