Documents
NextGrid & NextDBGrid
- Integrating Inplace Editors
- Upgrade existing projects for loading changes
- Grid Report Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- 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
- Export to XML from NextGrid
- NextGrid Custom Sorting
- TreeColumn Tutorial
NextDBGrid
- Sorting records in NextDBGrid
- NextDBGrid Events
- NextDBGrid Quick Start
- NextDBGrid How To
- LookupColumn Tutorial
NextInspector
- NextInspector Item Types
- NextInspector Quick Start
- NextDBInspector Tutorial
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- Map VCL property to item
NextSheet
- Formating in NextSheet
- NextSheet Sample Project
- NextSheet Quick Start
- NextSheet Print Method
NextCollection
- NxInfoPanel Tutorial
- Vista Styled Panels
- 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
- NxVirtualDataSet tutorial
- Component Names Change
- 32bit Bitmaps Tutorial
- Quick update
Labs
NextSheet Sample Project
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created: 2008-05-12
- Updated: 2009-06-27
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);
Comments
2009-06-21 02:54:20
can you please add a simple print routine for the next sheet...
2009-06-21 04:38:09
Hi,
There is no automatic printing routine, but with using Printer.BeginDoc and Printer.EndDoc printing can be made.
I will write small demo project to show this. I hope that it will be done in next few days.
Best regards
Boki (BergSoft)
There is no automatic printing routine, but with using Printer.BeginDoc and Printer.EndDoc printing can be made.
I will write small demo project to show this. I hope that it will be done in next few days.
Best regards
Boki (BergSoft)
2009-07-18 04:03:07
Hi,
I have write Print method which may help for basic printings. More info about this method on: http://dn.bergsoft.net/nextsheet-print-method.htm
I have write Print method which may help for basic printings. More info about this method on: http://dn.bergsoft.net/nextsheet-print-method.htm
2010-06-04 01:16:39
hi Boki,
since we a procedure that actually saves the nextsheet to an xls or csv file... why not have a procedure that loads the
file that it saves..including its user-defined format... am writing an application that will retrieve values a table and place them into the nextsheet... the end-user needs to define formulas which is in the nextsheet. it would be nice if you can add this feature to the nextsheet... thanks
mcblaise
since we a procedure that actually saves the nextsheet to an xls or csv file... why not have a procedure that loads the
file that it saves..including its user-defined format... am writing an application that will retrieve values a table and place them into the nextsheet... the end-user needs to define formulas which is in the nextsheet. it would be nice if you can add this feature to the nextsheet... thanks
mcblaise