Documents
NextGrid & NextDBGrid
- Integrating Inplace Editors
- Upgrade existing projects for loading changes
- FieldChooser Tutorial
- NextGrid How To
- Html Column Tutorial
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- Edit events in NextGrid
- NextGrid Vista Style
NextGrid
- NextGrid Quick Start
- Graphic Column Tutorial
- Optimize NextGrid
- Custom Draw in NextGrid
- VirtualColumn Tutorial
- NextGrid Custom Sorting
- TreeColumn Tutorial
NextDBGrid
NextInspector
- NextInspector Item Types
- NextInspector Quick Start
- NextDBInspector Tutorial
- NextInspector Advanced tutorial
- Map VCL property to item
NextSheet
- Formating in NextSheet
- NextSheet Sample Project
- NextSheet Quick Start
NextCollection
- NxInfoPanel Tutorial
- NxPathControl and NxNotebook tutorial
- NxAlertWindow Tutorial
- NxPathControl Quick Start
- NxButton Tutorial
- NxOutlookBar Tutorial
- NxFlipPanel and NxHeaderPanel Quick Start
- NxPageControl and NxNotebook Quick Start
Misc
- DateTime FormatMask
- NxAutoCompletion Tutorial
- Using NxColorScheme
- NxComboBox styles
- Enable typing unicode characters in InplaceEditors
- NxProgress Tutorial
- NxPreview Quick Start
- Numeric FormatMask
- Component Names Change
- 32bit Bitmaps Tutorial
Labs
Formating in NextSheet
Related Articles:
Info
- Skill:
- Version: 1.0.3
- Author: Bojan Nikolic
- Created:
- Updated: 2008-08-03
1. Introducing
Cell inside NextSheet may be formated in warious ways. There many elements to format such as cell's color, 4 borders, font, cell's kind, format mask...
1.1. Formating single cells
Cell may be formated alone at the time where Cell[] property is used. Example:
Cell[2, 3].Color := clRed; Cell[2, 3].Font.Size := 12;
or with using with command from Delphi:
with Cell[2, 3] do begin Color := clRed; Font.Size := 12; end;
Cell[2][3]->Color = clRed; Cell[2][3]->Font->Size = 12;
2. Cell Kind
Kind property is one of most important Cell's properties.
| Name | Meaning |
|---|---|
| ckGeneral | No formatting rules to be used. |
| ckNumber | Number formatting rules may be applied to cell's text with FormatMask. |
| ckDateTime | Date/Time formatting rules may be applied to cell's text with FormatMask. |
Example:
NextSheet1.Cell[1, 2].Text := DateToStr(Today); NextSheet1.Cell[1, 2].Kind := ckDateTime; NextSheet1.Cell[1, 2].FormatMask := 'mmm yyyy';
3. Cell borders
As mentioned in previous article, each cell include 4 properties for border: BorderLeft, BorderTop, BorderBottom, BorderRight. This borders are shared between 2 "neighbor" cells so setting bottom border will set border of cell bellow.
Border have 3 properties: Color which specify border's color, Position which is read-only property and determine border's position with cell, and LineStyle which represents style of border:
| Name | Preview |
|---|---|
| lsNone | ![]() |
| lsThinDot | ![]() |
| lsDot | ![]() |
| lsDashDotDot | not supported |
| lsWideDot | ![]() |
| lsThinLine | ![]() |
| lsWeightDashDotDot | ![]() |
| lsSkewDashDot | not supported |
| lsWeightDashDot | not supported |
| lsWeightDash | not supported |
| lsSolid | ![]() |
| lsWightSolid | ![]() |
| lsDouble | ![]() |
Example:
// Draw multi-color border cell and color it in clCream with NextSheet1.Cell[1, 1] do begin BorderTop.LineStyle := lsThinDot; BorderTop.Color := clPurple; BorderLeft.LineStyle := lsDouble; BorderLeft.Color := clRed; BorderBottom.LineStyle := lsWeightDashDotDot; BorderBottom.Color := clNavy; Color := clCream; end;
Result:

4. StylePainter object
As mentioned in first article about NextSheet StylePainter is handy object property which may be usefull for applying desired style (Alignment, Color, Font...). All needed is to set this sub-properties of StylePainter and call Apply method to apply this "styles" to range of cells.
This method is in next format:
procedure Apply(FromCol, FromRow, ToCol, ToRow: Integer);
In 1.0.7 Beta there is a new Paint method for individial cells.
5. FormatMask property
Each cell include FormatMask property, but how this format mask will be applied to the cell's value depends from Kind property of cell.
uses NxSheetCell, DateUtils; ... NextSheet1.Cell[0, 0].Value := '12345.00'; NextSheet1.Cell[0, 0].Kind := ckNumber; NextSheet1.Cell[0, 0].FormatMask := '#,##0.00'; NextSheet1.Cell[0, 1].Value := DateToStr(Today); NextSheet1.Cell[0, 1].Kind := ckDateTime; NextSheet1.Cell[0, 1].FormatMask := 'd.m.yyyy';
Result:

For formating ckNumber kind of cells, FormatFloat standard Delphi function is used. More details in
For formating ckDateTime kind of cells, FormatDateTime standard Delphi function is used. More details in
6. Clear formating
To clear formating of cell, you may simply set their properties back to default values or use ClearFormating function on range of cells.
// Clear cell colors and borders of all cells NextSheet1.ClearFormating(0, 0, NextSheet1.ColCount - 1, NextSheet1.RowCount - 1);
7. Procedures and functions
FrameCell procedure draw's frame (set Color and LineStyle properties is parameters) around cell. Example:
Example:
NextSheet1.FrameCell(NextSheet1.SelectedCol, NextSheet1.SelectedRow, lsSolid, clBlue);
Erase - Clear Text property for range of cells.
Example:
NextShee1.Erase(2, 2, 4, 3);
NextShee1->Erase(2, 2, 4, 3);








