2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【arrayformula()対応版】Google Spreadsheet 半角から全角に変換

Last updated at Posted at 2020-02-20

@ssmxgo さんの記事に、
https://qiita.com/ssmxgo/items/2bc510c6cec91badd332

ミラクル素敵な関数 「toFullWidth()」を見つけました。

arrayに非対応だったため、arrayformula()で処理できなかったので、
ちょい足ししたものを公開させていただきます:

// こちらを拝借させて頂きました
function toFullWidthSingle(value) {
  if (!value) return value;
  return String(value).replace(/[!-~]/g, function(all) {
    return String.fromCharCode(all.charCodeAt(0) + 0xFEE0);
  });
}

// アレイ対応にしました
function toFullWidth(array) {
  if (!array) return array;
  var newValues = [[]];
  array.forEach(function(item, index){
    newValues.push(toFullWidthSingle(item));
  });
  return(newValues.slice(1)) // 頭に一つ余計な要素が発生するのを削除して返す
}

Google Spreadsheetsは本当に便利ですね!

@ssmxgo 様ありがとうございました。

2
2
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?