Spread.Sheets
カスタムカルチャの作成

カルチャ文字列の修正や、カスタムカルチャの作成を行うには、 CultureInfoクラスを使用します。

次の表は、このクラスの各変数と、それぞれのデフォルト値および基本的な説明を示します。

変数名 デフォルト値 説明
currencySymbol "\u00A4" ドル記号は"$"
numberDecimalSeparator "." 小数点
numberGroupSeparator "," 3桁区切り記号
arrayGroupSeparator ";" 数式内の配列定数の区切り記号
listSeparator "," 数式内の関数引数の区切り記号
aMDesignator "AM"  
pMDesignator "PM"  
abbreviatedMonthNames ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""] フォーマッタは"MMM"
abbreviatedDayNames ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] フォーマッタは"ddd"
abbreviatedMonthGenitiveNames ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""] フォーマッタは"MMM"
dayNames ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] フォーマッタは"dddd"
fullDateTimePattern "dddd, dd MMMM yyyy HH:mm:ss" 標準の日付フォーマッタは"F"
longDatePattern "dddd, dd MMMM yyyy" 標準の日付フォーマッタは"D"
longTimePattern "HH:mm:ss" 標準の日付フォーマッタは"T"および"U"
monthDayPattern "MMMM dd" 標準の日付フォーマッタは"M"および"m"
monthNames ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December", ""]
フォーマッタは"M"または"MM"
monthGenitiveNames ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December", ""]
フォーマッタは"MMMM"
rFC1123Pattern "ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'" 標準の日付フォーマッタは"R"および"r"
shortDatePattern "MM/dd/yyyy" 標準の日付フォーマッタは"d"
shortTimePattern "HH:mm" 標準の日付フォーマッタは"t"
sortableDateTimePattern "yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss" 標準の日付フォーマッタは"s"
universalSortableDateTimePattern "yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'" 標準の日付フォーマッタは"u"
yearMonthPattern "yyyy MMMM" 標準の日付フォーマッタは"y"および"Y"

カスタムカルチャを表示するには、GeneralFormatterクラスを使用してセル書式を設定します。

コードの使用

次のサンプルコードは、カスタムカルチャを作成します。さらに、セル(1,0)および(3,0)の日時フォーマッタ、セル(0,0)の数値フォーマッタをそれぞれ設定します。

JavaScript
コードのコピー

var myCulture = new GC.Spread.Common.CultureInfo();
myCulture.NumberFormat.currencySymbol = "?"
myCulture.NumberFormat.numberDecimalSeparator = ",";
myCulture.NumberFormat.NumberFormatumberGroupSeparator = ".";
myCulture.NumberFormat.arrayGroupSeparator = ";";
myCulture.NumberFormat.arrayListSeparator = "\\";
myCulture.NumberFormat.listSeparator = ";";

myCulture.DateTimeFormat.amDesignator = "";
myCulture.DateTimeFormat.pmDesignator = "";
myCulture.DateTimeFormat.abbreviatedMonthNames = ["Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez", ""];
myCulture.DateTimeFormat.abbreviatedDayNames = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
myCulture.DateTimeFormat.abbreviatedMonthGenitiveNames = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
myCulture.DateTimeFormat.dayNames = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"];
myCulture.DateTimeFormat.fullDateTimePattern = "dddd, d. MMMM yyyy HH:mm:ss";
myCulture.DateTimeFormat.longDatePattern = "dddd, d. MMMM yyyy";
myCulture.DateTimeFormat.longTimePattern = "HH:mm:ss";
myCulture.DateTimeFormat.monthDayPattern = "dd MMMM";
myCulture.DateTimeFormat.monthNames = ["Januar", "Februar", "Marz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""];
myCulture.DateTimeFormat.monthGenitiveNames = ["Januar", "Februar", "Marz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""];
myCulture.DateTimeFormat.shortDatePattern = "dd.MM.yyyy";
myCulture.DateTimeFormat.shortTimePattern = "HH:mm";
myCulture.DateTimeFormat.yearMonthPattern = "MMMM yyyy";

//1つのカルチャを追加します。
GC.Spread.Common.CultureManager.addCultureInfo("de-DE", myCulture);
//switch to "de-DE" culture
GC.Spread.Common.CultureManager.culture("de-DE");
var d = new Date();
//カルチャを使用します。
activeSheet.setValue(1, 0, new Date(d.setDate(d.getDate() + 1)));
activeSheet.getCell(1, 0).formatter("mmm");
var dvalue = 12345.6789;
activeSheet.setColumnWidth(0, 200);
activeSheet.setColumnWidth(1, 200);
activeSheet.setColumnWidth(2, 200);
activeSheet.setValue(0, 0, dvalue);
activeSheet.getCell(0, 0).formatter("###,###.00");

activeSheet.setValue(2, 0, new Date(d.setDate(d.getDate() + 1)));
//カルチャを使用します。
activeSheet.getCell(3, 0).formatter("yyyy/mmm/dddd");
activeSheet.setValue(3, 0, new Date());

参照

 

 


© 2016-2018, GrapeCity inc. All rights reserved.