org.zkoss.zss.ui.impl
Class Utils

java.lang.Object
  extended by org.zkoss.zss.ui.impl.Utils

public class Utils
extends java.lang.Object

Internal Use Only. Utility class for Spreadsheet.

Author:
Dennis.Chen

Constructor Summary
Utils()
           
 
Method Summary
static void autoFilter(Worksheet sheet, Rect selection)
           
static int calcDefaultCharWidth(java.awt.Font font)
           
static void copyCell(org.zkoss.poi.ss.usermodel.Cell cell, Worksheet dstSheet, int dstRow, int dstCol)
           
static void copyCell(Worksheet srcSheet, int srcRow, int srcCol, Worksheet dstSheet, int dstRow, int dstCol)
           
static int defaultColumnWidthToPx(int columnWidth, int charWidth)
          Convert default columns character width to pixel
static void deleteColumns(Worksheet sheet, int startCol, int endCol)
           
static void deleteRows(Worksheet sheet, int startRow, int endRow)
           
static java.lang.String escapeCellText(java.lang.String text, boolean wrap, boolean multiline)
          Escape character that has special meaning in HTML such as <, &, etc..
static int fileChar256ToPx(int char256, int charWidth)
          convert file 1/256 character width to pixel
static void fillCells(Worksheet sheet, int srctRow, int srclCol, int srcbRow, int srcrCol, int dsttRow, int dstlCol, int dstbRow, int dstrCol)
           
static void fillColumns(Worksheet sheet, int srclCol, int srcrCol, int dstlCol, int dstrCol)
           
static void fillRows(Worksheet sheet, int srctRow, int srcbRow, int dsttRow, int dstbRow)
           
static java.lang.String formatHyperlink(Worksheet sheet, org.zkoss.poi.ss.usermodel.Hyperlink hlink, java.lang.String cellText, boolean wrap)
          Format and escape a Hyperlink to HTML <a> string.
static java.lang.String formatRichTextString(Worksheet sheet, org.zkoss.poi.ss.usermodel.RichTextString rstr, boolean wrap)
          Format and escape a RichTextString to HTML <span> string.
static org.zkoss.poi.ss.usermodel.Cell getCell(Worksheet sheet, int rowIndex, int colIndex)
          Return the Cell per the given sheet, row index, and column index; return null if cell not exists.
static java.lang.String getCellText(Worksheet sheet, org.zkoss.poi.ss.usermodel.Cell cell)
           
static java.lang.String getColumnTitle(Worksheet sheet, int col)
           
static int getColumnWidthInPx(Worksheet sheet, int col)
           
static int getDefaultCharWidth(Worksheet sheet)
           
static int getDefaultColumnWidthInPx(Worksheet sheet)
           
static java.lang.String getEditText(org.zkoss.poi.ss.usermodel.Cell cell)
          Returns the text for editing on the specified cell.
static FormatText getFormatText(org.zkoss.poi.ss.usermodel.Cell cell)
           
static int getHeightAny(Worksheet sheet, int row)
           
static int getHeightInPx(Worksheet zkSheet, org.zkoss.poi.ss.usermodel.ClientAnchor anchor)
           
static org.zkoss.poi.ss.usermodel.Hyperlink getHyperlink(org.zkoss.poi.ss.usermodel.Cell cell)
          Returns the Hyperlink to be shown on the specified cell.
static int getLeftFraction(Worksheet zkSheet, org.zkoss.poi.ss.usermodel.ClientAnchor anchor, int charWidth)
           
static org.zkoss.poi.ss.usermodel.Cell getOrCreateCell(Worksheet sheet, int rowIndex, int colIndex)
          Return or create if not exist the Cell per the given sheet, row index, and column index.
static org.zkoss.poi.ss.usermodel.Row getOrCreateRow(Worksheet sheet, int rowIndex)
           
static Range getRange(Worksheet sheet, int row, int col)
          Return a cell Range per the given sheet, row index, and column index.
static Range getRange(Worksheet sheet, int tRow, int lCol, int bRow, int rCol)
          Returns a area Range per the given sheet, top row index, left column index, bottom row index, and right column index.
static Range getRange(Worksheet firstSheet, Worksheet lastSheet, int row, int col)
          Return a 3D cell Range per the given sheet, row index, and column index.
static Range getRange(Worksheet firstSheet, Worksheet lastSheet, int tRow, int lCol, int bRow, int rCol)
          Return a 3D area Range per the given sheet, top row index, left column index, bottom row index, and right column index.
static org.zkoss.poi.ss.usermodel.RichTextString getRichEditText(org.zkoss.poi.ss.usermodel.Cell cell)
          Returns the RichTextString for editing on the cell.
static int getRowHeightInPx(Worksheet sheet, int row)
           
static int getRowHeightInPx(Worksheet sheet, org.zkoss.poi.ss.usermodel.Row row)
           
static java.lang.String getRowTitle(Worksheet sheet, int row)
           
static Worksheet getSheetByRefSheet(Book book, RefSheet refSheet)
          Returns the associated model sheet(Worksheet) per the given the reference sheet(RefSheet).
static Worksheet getSheetByUuid(Book book, java.lang.String uuid)
          Returns the Worksheet of the specified uuid; null if id not exists.
static java.lang.String getSheetUuid(Worksheet sheet)
          Returns the uuid of the specified Worksheet.
static org.zkoss.poi.ss.usermodel.RichTextString getText(org.zkoss.poi.ss.usermodel.Cell cell)
          Returns the RichTextString to be shown on the specified cell.
static int getTopFraction(Worksheet zkSheet, org.zkoss.poi.ss.usermodel.ClientAnchor anchor)
           
static int getWidthAny(Worksheet zkSheet, int col, int charWidth)
           
static int getWidthInPx(Worksheet zkSheet, org.zkoss.poi.ss.usermodel.ClientAnchor anchor, int charWidth)
           
static void insertColumns(Worksheet sheet, int startCol, int endCol)
           
static void insertRows(Worksheet sheet, int startRow, int endRow)
           
static boolean isTitleIndexMode(Spreadsheet ss)
          Returns whether the Spreadsheet title is in index mode
static void mergeCells(Worksheet sheet, int tRow, int lCol, int bRow, int rCol, boolean across)
           
static void moveCells(Worksheet sheet, int tRow, int lCol, int bRow, int rCol, int nRow, int nCol)
           
static void moveColumns(Worksheet sheet, int lCol, int rCol, int nCol)
           
static void moveRows(Worksheet sheet, int tRow, int bRow, int nRow)
           
static java.lang.String nextUpdateId()
           
static Range pasteSpecial(Worksheet srcSheet, Rect srcRect, Worksheet dstSheet, int tRow, int lCol, int bRow, int rCol, int pasteType, int pasteOp, boolean skipBlanks, boolean transpose)
          Pastes to a destination from source Rect
static int pxToFileChar256(int px, int charWidth)
          convert pixel to file 1/256 character width
static int pxToPoint(int px)
          convert pixel to point
static double pxToScreenChar1(int px, int charWidth)
          Convert pixel to character width (for application)
static int pxToScreenChar256(int px, int charWidth)
          Convert pixel to 1/256 character width
static int pxToTwip(int px)
          convert pixel to twip (1/20 point)
static int screenChar1ToPx(double w, int charWidth)
          convert character width to pixel
static int screenChar256ToPx(int char256, int charWidth)
          convert 1/256 character width to pixel
static void setAlignment(Worksheet sheet, Rect rect, short alignment)
          Set alignment in selection range
static void setBackgroundColor(Worksheet sheet, Rect rect, java.lang.String color)
          Set background color in selection range.
static void setBorder(Worksheet sheet, Rect rect, short borderType, org.zkoss.poi.ss.usermodel.BorderStyle lineStyle, java.lang.String color)
          Sets the border in selection range
static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, boolean value)
           
static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, java.util.Date value)
           
static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, double value)
           
static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, int value)
           
static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, java.lang.String value)
           
static void setColumnWidth(Worksheet sheet, int col, int px)
          Sets column Width in pixel.
static void setDataFormat(Worksheet sheet, Rect rect, java.lang.String format)
          Set format in selection range
static void setEditText(org.zkoss.poi.ss.usermodel.Cell cell, java.lang.String txt)
          Sets the user input text into the cell.
static void setEditText(Worksheet sheet, int row, int col, java.lang.String value)
          Set user input text into the cell at specified sheet, row index, and column index.
static boolean setEditTextWithValidation(Spreadsheet ss, Worksheet sheet, int row, int col, java.lang.String txt, org.zkoss.zk.ui.event.EventListener callback)
           
static void setFont(Worksheet sheet, Rect rect, short boldWeight, org.zkoss.poi.ss.usermodel.Color color, short fontHeight, java.lang.String fontName, boolean italic, boolean strikeout, short typeOffset, byte underline)
          Set font in selection range.
static void setFontBold(Worksheet sheet, Rect rect, boolean isBold)
          Set the font bold.
static void setFontColor(Worksheet sheet, Rect rect, java.lang.String color)
          Sets font color in selection range
static void setFontFamily(Worksheet sheet, Rect rect, java.lang.String fontName)
          Set font family in selection range Copy the original cell style, font style, and set new font family
static void setFontHeight(Worksheet sheet, Rect rect, short fontHeight)
          Set the font height in unit's of 1/20th of a point Copy the original cell style, font style, and set new font family
static void setFontItalic(Worksheet sheet, Rect rect, boolean isItalic)
          Set the font Italic.
static void setFontStrikeout(Worksheet sheet, Rect rect, boolean isStrikeout)
          Set the font strikeout.
static void setFontUnderline(Worksheet sheet, Rect rect, byte underline)
          Set the font underline.
static void setHyperlink(Worksheet sheet, int rowIndex, int colIndex, int linkType, java.lang.String address, java.lang.String display)
          Set hyperlink in cell
static void setLocked(Worksheet sheet, Rect rect, boolean locked)
          Sets cell locked
static void setRichEditText(org.zkoss.poi.ss.usermodel.Cell cell, org.zkoss.poi.ss.usermodel.RichTextString value)
          Sets the user input RichTextString into the cell.
static void setRowHeight(Worksheet sheet, int row, int px)
          Sets Row Height in pixel.
static void setWrapText(Worksheet sheet, Rect rect, boolean wrapped)
          Set wrap text in selection range
static void sort(Worksheet sheet, Rect selection, int[] index, boolean[] order, int[] dataOption, boolean header, boolean matchCase, boolean sortByRows)
          Sort in selection range
static int twipToPx(int twip)
          convert twip (1/20 point) to pixel
static void unmergeCells(Worksheet sheet, int tRow, int lCol, int bRow, int rCol)
           
static void visitCells(Worksheet sheet, Rect rect, CellVisitor vistor)
          Visit each cell in the Rect
static void visitCells(Worksheet sheet, Rect rect, CellVisitor vistor, CellFilter... filters)
           
static void visitSheets(Book book, SheetVisitor visitor)
          Visit each worksheet in the Book.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

autoFilter

public static void autoFilter(Worksheet sheet,
                              Rect selection)

sort

public static void sort(Worksheet sheet,
                        Rect selection,
                        int[] index,
                        boolean[] order,
                        int[] dataOption,
                        boolean header,
                        boolean matchCase,
                        boolean sortByRows)
Sort in selection range

Parameters:
sheet - the sheet to sort
selection - sort range
index - keys for sorting

default use the first index in selection

order - order for sorting, true to do descending sort; false to do ascending sort

default ascending sort

header - whether sort range includes header
matchCase - true to match the string cases; false to ignore string cases
sortByRows - false indicate sort by column (sort from top to bottom); true indicate sort by row (sort from left to right)

pasteSpecial

public static Range pasteSpecial(Worksheet srcSheet,
                                 Rect srcRect,
                                 Worksheet dstSheet,
                                 int tRow,
                                 int lCol,
                                 int bRow,
                                 int rCol,
                                 int pasteType,
                                 int pasteOp,
                                 boolean skipBlanks,
                                 boolean transpose)
Pastes to a destination from source Rect

Parameters:
srcSheet - the source sheet
srcRect - paste source range
dstSheet - paste to the sheet
tRow - destination top row index
lCol - destination left column index
bRow - destination bottom row index
rCol - destination right column index
pasteType - the part of the range to be pasted
pasteOp - the paste operation
skipBlanks - true to not have blank cells in the ranage on the Clipboard pasted into this range; default false
transpose - true to transpose rows and columns when pasting to this range; default false
Returns:
the real pasted range

setHyperlink

public static void setHyperlink(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                int linkType,
                                java.lang.String address,
                                java.lang.String display)
Set hyperlink in cell

Parameters:
sheet -
rowIndex -
colIndex -
linkType -
address -
display -

setFont

public static void setFont(Worksheet sheet,
                           Rect rect,
                           short boldWeight,
                           org.zkoss.poi.ss.usermodel.Color color,
                           short fontHeight,
                           java.lang.String fontName,
                           boolean italic,
                           boolean strikeout,
                           short typeOffset,
                           byte underline)
Set font in selection range.

Copy original cell style, and set new font.

Parameters:
sheet -
rect - selection range
boldWeight -
color - color to use
fontHeight - the font height in unit's of 1/20th of a point
fontName - the name for the font
italic - use italics or not
strikeout - strikeout or not
typeOffset - offset type to use
underline - underline type

setFontColor

public static void setFontColor(Worksheet sheet,
                                Rect rect,
                                java.lang.String color)
Sets font color in selection range

Parameters:
sheet -
rect -
color - color (in string as #RRGGBB)

setFontFamily

public static void setFontFamily(Worksheet sheet,
                                 Rect rect,
                                 java.lang.String fontName)
Set font family in selection range

Copy the original cell style, font style, and set new font family

Parameters:
sheet -
rect - selection range
fontName - font name

setFontHeight

public static void setFontHeight(Worksheet sheet,
                                 Rect rect,
                                 short fontHeight)
Set the font height in unit's of 1/20th of a point

Copy the original cell style, font style, and set new font family

Parameters:
sheet -
rect - selection range
fontHeight - font height in 1/20ths of a point

setFontBold

public static void setFontBold(Worksheet sheet,
                               Rect rect,
                               boolean isBold)
Set the font bold.

Copy the original cell style, font style, and set bold.

Parameters:
sheet -
rect -
isBold -

setFontItalic

public static void setFontItalic(Worksheet sheet,
                                 Rect rect,
                                 boolean isItalic)
Set the font Italic.

Copy the original cell style, font style, and set italic.

Parameters:
sheet -
rect -
isItalic -

setFontUnderline

public static void setFontUnderline(Worksheet sheet,
                                    Rect rect,
                                    byte underline)
Set the font underline.

Copy the original cell style, font style, and set underline.

Parameters:
sheet -
rect -
underline -

setFontStrikeout

public static void setFontStrikeout(Worksheet sheet,
                                    Rect rect,
                                    boolean isStrikeout)
Set the font strikeout.

Copy the original cell style, font style, and set strikeout.

Parameters:
sheet -
rect -
isStrikeout -

setAlignment

public static void setAlignment(Worksheet sheet,
                                Rect rect,
                                short alignment)
Set alignment in selection range

Parameters:
sheet -
rect -
alignment -

setWrapText

public static void setWrapText(Worksheet sheet,
                               Rect rect,
                               boolean wrapped)
Set wrap text in selection range

Parameters:
sheet -
rect -
wrapped -

setLocked

public static void setLocked(Worksheet sheet,
                             Rect rect,
                             boolean locked)
Sets cell locked

Parameters:
sheet -
rect -
locked -

setDataFormat

public static void setDataFormat(Worksheet sheet,
                                 Rect rect,
                                 java.lang.String format)
Set format in selection range

Parameters:
sheet -
rect -
format -

visitCells

public static void visitCells(Worksheet sheet,
                              Rect rect,
                              CellVisitor vistor)
Visit each cell in the Rect

Parameters:
sheet -
rect -
vistor -

visitSheets

public static void visitSheets(Book book,
                               SheetVisitor visitor)
Visit each worksheet in the Book.

Parameters:
book -
visitor -

visitCells

public static void visitCells(Worksheet sheet,
                              Rect rect,
                              CellVisitor vistor,
                              CellFilter... filters)
Parameters:
sheet -
rect -
vistor -
filters -

setBackgroundColor

public static void setBackgroundColor(Worksheet sheet,
                                      Rect rect,
                                      java.lang.String color)
Set background color in selection range.

Copy original cell style, and set new background color

Parameters:
sheet - sheet to set background color
rect - selection range
color - color to use

setBorder

public static void setBorder(Worksheet sheet,
                             Rect rect,
                             short borderType,
                             org.zkoss.poi.ss.usermodel.BorderStyle lineStyle,
                             java.lang.String color)
Sets the border in selection range

Parameters:
sheet - sheet to set border
rect - selection range
borderType - border type
lineStyle - border line style
color - border color

formatHyperlink

public static java.lang.String formatHyperlink(Worksheet sheet,
                                               org.zkoss.poi.ss.usermodel.Hyperlink hlink,
                                               java.lang.String cellText,
                                               boolean wrap)
Format and escape a Hyperlink to HTML <a> string.

Parameters:
sheet - the sheet with the RichTextString
hlink - the Hyperlink
Returns:
the HTML <a> format string

formatRichTextString

public static java.lang.String formatRichTextString(Worksheet sheet,
                                                    org.zkoss.poi.ss.usermodel.RichTextString rstr,
                                                    boolean wrap)
Format and escape a RichTextString to HTML <span> string.

Parameters:
sheet - the sheet with the RichTextString
rstr - the RichTextString
wrap - whether wrap the string if see "\n".
Returns:
the HTML <span> format string

escapeCellText

public static java.lang.String escapeCellText(java.lang.String text,
                                              boolean wrap,
                                              boolean multiline)
Escape character that has special meaning in HTML such as <, &, etc..

Parameters:
text - the text
wrap - whether to allow wrap
multiline - whether to show multiple line
Returns:
the HTML

nextUpdateId

public static java.lang.String nextUpdateId()

getOrCreateCell

public static org.zkoss.poi.ss.usermodel.Cell getOrCreateCell(Worksheet sheet,
                                                              int rowIndex,
                                                              int colIndex)
Return or create if not exist the Cell per the given sheet, row index, and column index.

Parameters:
sheet - the sheet to get cell from
rowIndex - the row index of the cell
colIndex - the column index of the cell
Returns:
or create if not exist the Cell per the given sheet, row index, and column index.

getOrCreateRow

public static org.zkoss.poi.ss.usermodel.Row getOrCreateRow(Worksheet sheet,
                                                            int rowIndex)

getCell

public static org.zkoss.poi.ss.usermodel.Cell getCell(Worksheet sheet,
                                                      int rowIndex,
                                                      int colIndex)
Return the Cell per the given sheet, row index, and column index; return null if cell not exists.

Parameters:
sheet - the sheet to get cell from
rowIndex - the row index of the cell
colIndex - the column index of the cell
Returns:
the Cell per the given sheet, row index, and column index; return null if cell not exists.

copyCell

public static void copyCell(Worksheet srcSheet,
                            int srcRow,
                            int srcCol,
                            Worksheet dstSheet,
                            int dstRow,
                            int dstCol)

copyCell

public static void copyCell(org.zkoss.poi.ss.usermodel.Cell cell,
                            Worksheet dstSheet,
                            int dstRow,
                            int dstCol)

insertRows

public static void insertRows(Worksheet sheet,
                              int startRow,
                              int endRow)

deleteRows

public static void deleteRows(Worksheet sheet,
                              int startRow,
                              int endRow)

insertColumns

public static void insertColumns(Worksheet sheet,
                                 int startCol,
                                 int endCol)

deleteColumns

public static void deleteColumns(Worksheet sheet,
                                 int startCol,
                                 int endCol)

setCellValue

public static void setCellValue(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                java.lang.String value)

setCellValue

public static void setCellValue(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                double value)

setCellValue

public static void setCellValue(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                boolean value)

setCellValue

public static void setCellValue(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                java.util.Date value)

setCellValue

public static void setCellValue(Worksheet sheet,
                                int rowIndex,
                                int colIndex,
                                int value)

getRange

public static Range getRange(Worksheet sheet,
                             int row,
                             int col)
Return a cell Range per the given sheet, row index, and column index.

Parameters:
sheet - the sheet to get the Range from.
row - the row index of the cell
col - the column index of the cell
Returns:
a cell Range per the given sheet, row index, and column index.

getRange

public static Range getRange(Worksheet sheet,
                             int tRow,
                             int lCol,
                             int bRow,
                             int rCol)
Returns a area Range per the given sheet, top row index, left column index, bottom row index, and right column index.

Parameters:
sheet - the sheet to get the Range from.
tRow - the top row index of the area
lCol - the left column index of the area
bRow - the bottom row index of the area
rCol - the right column index of the area
Returns:
a area Range per the given sheet, top row index, left column index, bottom row index, and right column index.

getRange

public static Range getRange(Worksheet firstSheet,
                             Worksheet lastSheet,
                             int row,
                             int col)
Return a 3D cell Range per the given sheet, row index, and column index.

Parameters:
firstSheet - the sheet to get the Range from.
lastSheet - the sheet to get the Range from.
row - the row index of the cell
col - the column index of the cell
Returns:
a cell Range per the given sheet, row index, and column index.

getRange

public static Range getRange(Worksheet firstSheet,
                             Worksheet lastSheet,
                             int tRow,
                             int lCol,
                             int bRow,
                             int rCol)
Return a 3D area Range per the given sheet, top row index, left column index, bottom row index, and right column index.

Parameters:
firstSheet - the sheet to get the Range from.
lastSheet - the sheet to get the Range from.
tRow - the top row index of the area
lCol - the left column index of the area
bRow - the bottom row index of the area
rCol - the right column index of the area
Returns:
a 3D area Range per the given sheet, top row index, left column index, bottom row index, and right column index.

getSheetUuid

public static java.lang.String getSheetUuid(Worksheet sheet)
Returns the uuid of the specified Worksheet. to identify a Worksheet)

Parameters:
sheet - the sheet
Returns:
the uuid of the specified Worksheet.

getSheetByUuid

public static Worksheet getSheetByUuid(Book book,
                                       java.lang.String uuid)
Returns the Worksheet of the specified uuid; null if id not exists.

Parameters:
book - the book the contains the Worksheet
uuid - the sheet uuid
Returns:
the Worksheet of the specified uuid; null if id not exists.

isTitleIndexMode

public static boolean isTitleIndexMode(Spreadsheet ss)
Returns whether the Spreadsheet title is in index mode

Parameters:
ss - the Spreadsheet
Returns:
whether the Spreadsheet title is in index mode

getSheetByRefSheet

public static Worksheet getSheetByRefSheet(Book book,
                                           RefSheet refSheet)
Returns the associated model sheet(Worksheet) per the given the reference sheet(RefSheet).

Parameters:
book - the model book
refSheet - the reference sheet
Returns:
the associated model sheet(Worksheet) per the given the reference sheet(RefSheet).

getHyperlink

public static org.zkoss.poi.ss.usermodel.Hyperlink getHyperlink(org.zkoss.poi.ss.usermodel.Cell cell)
Returns the Hyperlink to be shown on the specified cell.

Parameters:
cell - the cell
Returns:
the Hyperlink to be shown on the specified cell.

getText

public static org.zkoss.poi.ss.usermodel.RichTextString getText(org.zkoss.poi.ss.usermodel.Cell cell)
Returns the RichTextString to be shown on the specified cell.

Parameters:
cell - the cell
Returns:
the RichTextString to be shown on the specified cell.

getFormatText

public static FormatText getFormatText(org.zkoss.poi.ss.usermodel.Cell cell)

getCellText

public static java.lang.String getCellText(Worksheet sheet,
                                           org.zkoss.poi.ss.usermodel.Cell cell)

getEditText

public static java.lang.String getEditText(org.zkoss.poi.ss.usermodel.Cell cell)
Returns the text for editing on the specified cell.

Parameters:
cell - the cell
Returns:
the text for editing on the specified cell.

setEditText

public static void setEditText(Worksheet sheet,
                               int row,
                               int col,
                               java.lang.String value)
Set user input text into the cell at specified sheet, row index, and column index.

Parameters:
sheet - the sheet where the cell resides
row - the row index
col - the column index
value - the user input text

setEditText

public static void setEditText(org.zkoss.poi.ss.usermodel.Cell cell,
                               java.lang.String txt)
Sets the user input text into the cell.

Parameters:
cell - the cell.
txt - the user input text.

getRichEditText

public static org.zkoss.poi.ss.usermodel.RichTextString getRichEditText(org.zkoss.poi.ss.usermodel.Cell cell)
Returns the RichTextString for editing on the cell.

Parameters:
cell - the cell
Returns:
the RichTextString for editing on the cell.

setRichEditText

public static void setRichEditText(org.zkoss.poi.ss.usermodel.Cell cell,
                                   org.zkoss.poi.ss.usermodel.RichTextString value)
Sets the user input RichTextString into the cell.

Parameters:
cell - the cell
value - the user input RichTextString to be set into the cell.

mergeCells

public static void mergeCells(Worksheet sheet,
                              int tRow,
                              int lCol,
                              int bRow,
                              int rCol,
                              boolean across)

unmergeCells

public static void unmergeCells(Worksheet sheet,
                                int tRow,
                                int lCol,
                                int bRow,
                                int rCol)

getWidthInPx

public static int getWidthInPx(Worksheet zkSheet,
                               org.zkoss.poi.ss.usermodel.ClientAnchor anchor,
                               int charWidth)

getHeightInPx

