HotXLS Docs

TXLSWorkbookViewer Component

TXLSWorkbookViewer is a VCL control that displays worksheets from either workbook engine without Microsoft Excel or any COM automation

Workbook sources

Navigation

The control provides horizontal and vertical scrollbars, mouse-wheel scrolling, mouse selection, arrow keys, Home, Page Up, Page Down, and Tab navigation

GoToCell , SelectRange , NextWorksheet , PreviousWorksheet , and SelectedRange expose the current view state

Editing and calculation

Set Editable to True to allow F2, double-click, printable-key, Delete and formula-bar edits; locked cells on a protected worksheet stay read only

BeginEdit, CommitEdit, and CancelEdit control the in-place editor, whilst EditSelectedCell and FormulaBarText support an external formula bar

Committed edits recognise formulas, booleans, integers, floating-point values, text, and blank input, then recalculate dependent formulas and invalidate conditional-format and pagination caches

Undo and Redo use an O(1) bounded circular history; set UndoLimit to control capacity or to zero to disable history

Delete or ClearSelectedRange clears the selection as one transaction; Ctrl+C and CopySelectedRange copy Unicode tab-separated text, whilst Ctrl+V, PasteSelectedRange, and PasteText paste a rectangular text block at the top-left corner of the selection with a single undo entry

Protection and structural preflight rejects a whole blocked range before mutation; undo and redo preserve native rich text, formula caches, styles and absent cells in both models, with the same protection check on every history attempt

Existing array formulas, data-table regions and multi-cell pastes intersecting a merge are rejected; single merged-anchor edits and whole-merge clears preserve merge geometry, whilst partial merged-range clears are rejected

The shared TXLSWorkbookEditHistory engine can also be instantiated without a control; see headless editing transactions for coordinate, lifetime, calculation and operation-limit rules

Formula reference selection

Call BeginReferencePick whilst a host formula editor is collecting a worksheet reference; each selection change raises OnReferencePick with the current A1 range until EndReferencePick is called

Rendering

The viewer uses each worksheet's column widths, row heights, and formatted display text, renders classic solid fills and font styling, and provides configurable headers, gridlines, and selection colours

For XLSX worksheets, the viewer also renders conditional fills, font colours and emphasis, number formats, colour scales, directional positive and negative data bars, gradients, borders, axes, hidden values, and all built-in icon-set families

The viewer caches one prepared conditional-format evaluator for the active worksheet so that scrolling and selection repaints do not rescan the workbook; call RefreshConditionalFormats after changing values, formulas, ranges or conditional rules in an attached workbook

XLSX rendering checks sparse cells and interval style overlays without indexing empty coordinates, so scrolling does not materialise visible blank cells or expand worksheet storage

Print preview

Set PrintPreview to True to display the active worksheet through the shared TXLSPaginationModel used by PDF page geometry and counting

PreviewPage is one based and clamps to PreviewPageCount; the arrow, Page Up, Page Down, Home, End, mouse-wheel, and vertical-scroll commands navigate logical pages whilst preview is active

PaginationModel exposes the cached model, SavePreviewPageAsMetafile writes the selected logical page as EMF, and RefreshPagination rebuilds the cache after changes to values, dimensions, print settings, breaks, titles or drawings

Events

Delphi example

Viewer := TXLSWorkbookViewer.Create(Self);
Viewer.Parent := Self;
Viewer.Align := alClient;
Viewer.XlsxWorkbook := Workbook;
Viewer.Editable := True;
Viewer.SelectRange(2, 1, 5, 3);
Caption := Viewer.SelectedRange;
Viewer.GoToCell(2, 3);
Viewer.FormulaBarText := '=A1*2';
Viewer.Undo;
Viewer.Redo;
Viewer.RefreshConditionalFormats;
Viewer.PrintPreview := True;
Viewer.PreviewPage := 1;
Viewer.SavePreviewPageAsMetafile('Preview.emf');
Viewer.GoToCell(12, 4);
Caption := Viewer.WorksheetName + ': ' + Viewer.SelectedCellText;

See Demo\Delphi\WorkbookViewer for a complete run-time-created viewer with file opening and worksheet controls