[]
Spread for Winforms provides the ability to apply formatting to a cell value itself. This helps to retain the format string of the value throughout the calculation.
The GrapeCity.CalcEngine.IFormattedCellValue interface is used to set the value and format properties in a cell. It represents the value of a cell with a format string and allows the user to implement their own formatted cell value. The CalcEngine.FormattedCellValue class members can also be used to create an object instance to implement the feature.
The following code example shows how to implement formatting to a cell value instead of to a cell.
GrapeCity.Spreadsheet.IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
GrapeCity.CalcEngine.FormattedCellValue fmval = GrapeCity.CalcEngine.FormattedCellValue.Create(fpSpread1.AsWorkbook(), 123, "dd/mm/yyyy");
TestActiveSheet.Cells["A1"].Value = fmval;
TestActiveSheet.Cells["A2"].Formula = "A1"; // A2 show value same as A1 : 02/05/1900
Dim TestActiveSheet As GrapeCity.Spreadsheet.IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
Dim fmval As GrapeCity.CalcEngine.FormattedCellValue = GrapeCity.CalcEngine.FormattedCellValue.Create(FpSpread1.AsWorkbook(), 123, "dd/mm/yyyy")
TestActiveSheet.Cells("A1").Value = fmval
TestActiveSheet.Cells("A2").Formula = "A1" ' A2 show value same as A1 : 02/05/1900
The following behavior should be noted when working with formatted cell values: