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
NextSheet Sample Project
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created: 2008-05-12
- Updated: 2008-08-09
This tutorial require NextSheet 1.0 to be installed.
1. Placing component on form
Click on "Next Suite" tab/category within components palette/toolbox and select NextSheet component icon.
Click on form, and component will be placed with one cell already added, with ColCount and RowCount properties set to 1.

Now add NxSheetCell unit in uses section. This unit contain values for cell alignment, line styles...
2. Setting ColCount and RowCount properties
By increasing ColCount property new columns will be added at the end of columns array. Otherwise decreasing value of this property will delete columns beginning from last one.
Set ColCount property to 4.
Result:

RowCount property is very similar, but instead on columns it work on rows.
Set RowCount property to 3.

Now we have matrix of 4 x 3 cells where every cell may have own value and be formated in own style.
3. Merging cells in first row
Cell's may be merged by calling MergeCells method. This method merge all cells in square between starting and end cell.
Next code will merge cells from cell 0, 0 to the cell 3, 0:
NextSheet1.MergeCells(0, 0, 3, 0);

Now, we will set Text property and Alignment property for first cell. Since this is first cell in merged cells region, this cell will occupy space of whole region.
NextSheet1.Cell[0, 0].Alignment := caCenter; NextSheet1.Cell[0, 0].Text := 'Sales Data'; NextSheet1.Cell[0, 0].Color := clSkyBlue;
Result:

Now we will draw one black line bellow first row.
Since cells in first row are merged, we will only set border for top-left cell in merged area:
NextSheet1.Cell[0, 0].BorderBottom.LineStyle := lsSolid; NextSheet1.Cell[0, 0].BorderBottom.Color := clBlack;
After cells are un-merged (by calling Split method), again visible cells will have borders set

4. Setting cells in second row
We will merge cells in 2nd row, but not as one cell but 2:
NextSheet1.MergeCells(0, 1, 1, 1, caCenter); NextSheet1.MergeCells(2, 1, 3, 1, caCenter);

And place text in them
NextSheet1.Cell[0, 1].Text := 'First Half'; NextSheet1.Cell[2, 1].Text := 'Second Half';

NextSheet1.Cell[0, 1].SetBorder(bpBottom, lsDouble, clBlack); NextSheet1.Cell[2, 1].SetBorder(bpBottom, lsDouble, clBlack);
5. Place text in third row
Also, we will place text in 3rd row:
NextSheet1.Cell[0, 2].Text := 'Q1'; NextSheet1.Cell[1, 2].Text := 'Q2'; NextSheet1.Cell[2, 2].Text := 'Q3'; NextSheet1.Cell[3, 2].Text := 'Q4';

6. Add sample data
Now we will set RowCount property to 10.

and add sample data with AddCells method. This method add cells from array beginning from one cell.
NextSheet1.AddCells(['435', '335', '23', '46', '94', '256',
'334', '24', '134', '920', '23', '1', '567', '753', '13', '88'], 0, 3);

We will add thin line between data and remaining rows:
NextSheet1.Cell[0, 7].BorderTop.SetBorder(clBlack, lsThinLine); NextSheet1.Cell[1, 7].BorderTop.SetBorder(clBlack, lsThinLine); NextSheet1.Cell[2, 7].BorderTop.SetBorder(clBlack, lsThinLine); NextSheet1.Cell[3, 7].BorderTop.SetBorder(clBlack, lsThinLine);

7. Sumarize columns
Now we will sumarize sample data within last row:
NextSheet1.Cell[0, 7].Text := '=SUM(A4:A7)'; NextSheet1.Cell[1, 7].Text := '=SUM(B4:B7)'; NextSheet1.Cell[2, 7].Text := '=SUM(C4:C7)'; NextSheet1.Cell[3, 7].Text := '=SUM(D4:D7)';
We have use SUM built-in function and calculate sum of each column.

Final make-up
With using StylePainter object we will align and format all number cells.
with NextSheet1.StylePainter do
begin
Alignment := caCenterRight;
FormatMask := '#,##0.00';
Kind := ckNumber;
end;
NextSheet1.StylePainter.Apply(0, 3, 3, 7);