Package io.keikai.api
Class SheetOperationUtil
- java.lang.Object
-
- io.keikai.api.SheetOperationUtil
-
-
Constructor Summary
Constructors Constructor Description SheetOperationUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Chart
addChart(Range range, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos)
Adds a chart to specified sheet range in pre-defined position and size.static Chart
addChart(Range range, SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos)
Adds a chart at the specified locationstatic Picture
addPicture(Range range, byte[] binary, Picture.Format format, int widthPx, int heightPx)
Add picture to the rangestatic Picture
addPicture(Range range, SheetAnchor anchor, byte[] binary, Picture.Format format)
Add picture to the rangestatic Picture
addPicture(Range range, org.zkoss.image.AImage image)
Add picture to the rangestatic void
addSheet(Range range, String prefix)
Add a new sheet to this bookstatic void
applyAutoFilter(Range range)
Re-apply autofilterstatic void
copySheet(Range range)
Copy the sheet with the naming pattern "ORIGINAL_SHEET_NAME (n)".static void
createSheet(Range range, String name)
Add a new sheet as the last sheet to this bookstatic void
deleteChart(Range range, Chart chart)
Delete a chart if the specified Range has the specified chart.static void
deletePicture(Range range, Picture picture)
Delete a picturestatic void
deleteSheet(Range range)
Deletes the sheet, notice that it prevents you from deleting the last sheetstatic void
displaySheetGridlines(Range range, boolean enable)
Enables/disables to show a sheet's gridlines.static Picture.Format
getPictureFormat(org.zkoss.image.AImage image)
Gets the picture formatstatic boolean
hasChart(Range range, Chart chart)
Returns whether the range of sheet has the chart.static boolean
hasPicture(Range range, Picture picture)
Returns whether the range of sheet has the picturestatic void
moveChart(Range range, Chart chart, int rowIndex, int columnIndex)
Move a chart to specified row and column.static void
movePicture(Range range, Picture picture, int rowIndex, int columnIndex)
Move a picture to specified row and column.static void
protectSheet(Range range, String password, boolean allowSelectingLockedCells, boolean allowSelectingUnlockedCells, boolean allowFormattingCells, boolean allowFormattingColumns, boolean allowFormattingRows, boolean allowInsertColumns, boolean allowInsertRows, boolean allowInsertingHyperlinks, boolean allowDeletingColumns, boolean allowDeletingRows, boolean allowSorting, boolean allowFiltering, boolean allowUsingPivotTables, boolean drawingObjects, boolean scenarios)
static void
protectSheet(Range range, String password, String newpasswrod)
static void
renameSheet(Range range, String newname)
Rename a sheetstatic void
resetAutoFilter(Range range)
Resets AutoFilterstatic void
setSheetOrder(Range range, int pos)
Sets a sheet's position order, used to move a sheetstatic SheetAnchor
toChartAnchor(Range range)
Create a anchor by range's row/column datastatic SheetAnchor
toFilledAnchor(Sheet sheet, int row, int column, int widthPx, int heightPx)
return aSheetAnchor
based on a cell and a picture width and heightstatic void
toggleAutoFilter(Range range)
Toggles AutoFilter on or offstatic boolean
unprotectSheet(Range range, String password)
-
-
-
Method Detail
-
toggleAutoFilter
public static void toggleAutoFilter(Range range)
Toggles AutoFilter on or off- Parameters:
range
- the range to toggle
-
resetAutoFilter
public static void resetAutoFilter(Range range)
Resets AutoFilter- Parameters:
range
- the range to reset
-
applyAutoFilter
public static void applyAutoFilter(Range range)
Re-apply autofilter- Parameters:
range
- the range to apply
-
addPicture
public static Picture addPicture(Range range, org.zkoss.image.AImage image)
Add picture to the range- Parameters:
range
- the range to add picture toimage
- the image
-
addPicture
public static Picture addPicture(Range range, byte[] binary, Picture.Format format, int widthPx, int heightPx)
Add picture to the range- Parameters:
range
- the range to add picturebinary
- the image binary dataformat
- the image formatwidthPx
- the width of image to placeheightPx
- the height of image to place
-
addPicture
public static Picture addPicture(Range range, SheetAnchor anchor, byte[] binary, Picture.Format format)
Add picture to the range- Parameters:
range
- the range to add pictureanchor
- the picture locationbinary
- the image binary dataformat
- the image format
-
getPictureFormat
public static Picture.Format getPictureFormat(org.zkoss.image.AImage image)
Gets the picture format- Parameters:
image
- the image- Returns:
- image format, or null if doens't support
-
movePicture
public static void movePicture(Range range, Picture picture, int rowIndex, int columnIndex)
Move a picture to specified row and column.- Parameters:
range
- a range represented the sheet that contains the picturepicture
- the picture to moverowIndex
- destination row index, 0-basedcolumnIndex
- destination column index, 0-based
-
deletePicture
public static void deletePicture(Range range, Picture picture)
Delete a picture- Parameters:
range
- a range that represents the sheet that contains the picturepicture
- the picture to delete
-
hasPicture
public static boolean hasPicture(Range range, Picture picture)
Returns whether the range of sheet has the picture- Parameters:
range
-picture
-- Returns:
- true if the range has, otherwise false
-
addChart
public static Chart addChart(Range range, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos)
Adds a chart to specified sheet range in pre-defined position and size.
Position: the same row as the specified range, 2 columns right to the specified range
Size: 7 rows, 7 columns- Parameters:
range
- the range of source datatype
- the chart typegrouping
- the grouping typepos
- the legend position type
-
addChart
public static Chart addChart(Range range, SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos)
Adds a chart at the specified location- Parameters:
range
- the range of source dataanchor
- the chart location on a sheettype
- the chart typegrouping
- the grouping typepos
- the legend position type
-
toChartAnchor
public static SheetAnchor toChartAnchor(Range range)
Create a anchor by range's row/column data- Parameters:
range
- the range for chart.- Returns:
- a new anchor
-
moveChart
public static void moveChart(Range range, Chart chart, int rowIndex, int columnIndex)
Move a chart to specified row and column.- Parameters:
range
- the range that represents the sheet contains the chart to move.chart
- the chart to moverowIndex
- destination row index, 0-based.columnIndex
- destination column index, 0-based.
-
deleteChart
public static void deleteChart(Range range, Chart chart)
Delete a chart if the specified Range has the specified chart.- Parameters:
range
- the range that represents the sheet contains the chart to delete.chart
- the chart to delete.
-
hasChart
public static boolean hasChart(Range range, Chart chart)
Returns whether the range of sheet has the chart.- Parameters:
range
-chart
-- Returns:
- true if the range has, otherwise false
-
protectSheet
public static void protectSheet(Range range, String password, boolean allowSelectingLockedCells, boolean allowSelectingUnlockedCells, boolean allowFormattingCells, boolean allowFormattingColumns, boolean allowFormattingRows, boolean allowInsertColumns, boolean allowInsertRows, boolean allowInsertingHyperlinks, boolean allowDeletingColumns, boolean allowDeletingRows, boolean allowSorting, boolean allowFiltering, boolean allowUsingPivotTables, boolean drawingObjects, boolean scenarios)
-
displaySheetGridlines
public static void displaySheetGridlines(Range range, boolean enable)
Enables/disables to show a sheet's gridlines.- Parameters:
range
- the sheet range to be appliedenable
- true for enable
-
addSheet
public static void addSheet(Range range, String prefix)
Add a new sheet to this book- Parameters:
range
- the range to be appliedprefix
- the sheet name prefix, it will produce a new name with this prefix and a counter.
-
createSheet
public static void createSheet(Range range, String name)
Add a new sheet as the last sheet to this book- Parameters:
range
- the Book to be appliedname
- the sheet name, it must not be the same as another sheet name in this book, otherwise it takes no effect.
-
renameSheet
public static void renameSheet(Range range, String newname)
Rename a sheet- Parameters:
range
- the sheet range to be appliednewname
- the new name of the sheet, it must not same as another sheet name in this book
-
setSheetOrder
public static void setSheetOrder(Range range, int pos)
Sets a sheet's position order, used to move a sheet- Parameters:
range
- the sheet range to be appliedpos
- the sheet position
-
deleteSheet
public static void deleteSheet(Range range)
Deletes the sheet, notice that it prevents you from deleting the last sheet- Parameters:
range
- the sheet range to be applied
-
copySheet
public static void copySheet(Range range)
Copy the sheet with the naming pattern "ORIGINAL_SHEET_NAME (n)".- Parameters:
range
- the sheet range to be applied
-
toFilledAnchor
public static SheetAnchor toFilledAnchor(Sheet sheet, int row, int column, int widthPx, int heightPx)
return aSheetAnchor
based on a cell and a picture width and height- Parameters:
sheet
- target sheet where the anchor locatesrow
- 0-based row indexcolumn
- 0-base column indexwidthPx
- a picture's width in pixelheightPx
- a picture's height in pixel- Returns:
- a
SheetAnchor
-
-