JSpreadsheet provides two controls that can display and modify Worksheet and Workbook objects respectively.
The WorksheetView control can be used to display Worksheet objects on a Windows form. The view displays the cells and objects of the worksheet and provides the users the ability to:
The worksheet is associated with the view through the Worksheet property. The currently active cell can be get or set through the ActiveCell property. The cell and object selection can be manipulated through the Selection property. The ScrollX and ScrollY properties can be used to get or set the position of the scrollbars. The scrollbars can be hidden through the ShowHorizontalScrollBar and ShowVerticalScrollBar properties. The worksheet headers can be hidden through the ShowHeaders property. The grid lines can be toggled through the ShowGridLines property. The cursors displayed during various user interactions can be customized through a set of properties: PointerCursor, AutoFillCursor, DiagonalResizeCursor, CounterDiagonalResizeCursor, HorizontalResizeCursor, VerticalResizeCursor, MoveCursor, DisallowCursor, HorizontalSplitCursor, and VerticalSplitCursor.
The view provides many events that can be used to track, validate and respond to user activities in the view. Some of the more interesting ones are listed below:
For a complete list of the view events, see WorksheetViewListener.
The WorkbookView control can be used to display Workbook objects on a Windows form. It extends the WorksheetView by adding tabs and a formula bar. The tabs represent the worksheets in the workbook. Selecting a tab results in activating its associated worksheet in the control. The formula bar displays the data of the currently active cell. The following image illustrates the WorkbookView control:
The workbook is associated with the view through the Workbook property. Similarly to the WorksheetView, the WorkbookView provides properties for manipulating the active cell and selection, for scrolling the view, for hiding the scrollbars and the worksheet headers, and so on.
The currently active worksheet can be get or set through the ActiveWorksheet property. The tabs representing the worksheets in the workbook can be customized through several properties. The alignment of the tabs is set through the TabAlignment property. The ShowTabs, ShowTabCloseButtons, ShowTabNavigationButtons, and ShowCreateNewTab properties can be used to show or hide the tab panel, the close buttons inside the individual tabs, the navigation buttons, and the button that can be used to create new worksheets respectively. The AllowTabReorder property specifies whether the tabs can be reordered interactively by dragging them with the mouse. Finally, the AllowTabEdit property indicates whether worksheets can be renamed in-place by double clicking on their respective tab.
The view provides various events, including worksheetAdded, worksheetRenamed, and activeWorksheetChanged. For the complete list of events, check WorkbookViewListener.
The view also provides several methods that can be used to auto-size rows and columns based on the cell content, namely, resizeColumnToFit, resizeColumnsToFit, resizeRowToFit, and resizeRowsToFit.