public static int getHeightInPx(Worksheet zkSheet,
                                org.zkoss.poi.ss.usermodel.ClientAnchor anchor)

getTopFraction

public static int getTopFraction(Worksheet zkSheet,
                                 org.zkoss.poi.ss.usermodel.ClientAnchor anchor)

getLeftFraction

public static int getLeftFraction(Worksheet zkSheet,
                                  org.zkoss.poi.ss.usermodel.ClientAnchor anchor,
                                  int charWidth)

getColumnWidthInPx

public static int getColumnWidthInPx(Worksheet sheet,
                                     int col)

getRowHeightInPx

public static int getRowHeightInPx(Worksheet sheet,
                                   int row)

getRowHeightInPx

public static int getRowHeightInPx(Worksheet sheet,
                                   org.zkoss.poi.ss.usermodel.Row row)

getDefaultColumnWidthInPx

public static int getDefaultColumnWidthInPx(Worksheet sheet)

getDefaultCharWidth

public static int getDefaultCharWidth(Worksheet sheet)

getWidthAny

public static int getWidthAny(Worksheet zkSheet,
                              int col,
                              int charWidth)

getHeightAny

public static int getHeightAny(Worksheet sheet,
                               int row)

calcDefaultCharWidth

public static int calcDefaultCharWidth(java.awt.Font font)

pxToPoint

public static int pxToPoint(int px)
convert pixel to point


pxToTwip

public static int pxToTwip(int px)
convert pixel to twip (1/20 point)


twipToPx

public static int twipToPx(int twip)
convert twip (1/20 point) to pixel


fileChar256ToPx

public static int fileChar256ToPx(int char256,
                                  int charWidth)
convert file 1/256 character width to pixel


pxToFileChar256

public static int pxToFileChar256(int px,
                                  int charWidth)
convert pixel to file 1/256 character width


screenChar256ToPx

public static int screenChar256ToPx(int char256,
                                    int charWidth)
convert 1/256 character width to pixel


pxToScreenChar256

public static int pxToScreenChar256(int px,
                                    int charWidth)
Convert pixel to 1/256 character width


screenChar1ToPx

public static int screenChar1ToPx(double w,
                                  int charWidth)
convert character width to pixel


pxToScreenChar1

public static double pxToScreenChar1(int px,
                                     int charWidth)
Convert pixel to character width (for application)


defaultColumnWidthToPx

public static int defaultColumnWidthToPx(int columnWidth,
                                         int charWidth)
Convert default columns character width to pixel


getColumnTitle

public static java.lang.String getColumnTitle(Worksheet sheet,
                                              int col)

getRowTitle

public static java.lang.String getRowTitle(Worksheet sheet,
                                           int row)

setColumnWidth

public static void setColumnWidth(Worksheet sheet,
                                  int col,
                                  int px)
Sets column Width in pixel.

Parameters:
sheet -
col -
px - column width in pixel

setRowHeight

public static void setRowHeight(Worksheet sheet,
                                int row,
                                int px)
Sets Row Height in pixel.

Parameters:
sheet -
row -
px - row height in pixel

moveRows

public static void moveRows(Worksheet sheet,
                            int tRow,
                            int bRow,
                            int nRow)

moveColumns

public static void moveColumns(Worksheet sheet,
                               int lCol,
                               int rCol,
                               int nCol)

moveCells

public static void moveCells(Worksheet sheet,
                             int tRow,
                             int lCol,
                             int bRow,
                             int rCol,
                             int nRow,
                             int nCol)

fillRows

public static void fillRows(Worksheet sheet,
                            int srctRow,
                            int srcbRow,
                            int dsttRow,
                            int dstbRow)

fillColumns

public static void fillColumns(Worksheet sheet,
                               int srclCol,
                               int srcrCol,
                               int dstlCol,
                               int dstrCol)

fillCells

public static void fillCells(Worksheet sheet,
                             int srctRow,
                             int srclCol,
                             int srcbRow,
                             int srcrCol,
                             int dsttRow,
                             int dstlCol,
                             int dstbRow,
                             int dstrCol)

setEditTextWithValidation

public static boolean setEditTextWithValidation(Spreadsheet ss,
                                                Worksheet sheet,
                                                int row,
                                                int col,
                                                java.lang.String txt,
                                                org.zkoss.zk.ui.event.EventListener callback)


Copyright © 2005-2010 Potix Corporation. All Rights Reserved. SourceForge.net Logo