Skip to main content Skip to footer

GrapeCity Spread Silverlight CTP, Part 4 - Cell Format

Spread CTP - Script 4: Cell Format

If you are interested in downloading the Spread CTP, please email labs@grapecity.com .

This is the 4th in a series of Spread CTP Blogs and is a continuation of:

Part 1 - Create an app from scratch
Part 2 – AutoFit
Part 3 – Borders and Grid Lines

You can format cell values using standard number, date time, and custom formats.

Numbers are formatted based on the current culture. The default culture is English.

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

Using Code

CS

double dvalue = 12345.6789;

gcSpreadSheet1.Sheets[0].Cells[0, 0].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.StandardNumericMode, "c");

gcSpreadSheet1.Sheets[0].Cells[0, 0].Value = dvalue;

gcSpreadSheet1.Sheets[0].Cells[0, 1].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.StandardDateTimeMode, "M");

gcSpreadSheet1.Sheets[0].SetValue(0, 1, new DateTime(2011, 2, 9));

gcSpreadSheet1.Sheets[0].Cells[0, 2].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter("m");

gcSpreadSheet1.Sheets[0].SetValue(0, 2, new DateTime(2012, 10, 15));

gcSpreadSheet1.Sheets[0].Cells[0, 3].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter();

gcSpreadSheet1.Sheets[0].SetValue(0, 3, new DateTime(2012, 10, 15));

gcSpreadSheet1.Sheets[0].Cells[0, 4].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.CustomMode, "#.#%");

gcSpreadSheet1.Sheets[0].SetValue(0, 4, 1);

gcSpreadSheet1.Sheets[0].Cells[1, 0].Formatter = new GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.CustomMode, "[>2]0.0;[<-3]0.0;zero;");

gcSpreadSheet1.Sheets[0].SetValue(1, 0, 3);

gcSpreadSheet1.Invalidate();

VB.NET

Dim dvalue As Double

dvalue = 12345.6789

GcSpreadSheet1.Sheets(0).Cells(0, 0).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.StandardNumericMode, "c")

GcSpreadSheet1.Sheets(0).Cells(0, 0).Value = dvalue

GcSpreadSheet1.Sheets(0).Cells(0, 1).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.StandardDateTimeMode, "M")

GcSpreadSheet1.Sheets(0).SetValue(0, 1, New DateTime(2011, 2, 9))

GcSpreadSheet1.Sheets(0).Cells(0, 2).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter("m")

GcSpreadSheet1.Sheets(0).SetValue(0, 2, New DateTime(2012, 10, 15))

GcSpreadSheet1.Sheets(0).Cells(0, 3).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter()

GcSpreadSheet1.Sheets(0).SetValue(0, 3, New DateTime(2012, 10, 15))

GcSpreadSheet1.Sheets(0).Cells(0, 4).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.CustomMode, "#.#%")

GcSpreadSheet1.Sheets(0).SetValue(0, 4, 1)

GcSpreadSheet1.Sheets(0).Cells(1, 0).Formatter = New GrapeCity.Windows.SpreadSheet.Data.GeneralFormatter(GrapeCity.Windows.SpreadSheet.Data.FormatMode.CustomMode, "[>2]0.0;[<-3]0.0;zero;")

GcSpreadSheet1.Sheets(0).SetValue(1, 0, 3)

GcSpreadSheet1.Invalidate()

clip_image001

Next Part – Cell Overflow

Technorati Tags: Spread,Excel,Silverlight,CTP,labs@grapecity.com,visual studio,AutoFit,borders and Grid lines,cell format

tweetmeme_url = 'http://www.clubfarpoint.com/Forums/blogs/russells\_blog/archive/2012/03/27/grapecity-spread-silverlight-ctp-part-4-cell-format.aspx'; tweetmeme_source = '@russcamtv'; tweetmeme_hashtags = '#appdev';

MESCIUS inc.

comments powered by Disqus