SpreadJS Documentation > Developer's Guide > Managing Data > Creating a Custom Culture |
You can modify the culture string and create a custom culture using the CultureInfo class.
The following table lists the class variables, default values, and basic descriptions.
Variable Name | Default Value | Description |
currencySymbol | "\u00A4" | Dollar is "$" |
numberDecimalSeparator | "." | Decimal point |
numberGroupSeparator | "," | Thousand separator |
arrayGroupSeparator | ";" | Separator for array constant in formula |
listSeparator | "," | Separator for function arguments in formula |
aMDesignator | "AM" | |
pMDesignator | "PM" | |
abbreviatedMonthNames | ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""] | Formatter is "MMM" |
abbreviatedDayNames | ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] | Formatter is "ddd" |
abbreviatedMonthGenitiveNames | ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""] | Formatter is "MMM" |
dayNames | ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] | Formatter is "dddd" |
fullDateTimePattern | "dddd, dd MMMM yyyy HH:mm:ss" | Standard date formatter "F" |
longDatePattern | "dddd, dd MMMM yyyy" | Standard date formatter "D" |
longTimePattern | "HH:mm:ss" | Standard date formatter "T" and "U" |
monthDayPattern | "MMMM dd" | Standard date formatter "M" and "m" |
monthNames | ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""] |
Formatter is "M" or "MM" |
monthGenitiveNames | ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""] |
Formatter is "MMMM" |
rFC1123Pattern | "ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'" | Standard date formatter "R" and "r" |
shortDatePattern | "MM/dd/yyyy" | Standard date formatter "d" |
shortTimePattern | "HH:mm" | Standard date formatter "t" |
sortableDateTimePattern | "yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss" | Standard date formatter "s" |
universalSortableDateTimePattern | "yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'" | Standard date formatter "u" |
yearMonthPattern | "yyyy MMMM" | Standard date formatter "y" and "Y" |
You can display the custom culture by setting the cell format using the GeneralFormatter class.
The following code creates a custom culture and sets a date time formatter for cell (1,0) and (3,0) and a number formatter for cell (0,0).
JavaScript |
Copy Code
|
---|---|
var myCulture = new GcSpread.Sheets.CultureInfo(); myCulture.currencySymbol = "€" myCulture.numberDecimalSeparator = ","; myCulture.numberGroupSeparator = "."; myCulture.arrayGroupSeparator = ";"; myCulture.arrayListSeparator = "\\"; myCulture.listSeparator = ";"; myCulture.amDesignator = ""; myCulture.pmDesignator = ""; myCulture.abbreviatedMonthNames = ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""]; myCulture.abbreviatedDayNames = ["So","Mo","Di","Mi","Do","Fr","Sa"]; myCulture.abbreviatedMonthGenitiveNames = ["So","Mo","Di","Mi","Do","Fr","Sa"]; myCulture.dayNames = ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]; myCulture.fullDateTimePattern = "dddd, d. MMMM yyyy HH:mm:ss"; myCulture.longDatePattern = "dddd, d. MMMM yyyy"; myCulture.longTimePattern = "HH:mm:ss"; myCulture.monthDayPattern = "dd MMMM"; myCulture.monthNames = ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""]; myCulture.monthGenitiveNames = ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""]; myCulture.shortDatePattern = "dd.MM.yyyy"; myCulture.shortTimePattern = "HH:mm"; myCulture.yearMonthPattern = "MMMM yyyy"; //add one culture GcSpread.Sheets.addCultureInfo("de-DE", myCulture); //switch to "de-DE" culture GcSpread.Sheets.Culture("de-DE"); var d = new Date(); //With culture activeSheet.setValue(1, 0, new Date(d.setDate(d.getDate()+1))); activeSheet.setFormatter(1, 0, new GcSpread.Sheets.GeneralFormatter("F", GcSpread.Sheets.FormatMode.StandardDateTimeMode)); var dvalue= 12345.6789; var nvalue = 12345; activeSheet.setColumnWidth(0, 100); activeSheet.setColumnWidth(1, 100); activeSheet.setColumnWidth(2, 100); activeSheet.setValue(0,0,dvalue); activeSheet.getCell(0, 0).formatter(new GcSpread.Sheets.GeneralFormatter("c3", GcSpread.Sheets.FormatMode.StandardNumericMode)); //Without culture activeSheet.setValue(2, 0, new Date(d.setDate(d.getDate() + 1))); //With culture activeSheet.setFormatter(3, 0, "yyyy/MMM/dddd"); activeSheet.setValue(3, 0, new Date()); |