New Features of ZK Spreadsheet 1.0.0 RC

From Documentation
Revision as of 03:08, 14 September 2010 by Elton776 (talk | contribs)
DocumentationSmall Talks2008JulyNew Features of ZK Spreadsheet 1.0.0 RC
New Features of ZK Spreadsheet 1.0.0 RC

Author
Dennis Chen, Engineer, Potix Corporation
Date
July 8, 2008
Version


ZK Spreadsheet 1.0.0 RC1 has been released on 6/26. In the early articles, we were talking about the concept and use cases of ZK Spreadsheet. Now I will introduce the basic features of ZK Spreadsheet 1.0.0 RC to you.


You also can download zssnf.war file to run demos which in this introduction.


Import from an EXCEL file

In ZK Spreadsheet, base on MVC architecture, developer manipulates the data model org.zkoss.zss.model.Book to control the data presentation. The most efficient way to initial a data model is import from an exist EXCEL file by setting the location to the src attribute.

Following codes show how easily it could be to import an EXCEL file into ZK Spreadsheet.

<zk>

	<spreadsheet src="/xls/example.xls" height="500px" width="800px" />

</zk>


Rich User Interface

Styles

ZK Spreadsheet supports many styles such as font, font color, fill color ...etc. following table shows the styles that ZK Spreadsheet has supported.


Style Supported Notes
Font / Font Color / Fill Color Cause of browser limitation, font also depends on installed font on client side
Border / Border Color Cause of browser limitation, only solid/dashed/dotted border are supported now.
Horizontal Alignment Vertical Alignment has not implemented yet
Text Wrap & Overflow
Horizontal Merged Cell Vertical Merged Cell has not implemented yet


Following images are the screen shoot of EXCEL and ZK Spreadsheet

EXCEL Screen Shoot

Example excel.png


ZK Spreadsheet Screen Shoot

Example.png


Editing

When user using ZK Spreadsheet, it is very easy and similar to using EXCEL. You could do in-place editing, use function, change the column size ...etc.


Selection and Highlight

Selection is a special rectangle to show an area of cells that been selected, it could be changed either by user or program. Highlight is a special rectangle too, but it only could be changed by program. You could use highlight to emphasize a area that are marked to do something such as copy.


Custom Row and Column Title

The default title of the rows and columns are "1, 2, 3 ..." and "A, B, C ...". However you can change it to custom titles by setting rowtitles and columntitles attributes.

Title.png


Maximum Rows and Columns

Developer can control the maximum cells to be shown by setting maxrows and maxcolumns attributes. It is useful when you want to hide some data from user. It also has better performance because avoid loading too many data, that you don't want to show it, to client side.


Loading Cell on Demand

For the performance reason when showing with big data table, ZK Spreadsheet only load the necessary data to client side when scrolling.


Freezing Row and Column

By setting rowfreeze and columnfreeze attributes, you can freeze row and column on the left and top side of ZK Spreadsheet. This feature is useful when user browsing a report which has some title fields.


Image

Image is supported in ZK Spreadsheet. In following example, it display two images in ZK Spreadsheet.


Events

ZK Spreadsheet provide various events to notify what user have done, such as user start to edit a cell (onStartEditing) or press CTRL+C ( onCtrlKey ) to do something.


Editing Events

By listening onStartEditing, you can control which cell could be editing and what is the text to edit. By listening onStopEditing, you can check the commeted value and even change it. In following example, only cell in C3:E5 colud be editing and only numberic value is accepted.


Key Events

Like other standard ZK component, you can set keys which you are interested to ctrlKeys attribute and listen onCtrlKey event to handle it when user press those keys. In following example, it listen CTRL+C and CTRL+V to handle copy and paste of cell.


Mouse Events

Mouse events(onCellClick, onCellRightClick , onCellDoubleClick, onHeaderClick, onHeaderRightClick and onHeaderDoubleClick) are fired when user click on cell or header. In following example, it popup a menu when user right click on a header.


Selection Events

There are two types of Selection events: onCellSelection and onSelectionChange. onCellSelection is fired after user select a area of cells by mouse drag or key (shift + arrow key). onSelectionChange is fired after user drag the dot area(right-bottom of a selection area), which change the selection area.


Functions

Built-in Functions

ZK Spreadsheet provides many built-in functions that are compatible with EXCEL formula. In following example, it uses several functions, such as PMT, IPMT, PPMT, to calculate payment for a loan.


Custom Functions

It is also possible to plug custom functions into ZK Spreadsheet. In following example, we plug-in an 'ECHO' function which simply concatenate all given values into a string.