Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

你可以使用数字,日期或者自定义格式来格式化单元格。

你也可以将单元格的 culture 设置成 "ja-jp" 或者 "en-us"。

数字会基于当前的 culture 进行格式化。默认为 English。

你可以将 culture 设置为 "ja-jp" 或者 "en-us"。

你可以只给整个控件设置 culture,也可以给某个单元格设置 culture。

单元格的 culture 不会影响控件的 culture。

Spread.Sheets 支持普通分数格式,比如 "# ?/?","# ??/??","# ?/4"和"#,## ?/?"。

你可以将负数转换成分数格式,

Spread.Sheets supports common fraction formats, such as "# ?/?", "# ??/??", "# ?/4", and "#,## ?/?". You can convert a negative value to a fraction. Spread.Sheets also supports the local ID "$-411" and DBNumber.

The custom format mode supports the combo, conditional, and forecolor formatters. The "(", ")", and "*" expressions are not supported.

You can also create a custom formatter with the FormatterBase class.

For more information on number format codes, refer to http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx.

Using Code

This example formats cell values.

JavaScript

Copy Code

var dvalue= 12345.6789;
activeSheet.setValue(0,0,dvalue);
activeSheet.getCell(0, 1).formatter("M");
activeSheet.setValue(0, 1, new Date(2011, 2, 9));
activeSheet.getCell(0, 2).formatter("m");
activeSheet.setValue(0, 2, new Date(2012, 10, 15));
activeSheet.getCell(0, 3).formatter("General");
activeSheet.setValue(0, 3, new Date(2012, 10, 15));
activeSheet.getCell(0, 4).formatter("#.#%");
activeSheet.setValue(0, 4, 1);
activeSheet.getCell(1, 0).formatter("[>2]0.0;[<-3]0.0;zero;");
activeSheet.setValue(1, 0, 3);

Using Code

This example formats a cell value as a fraction.

JavaScript

Copy Code

var dvalue= 123.89;
activeSheet.setValue(0,0,dvalue);
activeSheet.getCell(0, 0).formatter("# ??/??");

Using Code

This example formats a cell value using locale ID "$-411".

JavaScript

Copy Code

var dvalue= 123.89;
activeSheet.setValue(0,0,dvalue);
activeSheet.getCell(0,0).formatter("[$-411]dddd");

Using Code

This example formats a cell value using DBNumber.

JavaScript

Copy Code

var dvalue= 123.89;
activeSheet.setValue(0,0,dvalue);
activeSheet.getCell(0,0).formatter("[DBNum2][$-411]General");

Using Code

This example sets the culture for the widget.

JavaScript

Copy Code

//widget setting
GC.Spread.Common.CultureManager.culture("ja-jp");

Using Code

This example sets the culture for the cell.

JavaScript

Copy Code

//cell setting
//Input date string "2014/01/07" in cell[0,0] and cell[0,1]
activeSheet.getCell(0,0).formatter(new GC.Spread.Formatter.GeneralFormatter("yyyy/MM/dd dddd", "ja-jp"));
activeSheet.getCell(0,1).formatter(new GC.Spread.Formatter.GeneralFormatter("yyyy/MM/dd dddd", "en-us"));


See Also
Setting the Culture
GeneralFormatter class
formatter Method

  • No labels