Apply multiple font colors to the text in a single Google Sheets cell

As on July 2018, Apps-Script support changing individual text colors and other font related styles. Two methods are added to SpreadsheetApp. newTextStyle() and newRichTextValue(). The following apps-script changes such fontstyles in A1. For best effects, Use a lengthy string(30 characters or more). function rainbow(){ var rng = SpreadsheetApp.getActiveSheet().getRange(“A1”); var val = rng.getValue().toString(); var len = … Read more

Use a custom thousand separator in C#

I suggest you find a NumberFormatInfo which most closely matches what you want (i.e. it’s right apart from the thousands separator), call Clone() on it and then set the NumberGroupSeparator property. (If you’re going to format the numbers using currency formats, you need to change CurrencyGroupSeparator instead/as well.) Use that as the format info for … Read more

Printing with “\t” (tabs) does not result in aligned columns

Building on this question, I use the following code to indent my messages: String prefix1 = “short text:”; String prefix2 = “looooooooooooooong text:”; String msg = “indented”; /* * The second string begins after 40 characters. The dash means that the * first string is left-justified. */ String format = “%-40s%s%n”; System.out.printf(format, prefix1, msg); System.out.printf(format, … Read more

How to output numbers with leading zeros in JavaScript? [duplicate]

NOTE: Potentially outdated. ECMAScript 2017 includes String.prototype.padStart. You’ll have to convert the number to a string since numbers don’t make sense with leading zeros. Something like this: function pad(num, size) { num = num.toString(); while (num.length < size) num = “0” + num; return num; } Or, if you know you’d never be using more … Read more