Answer the question
In order to leave comments, you need to log in
Who will help to finish the script for Google Spreadsheets?
There is this script:
function onOpen() {
SpreadsheetApp.getUi().createMenu("Extra")
.addItem("Обновить данные", "updatePoints")
.addToUi();
}
function updatePoints() {
var sh = SpreadsheetApp.getActiveSheet();
var datesColumn = sh.getRange( "A1:A" ).getValues();
var lastRow = datesColumn.filter( String ).length;
var oldDate = datesColumn[ lastRow - 1 ][ 0 ];
var oldPoints = parseFloat( sh.getRange( "B" + lastRow ).getValues() );
//обновляем валютки на сегодня
sh.getRange( 'e2' ).setValue( '=ROUND(IMPORTXML("http://www.cbr.ru/scripts/XML_daily.asp"; "//ValCurs/Valute[CharCode=""USD""]/Value");2)' );
//сохраняем текущую дату-время
var currentDate = Utilities.formatDate( new Date(), "GMT+3", "dd.MM HH:mm" );
sh.getRange( 'e1' ).setValue( currentDate );
//забираем текущие цифры
var currentPoints = parseFloat( sh.getRange( 'e2' ).getValues() );
if ( currentPoints !== oldPoints ) {
//сохраняем новые поинты и дату-время обновления
lastRow++;
sh.getRange( "B" + lastRow ).setValue( currentPoints );
sh.getRange( "A" + lastRow ).setValue( currentDate );
Logger.log( currentPoints + " <> " + oldPoints )
//MailApp.sendEmail("", "[Alert] ["+currentDate+"] points raised to " + currentPoints, "Old points " + oldPoints
//+"\nNew points "+currentPoints+"\n\nUpdated:"+currentDate,{noReply:true});
} else {
Logger.log( currentPoints + " = " + oldPoints )
}
}
Answer the question
In order to leave comments, you need to log in
Hmm, so here it's just rounding up to 56.00 and that's it. To round to two decimal places, you need to write:
sh.getRange( 'e2' ).setValue( '=ROUND(IMPORTXML(" www.cbr.ru/scripts/XML_daily.asp "; "//ValCurs/Valute [CharCode=""USD""]/Value");2)' );
I've been able to round...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question