[]
IRange range = worksheet.getRange("A1:B2");
range.setValue(new Object[][] {{"Name", "Score"}, {"Alice", 95}});
range.getInterior().setColor(Color.GetLightYellow());
Object value = worksheet.getRange("B2").getValue();
voidactivate()addComment(String text) addCommentThreaded(String text) addCommentThreaded(String text,
String author) voidvoidautoFilter(boolean isFirstRowData) voidautoFilter(boolean isFirstRowData,
int field) voidautoFilter(boolean isFirstRowData,
int field,
Object criteria1) voidautoFilter(boolean isFirstRowData,
int field,
Object criteria1,
AutoFilterOperator op) voidautoFilter(boolean isFirstRowData,
int field,
Object criteria1,
AutoFilterOperator op,
Object criteria2) voidautoFilter(boolean isFirstRowData,
int field,
Object criteria1,
AutoFilterOperator op,
Object criteria2,
boolean visibleDropDown) voidautoFilter(int field) voidautoFilter(int field,
Object criteria1) voidautoFilter(int field,
Object criteria1,
AutoFilterOperator op) voidautoFilter(int field,
Object criteria1,
AutoFilterOperator op,
Object criteria2) voidautoFilter(int field,
Object criteria1,
AutoFilterOperator op,
Object criteria2,
boolean visibleDropDown) voidautoFit()voidautoFit(boolean considerMergedCell) voidcharacters(int startIndex,
int length) voidclear()voidvoidvoidvoidvoidvoidvoidvoidcopy(IRange destination,
PasteOption pasteOption) voidvoidvoiddelete()voiddelete(DeleteShiftDirection shiftDirection) voiddirty()find(Object what,
FindOptions options) find(Object what,
IRange after,
FindOptions options) voidgenerateGetPivotDataFunction(IRange destination) get(int index) IRange by index which represents a cell.get(int rowOffset,
int columnOffset) IRange which is offset from this range.booleangetAddress(boolean rowAbsolute,
boolean columnAbsolute) getAddress(boolean rowAbsolute,
boolean columnAbsolute,
ReferenceStyle referenceStyle) getAddress(boolean rowAbsolute,
boolean columnAbsolute,
ReferenceStyle referenceStyle,
IRange relativeTo) getAreas()IAreas which represents an array of ranges where each range returned by areas represents one cell or range.byte[]IBorders which represents the cell borders of the cell or range represented by this IRange.ICellControl object that represents the cell control of the current range.getCells()IRange object that represents the cells in the specified range.intintIRange object that represents the columns in the specified range.doubledoubleIComment which may be used to get and set Comment properties of the cells.intgetCount()IRange object that represents the entire array.getDependents(boolean includeIndirect) IRange which represents the same range of cells, but expanded to include all rows.IRange representing the area of the current range which is iteratively grown as needed until it includes no partial merged cells.IRange which represents the same range of cells, but expanded to include all columns.getFont()IFont which may be used to get and set font properties of the cells represented by this IRange.booleanbooleanbooleanbooleandoubledoublebooleanHorizontalAlignment of a cell or range.IHyperlinks which may be used to get and set HyperLinks properties.intIInterior which represents the interior (background)color and pattern of the specified cell(s).intintbooleanIRange representing the merged range containing the specified cell.booleanintintgetPrecedents(boolean includeInDirect) intgetRow()intdoubledoublegetRows()IRange object that represents the rows in the specified range.booleanbooleangetStyle()IStyle associated with the cells represented by this IRange.booleangetTag()getText()IRange representing the used range in the current range.getUsedRange(EnumSet<UsedRangeType> type) IRange representing the used range in the current range.booleanIRange object equals the standard height of the sheet.booleanIRange object equals the standard width of the sheet.IValidation which may be used to get and set validation properties of the cells represented by this IRange.booleanIRange are the same; otherwise, false is returned.getValue()Date, Object[][], or null.VerticalAlignment of a cell or range.doublegetWidth()doubleIWorksheet of this range.booleanbooleanvoidgroup()importData(Object items) importData(Object items,
DataImportOptions options) voidinsert()voidinsert(InsertShiftDirection shiftDirection) booleanvoidmerge()voidmerge(boolean isAcross) offset(int rowOffset,
int columnOffset) voidvoidintintreplace(Object what,
Object replacement,
ReplaceOptions options) voidselect()voidsetAddIndent(boolean value) voidsetBackgroundImage(byte[] backgroundImage) voidsetBackgroundImageLayout(BackgroundImageLayout backgroundImageLayout) voidsetBindingPath(String value) voidsetCellPadding(ICellPadding cellPadding) voidsetCellPicture(CellPicture picture) voidsetCellType(BaseCellType cellType) voidsetColumnWidth(double value) voidsetColumnWidthInPixel(double value) voidsetDecoration(ICellDecoration value) voidsetDefaultValue(Object value) voidsetFormula(String value) voidsetFormula2(String value) voidsetFormula2Local(String value) voidsetFormula2R1C1(String value) voidsetFormula2R1C1Local(String value) voidsetFormulaArray(String value) voidsetFormulaArrayR1C1(String value) voidsetFormulaHidden(boolean value) voidsetFormulaLocal(String value) voidsetFormulaR1C1(String value) voidsetFormulaR1C1Local(String value) voidsetHidden(boolean value) voidHorizontalAlignment of a cell or range.voidsetIgnoredError(EnumSet<IgnoredErrorType> value) voidsetIndentLevel(int value) voidsetLocked(boolean value) voidsetMergeCells(boolean value) voidsetNumberFormat(String value) voidsetOrientation(int value) voidsetOutlineLevel(int value) voidsetReadingOrder(ReadingOrder value) voidsetRowHeight(double value) voidsetRowHeightInPixel(double value) voidsetShowDetail(boolean value) voidsetShrinkToFit(boolean value) voidIStyle associated with the cells represented by this IRange.voidvoidsetUseStandardHeight(boolean value) IRange object equals the standard height of the sheet.voidsetUseStandardWidth(boolean value) IRange object equals the standard width of the sheet.voidvoidVerticalAlignment of a cell or range.voidsetWatermark(String watermark) voidsetWrapText(boolean value) voidsort(IRange key,
SortOrder order,
SortOrientation orientation) voidsort(IRange key,
SortOrder order,
SortOrientation orientation,
boolean caseSensitive) voidsort(SortOrientation orientation,
boolean caseSensitive,
IValueSortField... keys) specialCells(SpecialCellType type) specialCells(SpecialCellType type,
SpecialCellsValue value) voidsubtotal(int groupBy,
ConsolidationFunction subtotalFunction,
int[] totalList) voidsubtotal(int groupBy,
ConsolidationFunction subtotalFunction,
int[] totalList,
boolean replace) voidsubtotal(int groupBy,
ConsolidationFunction subtotalFunction,
int[] totalList,
boolean replace,
boolean pageBreaks) voidsubtotal(int groupBy,
ConsolidationFunction subtotalFunction,
int[] totalList,
boolean replace,
boolean pageBreaks,
SummaryRow summaryRowLocation) voidsubtotal(int groupBy,
ConsolidationFunction subtotalFunction,
int[] totalList,
SummaryRow summaryRowLocation) voidtoImage(OutputStream stream,
ImageType imageType) voidtoImage(OutputStream stream,
ImageType imageType,
ImageSaveOptions options) voidvoidtoImage(String imageFile,
ImageSaveOptions options) toJson()voidungroup()voidunmerge()IRange object that represents the rows in the specified range.
IRange range = worksheet.getRange("B2:C3");
IRange rows = range.getRows();
int rowCount = rows.getCount();
IRange object that represents the rows in the specified range.IRange object that represents the columns in the specified range.
IRange range = worksheet.getRange("B2:C3");
IRange columns = range.getColumns();
int columnCount = columns.getCount();
IRange object that represents the columns in the specified range.IRange object that represents the cells in the specified range.
IRange range = worksheet.getRange("B2:C3");
IRange cells = range.getCells();
int cellCount = cells.getCount();
IRange object that represents the cells in the specified range.
IRange range = worksheet.getRange("B2:C3");
int row = range.getRow();
IRange range = worksheet.getRange("B2:C3");
int lastRow = range.getLastRow();
IRange range = worksheet.getRange("B2:C3");
int rowCount = range.getRowCount();
IRange range = worksheet.getRange("B2:C3");
int column = range.getColumn();
IRange range = worksheet.getRange("B2:C3");
int lastColumn = range.getLastColumn();
IRange range = worksheet.getRange("B2:C3");
int columnCount = range.getColumnCount();
IRange range = worksheet.getRange("B2:C3");
int count = range.getCount();
IFont which may be used to get and set font properties of the cells represented by this IRange.
IRange range = worksheet.getRange("A1");
IFont font = range.getFont();
font.setBold(true);
boolean bold = range.getFont().getBold();
IBorders which represents the cell borders of the cell or range represented by this IRange.
IRange range = worksheet.getRange("A1");
IBorder border = range.getBorders().get(BordersIndex.EdgeBottom);
border.setLineStyle(BorderLineStyle.Thin);
BorderLineStyle style = border.getLineStyle();
IInterior which represents the interior (background)color and pattern of the specified cell(s).
IRange range = worksheet.getRange("A1");
IInterior interior = range.getInterior();
interior.setColor(Color.GetLightYellow());
Color color = range.getInterior().getColor();
IInterior object that represents the interior (background) color and pattern of the specified cell(s).
IRange range = worksheet.getRange("A1");
range.setNumberFormat("$#,##0.00");
String numberFormat = range.getNumberFormat();
IRange range = worksheet.getRange("A1");
range.setValue(1234.5);
range.setNumberFormat("$#,##0.00");
String text = range.getText();
value - The number format of the cells in the range.
IRange range = worksheet.getRange("A1");
range.setHorizontalAlignment(HorizontalAlignment.Distributed);
range.setAddIndent(true);
boolean addIndent = range.getAddIndent();
IRange range = worksheet.getRange("A1");
range.setHorizontalAlignment(HorizontalAlignment.Distributed);
range.setAddIndent(true);
boolean addIndent = range.getAddIndent();
value - The property value that controls indentation of text when horizontal or vertical alignment is set to distributed.
IRange range = worksheet.getRange("A1");
range.setIndentLevel(2);
int indentLevel = range.getIndentLevel();
IRange range = worksheet.getRange("A1");
range.setValue("Indented");
range.setIndentLevel(2);
int indentLevel = range.getIndentLevel();
value - The indent level of the specified cell(s).
IRange row = worksheet.getRange("2:2");
row.setHidden(true);
boolean hidden = row.getHidden();
IRange row = worksheet.getRange("2:2");
row.setHidden(true);
boolean hidden = row.getHidden();
value - Whether rows or columns should be hidden.
IRange range = worksheet.getRange("A1");
range.setLocked(false);
worksheet.protect();
boolean locked = range.getLocked();
IRange range = worksheet.getRange("A1");
range.setLocked(false);
worksheet.protect();
boolean locked = range.getLocked();
value - Whether cells should be locked.
IRange range = worksheet.getRange("A1");
range.setValue("Rotated");
range.setOrientation(45);
int orientation = range.getOrientation();
IRange range = worksheet.getRange("A1");
range.setValue("Rotated");
range.setOrientation(45);
int orientation = range.getOrientation();
value - The text orientation of a cell or range, which may be from -90 to 90 degrees, or 255(vertical text).
IRange range = worksheet.getRange("A1");
range.setValue("Long text");
range.setShrinkToFit(true);
boolean shrinkToFit = range.getShrinkToFit();
IRange range = worksheet.getRange("A1");
range.setValue("Long text");
range.setShrinkToFit(true);
boolean shrinkToFit = range.getShrinkToFit();
value - Whether cells will be drawn in a smaller font if needed to display the contents of the cell.
IRange range = worksheet.getRange("A1");
range.setValue("Line 1\nLine 2");
range.setWrapText(true);
boolean wrapText = range.getWrapText();
IRange range = worksheet.getRange("A1");
range.setValue("Line 1\nLine 2");
range.setWrapText(true);
boolean wrapText = range.getWrapText();
value - Whether word wrap is enabled in a cell.HorizontalAlignment of a cell or range.
IRange range = worksheet.getRange("A1:C1");
range.setValue("Quarterly Report");
range.setHorizontalAlignment(HorizontalAlignment.Center);
HorizontalAlignment alignment = range.getHorizontalAlignment();
HorizontalAlignment of a cell or range.HorizontalAlignment of a cell or range.
IRange range = worksheet.getRange("A1:C1");
range.setValue("Quarterly Report");
range.setHorizontalAlignment(HorizontalAlignment.Center);
HorizontalAlignment alignment = range.getHorizontalAlignment();
value - The HorizontalAlignment of a cell or range.VerticalAlignment of a cell or range.
IRange range = worksheet.getRange("A1");
range.setVerticalAlignment(VerticalAlignment.Center);
VerticalAlignment alignment = range.getVerticalAlignment();
VerticalAlignment of a cell or range.VerticalAlignment of a cell or range.
IRange range = worksheet.getRange("A1");
range.setValue("Centered");
range.setVerticalAlignment(VerticalAlignment.Center);
VerticalAlignment alignment = range.getVerticalAlignment();
value - The VerticalAlignment of a cell or range.
IRange range = worksheet.getRange("A1");
range.getInterior().setColor(Color.GetLightYellow());
IDisplayFormat displayFormat = range.getDisplayFormat();
Color color = displayFormat.getInterior().getColor();
IRange range = worksheet.getRange("A1");
range.setFormula("=1+1");
range.setFormulaHidden(true);
boolean formulaHidden = range.getFormulaHidden();
IRange range = worksheet.getRange("A1");
range.setFormula("=1+1");
range.setFormulaHidden(true);
boolean formulaHidden = range.getFormulaHidden();
value - Whether the formula will be hidden when the worksheet is protected.
IRange range = worksheet.getRange("A1");
range.setReadingOrder(ReadingOrder.RightToLeft);
ReadingOrder readingOrder = range.getReadingOrder();
IRange range = worksheet.getRange("A1");
range.setValue("שלום");
range.setReadingOrder(ReadingOrder.RightToLeft);
ReadingOrder readingOrder = range.getReadingOrder();
value - The reading order for the specified object.IStyle associated with the cells represented by this IRange.
IStyle style = workbook.getStyles().add("InputStyle");
style.getFont().setBold(true);
IRange range = worksheet.getRange("A1");
range.setStyle(style);
IStyle appliedStyle = range.getStyle();
IStyle associated with the cells represented by this IRange.
IStyle style = workbook.getStyles().add("InputStyle");
style.getFont().setBold(true);
IRange range = worksheet.getRange("A1");
range.setStyle(style);
IStyle appliedStyle = range.getStyle();
value - The named style IStyle associated with the cells represented by this IRange.IValidation which may be used to get and set validation properties of the cells represented by this IRange.
IRange range = worksheet.getRange("A1");
IValidation validation = range.getValidation();
validation.add(ValidationType.Whole, ValidationAlertStyle.Stop, ValidationOperator.Between, 1, 10);
boolean hasValidation = range.getHasValidation();
IValidation and IRange.IHyperlinks which may be used to get and set HyperLinks properties.
IRange range = worksheet.getRange("A1");
IHyperlinks hyperlinks = range.getHyperlinks();
hyperlinks.add(range, "https://www.example.com");
int hyperlinkCount = hyperlinks.getCount();
IHyperlinks which may be used to get and set HyperLinks properties.IComment which may be used to get and set Comment properties of the cells.
IRange range = worksheet.getRange("A1");
range.addComment("Review this value.");
IComment comment = range.getComment();
String text = comment.getText();
IComment.
worksheet.getRange("A1:A3").setValue(new Object[][] {{1}, {2}, {3}});
IRange location = worksheet.getRange("B1:B3");
ISparklineGroups sparklineGroups = location.getSparklineGroups();
sparklineGroups.add(SparkType.Line, "A1:A3");
int groupCount = sparklineGroups.getCount();
ISparklineGroups.IWorksheet of this range.
IRange range = worksheet.getRange("A1");
IWorksheet parentWorksheet = range.getWorksheet();
String sheetName = parentWorksheet.getName();
IRange which represents the same range of cells, but expanded to include all columns.
IRange range = worksheet.getRange("B2:C3");
IRange entireRow = range.getEntireRow();
int columnCount = entireRow.getColumnCount();
IRange.IRange which represents the same range of cells, but expanded to include all rows.
IRange range = worksheet.getRange("B2:C3");
IRange entireColumn = range.getEntireColumn();
int rowCount = entireColumn.getRowCount();
IRange.IRange representing the area of the current range which is iteratively grown as needed until it includes no partial merged cells.
worksheet.getRange("A1:B2").merge();
IRange mergeArea = worksheet.getRange("A1").getEntireMergeArea();
int rowCount = mergeArea.getRowCount();
IRange.IRange representing the merged range containing the specified cell. If the specified cell isn't in a merged range, this property returns the specified cell.
worksheet.getRange("A1:B2").merge();
IRange mergeArea = worksheet.getRange("A1").getMergeArea();
String address = mergeArea.getAddress();
IRange representing the merged range containing the specified cell.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormula("=A1+A2");
String formula = range.getFormula();
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormula("=A1+A2");
workbook.calculate();
Object value = range.getValue();
value - The formula of the cells represented by this range in A1-style notation.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaLocal("=A1+A2");
String formula = range.getFormulaLocal();
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaLocal("=A1+A2");
workbook.calculate();
Object value = range.getValue();
value - The localized formula of the cells represented by this range in A1-style notation.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaR1C1("=RC[-1]+R[1]C[-1]");
String formula = range.getFormulaR1C1();
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaR1C1("=RC[-1]+R[1]C[-1]");
workbook.calculate();
Object value = range.getValue();
value - The formula of the cells represented by this range in R1C1-style notation.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaR1C1Local("=RC[-1]+R[1]C[-1]");
String formula = range.getFormulaR1C1Local();
worksheet.getRange("A1").setValue(10);
worksheet.getRange("A2").setValue(5);
IRange range = worksheet.getRange("B1");
range.setFormulaR1C1Local("=RC[-1]+R[1]C[-1]");
workbook.calculate();
Object value = range.getValue();
value - The localized formula of the cells represented by this range in R1C1-style notation.
IRange range = worksheet.getRange("A1:A3");
range.setFormula2("=SEQUENCE(3)");
String formula = range.getFormula2();
IRange range = worksheet.getRange("A1:A3");
range.setFormula2("=SEQUENCE(3)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The formula of the cells represented by this range in A1-style array notation.
IRange range = worksheet.getRange("A1:A3");
range.setFormula2Local("=SEQUENCE(3)");
String formula = range.getFormula2Local();
IRange range = worksheet.getRange("A1:A3");
range.setFormula2Local("=SEQUENCE(3)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The localized formula of the cells represented by this range in A1-style array notation.
IRange range = worksheet.getRange("A1:A3");
range.setFormula2R1C1("=SEQUENCE(3)");
String formula = range.getFormula2R1C1();
IRange range = worksheet.getRange("A1:A3");
range.setFormula2R1C1("=SEQUENCE(3)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The formula of the cells represented by this range in R1C1-style array notation.
IRange range = worksheet.getRange("A1:A3");
range.setFormula2R1C1Local("=SEQUENCE(3)");
String formula = range.getFormula2R1C1Local();
IRange range = worksheet.getRange("A1:A3");
range.setFormula2R1C1Local("=SEQUENCE(3)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The localized formula of the cells represented by this range in R1C1-style array notation.
IRange range = worksheet.getRange("A1:A3");
range.setFormulaArray("=ROW(A1:A3)");
String formula = range.getFormulaArray();
IRange range = worksheet.getRange("A1:A3");
range.setFormulaArray("=ROW(A1:A3)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The array formula of a range.
IRange range = worksheet.getRange("A1:A3");
range.setFormulaArrayR1C1("=ROW(R1C1:R3C1)");
String formula = range.getFormulaArrayR1C1();
IRange range = worksheet.getRange("A1:A3");
range.setFormulaArrayR1C1("=ROW(R1C1:R3C1)");
workbook.calculate();
Object value = worksheet.getRange("A1").getValue();
value - The array formula of a range using ReferenceStyle.R1C1.IRange object that represents the entire array.
IRange arrayRange = worksheet.getRange("A1:A3");
arrayRange.setFormulaArray("=ROW(A1:A3)");
IRange currentArray = worksheet.getRange("A2").getCurrentArray();
String address = currentArray.getAddress();
IRange range = worksheet.getRange("A1");
range.setFormula("=1+1");
boolean hasFormula = range.getHasFormula();
IRange range = worksheet.getRange("A1:A3");
range.setFormulaArray("=ROW(A1:A3)");
boolean hasArray = worksheet.getRange("A1").getHasArray();
Date, Object[][], or null.
IRange range = worksheet.getRange("A1");
range.setValue("Ready");
Object value = range.getValue();
Date, Object[][], or null.value - The EnumSet of IgnoredErrorType.
IRange range = worksheet.getRange("A1");
range.setValue("\'123");
range.setIgnoredError(EnumSet.of(IgnoredErrorType.NumberAsText));
EnumSet<IgnoredErrorType> ignoredErrors = range.getIgnoredError();
IgnoredErrorType.
IRange range = worksheet.getRange("A1");
range.setValue("\'123");
range.setIgnoredError(EnumSet.of(IgnoredErrorType.NumberAsText));
EnumSet<IgnoredErrorType> ignoredErrors = range.getIgnoredError();
IRange range = worksheet.getRange("A1");
range.setTag("customer-id");
Object tag = range.getTag();
IRange range = worksheet.getRange("A1");
range.setTag("customer-id");
Object tag = range.getTag();
value - The tag value of the specified range in the sheet.
ButtonCellType button = new ButtonCellType();
button.setText("Submit");
IRange range = worksheet.getRange("A1");
range.setCellType(button);
BaseCellType cellType = range.getCellType();
ButtonCellType button = new ButtonCellType();
button.setText("Submit");
IRange range = worksheet.getRange("A1");
range.setCellType(button);
BaseCellType cellType = range.getCellType();
cellType - The cell type for specified range in the sheet.ICellControl object that represents the cell control of the current range.
IRange range = worksheet.getRange("A1:A3");
range.getCellControl().setCheckbox();
ICellControl cellControl = range.getCellControl();
CellControlType controlType = cellControl.getType();
For a regular range, this method returns the binding path of the top-left cell. For an entire column range, it returns the binding path of the leftmost column. For an entire row range, it returns null.
IRange range = worksheet.getRange("A1");
range.setBindingPath("Customer.Name");
String bindingPath = range.getBindingPath();
For a regular range, this method sets the binding path of the top-left cell. For an entire column range, it sets the binding path of the leftmost column. For an entire row range, this method does nothing.
IRange range = worksheet.getRange("A1");
range.setBindingPath("Customer.Name");
String bindingPath = range.getBindingPath();
value - The binding path of the current cell or column. For a regular range, sets the binding path of the top-left cell. For an entire column range, sets the binding path of the leftmost column. For an entire row range, does nothing.
IRange range = worksheet.getRange("A1");
range.setValue(1234.5);
range.setNumberFormat("$#,##0.00");
String text = range.getText();
IAreas which represents an array of ranges where each range returned by areas represents one cell or range.
IRange range = worksheet.getRange("A1,C3");
IAreas areas = range.getAreas();
int areaCount = areas.getAreaCount();
IAreas.IRange representing the used range in the current range.
worksheet.getRange("B2").setValue("Used cell");
IRange usedRange = worksheet.getRange("A1:C5").getUsedRange();
String address = usedRange.getAddress();
IRange representing the used range in the current range.IRange representing the used range in the current range.
worksheet.getRange("B2").setValue("Used cell");
worksheet.getRange("C3").getInterior().setColor(Color.GetYellow());
IRange usedRange = worksheet.getRange("A1:C5").getUsedRange(EnumSet.of(UsedRangeType.Data));
String address = usedRange.getAddress();
type - The feature type.IRange representing the used range in the current range.IRange which is offset from this range.rowOffset - The row offset.columnOffset - The column offset.
IRange range = worksheet.getRange("B2:C3");
IRange cell = range.get(1, 1);
cell.setValue("C3");
Object value = worksheet.getRange("C3").getValue();
IRange by index which represents a cell.index - The index of the range.
IRange range = worksheet.getRange("B2:C3");
IRange cell = range.get(2);
cell.setValue("Selected cell");
Object value = cell.getValue();
IRange range = worksheet.getRange("A1:B2");
range.merge();
boolean mergeCells = range.getMergeCells();
IRange range = worksheet.getRange("A1:B2");
range.setMergeCells(true);
boolean mergeCells = range.getMergeCells();
value - Whether cells are merged.
IRange range = worksheet.getRange("A1:B2");
range.merge();
boolean mergeCells = range.getMergeCells();
isAcross - Optional Object. True to merge cells in each row of the specified range as separate merged cells. The default value is False.
IRange range = worksheet.getRange("A1:B2");
range.merge(true);
boolean firstRowMerged = worksheet.getRange("A1:B1").getMergeCells();
IRange range = worksheet.getRange("A1:B2");
range.merge();
range.unmerge();
boolean mergeCells = range.getMergeCells();
worksheet.getRange("A1").setValue("First");
worksheet.getRange("A1").insert();
Object value = worksheet.getRange("A2").getValue();
shiftDirection - Specifies which way to shift the cells.
worksheet.getRange("A1").setValue("First");
worksheet.getRange("A1").insert(InsertShiftDirection.Down);
Object value = worksheet.getRange("A2").getValue();
worksheet.getRange("A1").setValue("Delete me");
worksheet.getRange("A2").setValue("Keep me");
worksheet.getRange("A1").delete();
Object value = worksheet.getRange("A1").getValue();
shiftDirection - Specifies which way to shift the cells.
worksheet.getRange("A1").setValue("Delete me");
worksheet.getRange("A2").setValue("Keep me");
worksheet.getRange("A1").delete(DeleteShiftDirection.Up);
Object value = worksheet.getRange("A1").getValue();
IRange range = worksheet.getRange("A1");
range.setValue("Clear me");
range.getInterior().setColor(Color.GetYellow());
range.clear();
Object value = range.getValue();
IRange range = worksheet.getRange("A1");
range.setValue("Clear me");
range.getInterior().setColor(Color.GetYellow());
range.clearContents();
Object value = range.getValue();
IRange range = worksheet.getRange("A1");
range.setValue("Keep value");
range.getInterior().setColor(Color.GetYellow());
range.clearFormats();
Object value = range.getValue();
IRange range = worksheet.getRange("A1");
range.getHyperlinks().add(range, "https://www.example.com");
range.clearHyperlinks();
int hyperlinkCount = range.getHyperlinks().getCount();
IRange range = worksheet.getRange("A1");
range.addComment("Review this value.");
range.clearComments();
IComment comment = range.getComment();
IRange range = worksheet.getRange("A1");
range.addCommentThreaded("Review this value.", "Alex");
range.clearCommentsThreaded();
ICommentThreaded comment = range.getCommentThreaded();
IRange range = worksheet.getRange("A1");
range.getCellControl().setCheckbox();
range.removeControls();
CellControlType controlType = range.getCellControl().getType();
text - The text you want to add.IComment object.
IRange range = worksheet.getRange("A1");
IComment comment = range.addComment("Review this value.");
String text = comment.getText();
orientation - The orientation.caseSensitive - if set to true, case sensitive.keys - The IValueSortField array.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
ValueSortField key = new ValueSortField(worksheet.getRange("B2:B4"));
worksheet.getRange("A2:B4").sort(SortOrientation.Columns, false, key);
Object firstScore = worksheet.getRange("B2").getValue();
key - The key of the sort column.order - The sort order, ascending or descendingorientation - The orientation.caseSensitive - if set to true, case sensitive.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").sort(worksheet.getRange("B2:B4"), SortOrder.Ascending, SortOrientation.Columns, false);
Object firstScore = worksheet.getRange("B2").getValue();
key - The key of the sort column.order - The sort order, ascending or dscendingorientation - The orientation.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").sort(worksheet.getRange("B2:B4"), SortOrder.Ascending, SortOrientation.Columns);
Object firstScore = worksheet.getRange("B2").getValue();
field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperatorcriteria2 - Optional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.visibleDropDown - Optional Object. True to display the AutoFilter drop-down arrow for the filtered field; False to hide the AutoFilter drop-down arrow for the filtered field. True by default.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter(1, ">=80", AutoFilterOperator.And, "<=100", true);
boolean hidden = worksheet.getRange("3:3").getHidden();
field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter(1);
IRange filterRange = worksheet.getAutoFilter().getRange();
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter();
IRange filterRange = worksheet.getAutoFilter().getRange();
field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter(1, ">=90");
boolean hidden = worksheet.getRange("3:3").getHidden();
field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperator
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter(1, "2", AutoFilterOperator.Top10Items);
IRange filterRange = worksheet.getAutoFilter().getRange();
field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperatorcriteria2 - Optional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A1:B4").autoFilter(1, ">=80", AutoFilterOperator.And, "<=100");
boolean hidden = worksheet.getRange("3:3").getHidden();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperatorcriteria2 - Optional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.visibleDropDown - Optional Object. True to display the AutoFilter drop-down arrow for the filtered field; False to hide the AutoFilter drop-down arrow for the filtered field. True by default.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true, 1, ">=80", AutoFilterOperator.And, "<=100", true);
IRange filterRange = worksheet.getAutoFilter().getRange();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true);
IRange filterRange = worksheet.getAutoFilter().getRange();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true, 1);
IRange filterRange = worksheet.getAutoFilter().getRange();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true, 1, ">=90");
IRange filterRange = worksheet.getAutoFilter().getRange();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperator
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true, 1, "2", AutoFilterOperator.Top10Items);
IRange filterRange = worksheet.getAutoFilter().getRange();
isFirstRowData - Indicates whether the first row of the selection area participates in filtering. When set to true, the behavior is consistent with SpreadJS; when false, it is consistent with Microsoft Excel.field - Optional Object. The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field zero).criteria1 - Optional Object. The criteria (a string; for example,"101"). Use "=" to find blank fields, or use " <> " to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is AutoFilterOperator.Top10Items, Criteria1 specifies the number of items (for example, "10").op - Optional AutoFilterOperatorcriteria2 - Optional Object. The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.getRange("A2:B4").autoFilter(true, 1, ">=80", AutoFilterOperator.And, "<=100");
IRange filterRange = worksheet.getAutoFilter().getRange();
IRange range = worksheet.getRange("A1:B1");
double width = range.getWidth();
IRange range = worksheet.getRange("A1:B1");
double widthInPixel = range.getWidthInPixel();
IRange range = worksheet.getRange("A:A");
range.setColumnWidth(20);
double columnWidth = range.getColumnWidth();
IRange range = worksheet.getRange("A:A");
range.setColumnWidth(20);
double columnWidth = range.getColumnWidth();
value - The width of the individual columns represented in this range in characters.
IRange range = worksheet.getRange("A:A");
range.setColumnWidthInPixel(120);
double columnWidthInPixel = range.getColumnWidthInPixel();
IRange range = worksheet.getRange("A:A");
range.setColumnWidthInPixel(120);
double columnWidthInPixel = range.getColumnWidthInPixel();
value - The width of the individual columns represented in this range in pixels.
IRange range = worksheet.getRange("1:2");
double height = range.getHeight();
IRange range = worksheet.getRange("1:2");
double heightInPixel = range.getHeightInPixel();
IRange range = worksheet.getRange("1:1");
range.setRowHeight(30);
double rowHeight = range.getRowHeight();
IRange range = worksheet.getRange("1:1");
range.setRowHeight(30);
double rowHeight = range.getRowHeight();
value - The height of the individual rows represented by this range in points.
IRange range = worksheet.getRange("1:1");
range.setRowHeightInPixel(40);
double rowHeightInPixel = range.getRowHeightInPixel();
IRange range = worksheet.getRange("1:1");
range.setRowHeightInPixel(40);
double rowHeightInPixel = range.getRowHeightInPixel();
value - The height of the individual rows represented by this range in pixels.
IRange range = worksheet.getRange("A1:A3");
IFormatConditions conditions = range.getFormatConditions();
conditions.addAboveAverage();
int count = conditions.getCount();
worksheet.getRange("2:4").group();
IRange range = worksheet.getRange("2:4");
range.clearOutline();
int outlineLevel = range.getOutlineLevel();
IRange range = worksheet.getRange("2:4");
range.group();
int outlineLevel = range.getOutlineLevel();
worksheet.getRange("2:4").group();
IRange range = worksheet.getRange("2:4");
range.ungroup();
int outlineLevel = range.getOutlineLevel();
worksheet.getRange("2:4").group();
IRange range = worksheet.getRange("2:4");
int outlineLevel = range.getOutlineLevel();
IRange range = worksheet.getRange("2:4");
range.setOutlineLevel(2);
int outlineLevel = range.getOutlineLevel();
value - The current outline level of the specified row or column.
The following statements are true: 1.The range must be in a single summary row or column. 2.This property returns False if any of the children of the row or column are hidden. 3.Setting this property to True is equivalent to unhiding all the children of the summary row or column. 4.Setting this property to False is equivalent to hiding all the children of the summary row or column.
worksheet.getRange("2:4").group();
IRange summaryRow = worksheet.getRange("5:5");
boolean showDetail = summaryRow.getShowDetail();
The following statements are true: 1.The range must be in a single summary row or column. 2.This property returns False if any of the children of the row or column are hidden. 3.Setting this property to True is equivalent to unhiding all the children of the summary row or column. 4.Setting this property to False is equivalent to hiding all the children of the summary row or column.
worksheet.getRange("2:4").group();
IRange summaryRow = worksheet.getRange("5:5");
summaryRow.setShowDetail(false);
boolean hidden = worksheet.getRange("2:2").getHidden();
value - Whether to show the detail (True if the outline is expanded for the specified range, so that the detail of the column or row is visible). The specified range must be a single summary column or row in an outline.
worksheet.getRange("2:4").group();
boolean summary = worksheet.getRange("5:5").getSummary();
worksheet.getRange("B2").select();
worksheet.getRange("B2").activate();
IRange activeCell = worksheet.getActiveCell();
IRange range = worksheet.getRange("A1:B2");
range.select();
IRange selection = worksheet.getSelection();
worksheet.getRange("A1").setValue("Copy me");
worksheet.getRange("A1").copy(worksheet.getRange("B1"));
Object value = worksheet.getRange("B1").getValue();
destination - The destination range.copy(IRange,PasteOption) overload instead.destination - Specifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.pasteType - Specifies the part of the range to be pasted.destination - Specifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.pasteOption - Specifies the part of the range to be pasted and whether to include hidden range.
worksheet.getRange("A1").setFormula("=1+1");
PasteOption option = new PasteOption();
option.setPasteType(EnumSet.of(PasteType.Values));
worksheet.getRange("A1").copy(worksheet.getRange("B1"), option);
Object value = worksheet.getRange("B1").getValue();
destination - Specifies the new range to which the specified range will be pasted. It can be the range of the same or another workbook.
worksheet.getRange("A1").setValue("Move me");
worksheet.getRange("A1").cut(worksheet.getRange("B1"));
Object value = worksheet.getRange("B1").getValue();
IRange range = worksheet.getRange("A1");
range.getValidation().add(ValidationType.Whole, ValidationAlertStyle.Stop, ValidationOperator.Between, 1, 10);
boolean hasValidation = range.getHasValidation();
IRange are the same; otherwise, false is returned.
IRange range = worksheet.getRange("A1:A2");
range.getValidation().add(ValidationType.Whole, ValidationAlertStyle.Stop, ValidationOperator.Between, 1, 10);
boolean validationIsSame = range.getValidationIsSame();
IRange object equals the standard height of the sheet.
IRange row = worksheet.getRange("1:1");
row.setUseStandardHeight(true);
boolean useStandardHeight = row.getUseStandardHeight();
IRange object equals the standard height of the sheet.
IRange row = worksheet.getRange("1:1");
row.setRowHeight(30);
row.setUseStandardHeight(true);
boolean useStandardHeight = row.getUseStandardHeight();
value - Whether the row height of the IRange object equals the standard height of the sheet.IRange object equals the standard width of the sheet.
IRange column = worksheet.getRange("A:A");
column.setUseStandardWidth(true);
boolean useStandardWidth = column.getUseStandardWidth();
IRange object equals the standard width of the sheet.
IRange column = worksheet.getRange("A:A");
column.setColumnWidth(20);
column.setUseStandardWidth(true);
boolean useStandardWidth = column.getUseStandardWidth();
value - Whether the column width of the IRange object equals the standard width of the sheet.
worksheet.getRange("A1").setValue(10);
IRange formulaCell = worksheet.getRange("B1");
formulaCell.setFormula("=A1*2");
formulaCell.calculate();
Object value = formulaCell.getValue();
IRange formulaCell = worksheet.getRange("B1");
worksheet.getRange("A1").setValue(10);
formulaCell.setFormula("=A1*2");
formulaCell.dirty();
formulaCell.calculate();
Object value = formulaCell.getValue();
IRichText richText = worksheet.getRange("A1").getRichText();
richText.add("Document ").getFont().setBold(true);
richText.add("Solutions");
boolean richTextCell = worksheet.getRange("A1").isRichText();
IRichText richText = worksheet.getRange("A1").getRichText();
richText.add("Document ").getFont().setBold(true);
richText.add("Solutions");
String plainText = richText.getPlainText();
worksheet.getRange("A1").setValue("Document Solutions");
ITextRun run = worksheet.getRange("A1").characters(1, 8);
run.getFont().setBold(true);
String text = run.getText();
startIndex - The one-based index of the first character.length - The number of characters to return.what - The data to search for. Can be a String, double, Date, Calendar, boolean or int.after - The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Notice that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you do not specify this argument, the search starts at the cell in the upper-left corner of the range when FindOptions.SearchDirection is SearchDirection.Next, or at the cell in the bottom-right corner of the range when FindOptions.SearchDirection is SearchDirection.Previous.options - The find options
worksheet.getRange("A1:A3").setValue(new Object[][] {{"Alpha"}, {"Beta"}, {"Gamma"}});
FindOptions options = new FindOptions();
options.setLookAt(LookAt.Whole);
IRange found = worksheet.getRange("A1:A3").find("Beta", worksheet.getRange("A1"), options);
what - The data to search for. Can be a String, double, Date, LocalDateTime, Calendar, boolean or int.after - The cell after which you want the search to begin. This corresponds to the position of the active cell when a search is done from the user interface. Notice that After must be a single cell in the range. Remember that the search begins after this cell; the specified cell isn't searched until the method wraps back around to this cell. If you do not specify this argument, the search starts at the cell in the upper-left corner of the range when FindOptions.SearchDirection is SearchDirection.Next, or at the cell in the bottom-right corner of the range when FindOptions.SearchDirection is SearchDirection.Previous.
worksheet.getRange("A1:A3").setValue(new Object[][] {{"Alpha"}, {"Beta"}, {"Gamma"}});
IRange found = worksheet.getRange("A1:A3").find("Beta", worksheet.getRange("A1"));
what - The data to search for. Can be a String, double, Date, LocalDateTime, Calendar, boolean or int.
worksheet.getRange("A1:A3").setValue(new Object[][] {{"Alpha"}, {"Beta"}, {"Gamma"}});
IRange found = worksheet.getRange("A1:A3").find("Beta");
what - The data to search for. Can be a String, double, Date, LocalDateTime, Calendar, boolean or int.options - The find options
worksheet.getRange("A1:A3").setValue(new Object[][] {{"Alpha"}, {"Beta"}, {"Gamma"}});
FindOptions options = new FindOptions();
options.setLookAt(LookAt.Whole);
IRange found = worksheet.getRange("A1:A3").find("Beta", options);
what - The string you want to search for.replacement - The replacement string.
worksheet.getRange("A1:A2").setValue(new Object[][] {{"North"}, {"North"}});
int replacedCount = worksheet.getRange("A1:A2").replace("North", "East");
Object value = worksheet.getRange("A1").getValue();
what - The string you want to search for.replacement - The replacement string.options - The replace options.
worksheet.getRange("A1:A2").setValue(new Object[][] {{"North"}, {"north"}});
ReplaceOptions options = new ReplaceOptions();
options.setMatchCase(true);
int replacedCount = worksheet.getRange("A1:A2").replace("North", "East", options);
IRange range = worksheet.getRange("A:A");
worksheet.getRange("A1").setValue("Long text for autofit");
range.autoFit();
double width = range.getColumnWidth();
considerMergedCell - Indicates whether to consider merged cells in a single row.
IRange range = worksheet.getRange("A1:B1");
range.merge();
range.setValue("Long merged text for autofit");
range.autoFit(true);
double height = range.getRowHeight();
groupBy - The field to group by, as a one-based integer offset.subtotalFunction - The subtotal function.totalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added.
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
worksheet.getRange("A1:B4").subtotal(1, ConsolidationFunction.Sum, new int[] {2});
Object subtotalLabel = worksheet.getRange("A4").getValue();
groupBy - The field to group by, as a one-based integer offset.subtotalFunction - The subtotal function.totalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added.replace - True to replace existing subtotals. The default value is True.
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
worksheet.getRange("A1:B4").subtotal(1, ConsolidationFunction.Sum, new int[] {2}, true);
Object subtotalLabel = worksheet.getRange("A4").getValue();
groupBy - The field to group by, as a one-based integer offset.subtotalFunction - The subtotal function.totalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added.replace - True to replace existing subtotals. The default value is True.pageBreaks - True to add page breaks after each group. The default value is False.
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
worksheet.getRange("A1:B4").subtotal(1, ConsolidationFunction.Sum, new int[] {2}, true, false);
Object subtotalLabel = worksheet.getRange("A4").getValue();
groupBy - The field to group by, as a one-based integer offset.subtotalFunction - The subtotal function.totalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added.summaryRowLocation - Places the summary data relative to the subtotal. The default value is Below.
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
worksheet.getRange("A1:B4").subtotal(1, ConsolidationFunction.Sum, new int[] {2}, SummaryRow.Below);
Object subtotalLabel = worksheet.getRange("A4").getValue();
groupBy - The field to group by, as a one-based integer offset.subtotalFunction - The subtotal function.totalList - An array of 1-based field offsets, indicating the fields to which the subtotals are added.replace - True to replace existing subtotals. The default value is True.pageBreaks - True to add page breaks after each group. The default value is False.summaryRowLocation - Places the summary data relative to the subtotal. The default value is Below.
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
worksheet.getRange("A1:B4").subtotal(1, ConsolidationFunction.Sum, new int[] {2}, true, false, SummaryRow.Below);
Object subtotalLabel = worksheet.getRange("A4").getValue();
worksheet.getRange("A1:B4").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}});
IRange range = worksheet.getRange("A1:B4");
range.subtotal(1, ConsolidationFunction.Sum, new int[] {2});
range.removeSubtotal();
Object value = worksheet.getRange("A4").getValue();
worksheet.getRange("A1").setValue(10);
worksheet.getRange("B1").setFormula("=A1*2");
List<IRange> precedents = worksheet.getRange("B1").getPrecedents();
includeInDirect - Indicates whether to include indirect precedents.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("B1").setFormula("=A1*2");
List<IRange> precedents = worksheet.getRange("B1").getPrecedents(true);
worksheet.getRange("A1").setValue(10);
worksheet.getRange("B1").setFormula("=A1*2");
List<IRange> dependents = worksheet.getRange("A1").getDependents();
includeIndirect - Include the indirect dependent cells.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("B1").setFormula("=A1*2");
List<IRange> dependents = worksheet.getRange("A1").getDependents(true);
imageFile - The output image file.
worksheet.getRange("A1").setValue("Exported");
worksheet.getRange("A1:B2").toImage("path/to/range.png");
imageFile - The output image file.options - The options for output image.
worksheet.getRange("A1").setValue("Exported");
ImageSaveOptions options = new ImageSaveOptions();
options.setShowGridlines(true);
worksheet.getRange("A1:B2").toImage("path/to/range.png", options);
stream - The output image stream.imageType - Specifies the type of image to create.
worksheet.getRange("A1").setValue("Exported");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
worksheet.getRange("A1:B2").toImage(stream, ImageType.PNG);
byte[] imageBytes = stream.toByteArray();
stream - The output image stream.imageType - Specifies the type of image to create.options - The options for output image.
worksheet.getRange("A1").setValue("Exported");
ImageSaveOptions options = new ImageSaveOptions();
options.setShowGridlines(true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
worksheet.getRange("A1:B2").toImage(stream, ImageType.PNG, options);
byte[] imageBytes = stream.toByteArray();
IRange range = worksheet.getRange("B2:C3");
String address = range.getAddress();
IRange range = worksheet.getRange("B2:C3");
String address = range.getAddress(false, false);
rowAbsolute - True to return the row part of the reference as an absolute reference. The default value is true.columnAbsolute - True to return the column part of the reference as an absolute reference. The default value is true.
IRange range = worksheet.getRange("B2:C3");
String address = range.getAddress(false, false, ReferenceStyle.R1C1);
rowAbsolute - True to return the row part of the reference as an absolute reference. The default value is true.columnAbsolute - True to return the column part of the reference as an absolute reference. The default value is true.referenceStyle - The reference style. The default value is A1.
IRange range = worksheet.getRange("B2:C3");
String address = range.getAddress(false, false, ReferenceStyle.R1C1, worksheet.getRange("A1"));
rowAbsolute - True to return the row part of the reference as an absolute reference. The default value is true.columnAbsolute - True to return the column part of the reference as an absolute reference. The default value is true.referenceStyle - The reference style. The default value is A1.relativeTo - If RowAbsolute and ColumnAbsolute are false, and ReferenceStyle is R1C1, defines a starting point for the relative reference. The default reference is $A$1.
worksheet.getRange("A1").setValue("Header");
worksheet.getRange("A3").setValue("Total");
IRange blanks = worksheet.getRange("A1:A3").specialCells(SpecialCellType.Blanks);
String address = blanks.getAddress();
type - The type of cells to include.
worksheet.getRange("A1").setValue("Text");
worksheet.getRange("A2").setValue(100);
IRange numbers = worksheet.getRange("A1:A2").specialCells(SpecialCellType.Constants, SpecialCellsValue.Numbers);
String address = numbers.getAddress();
type - The type of cells to include.value - The value type to include when type is SpecialCellType.Constants or SpecialCellType.Formulas.ICellPadding object SpreadJS only.
IRange range = worksheet.getRange("A1");
range.setCellPadding(new CellPadding(10, 20, 10, 5));
ICellPadding padding = range.getCellPadding();
double left = padding.getLeft();
cellPadding - SpreadJS only.
IRange range = worksheet.getRange("A1");
range.setCellPadding(new CellPadding(10, 20, 10, 5));
ICellPadding padding = range.getCellPadding();
IRange range = worksheet.getRange("A1");
range.setWatermark("Required");
String watermark = range.getWatermark();
watermark - The watermark string
IRange range = worksheet.getRange("A1");
range.setWatermark("Required");
String watermark = range.getWatermark();
ICornerFold cornerFold = new CornerFold(Color.GetRed(), EnumSet.of(CornerPosition.LeftTop), 8);
IRange range = worksheet.getRange("A1");
range.setDecoration(new CellDecoration(cornerFold));
ICellDecoration decoration = range.getDecoration();
value - The cell decoration.
ICornerFold cornerFold = new CornerFold(Color.GetRed(), EnumSet.of(CornerPosition.LeftTop), 8);
IRange range = worksheet.getRange("A1");
range.setDecoration(new CellDecoration(cornerFold));
ICellDecoration decoration = range.getDecoration();
ILabelOptions object that controls the watermark label display options.
IRange range = worksheet.getRange("A1");
range.setWatermark("Required");
ILabelOptions labelOptions = range.getLabelOptions();
labelOptions.setVisibility(LabelVisibility.visible);
json - the json string that contains range info.
worksheet.getRange("A1").setValue("Original");
String json = worksheet.getRange("A1").toJson();
worksheet.getRange("B1").fromJson(json);
Object value = worksheet.getRange("B1").getValue();
worksheet.getRange("A1").setValue("Serialized");
String json = worksheet.getRange("A1").toJson();
text - The string is content of the threaded comment.ICommentThreaded.
IRange range = worksheet.getRange("A1");
ICommentThreaded comment = range.addCommentThreaded("Review this value.");
String text = comment.getText();
text - The string is content of the threaded comment.author - Author name of the threaded comment.
IRange range = worksheet.getRange("A1");
ICommentThreaded comment = range.addCommentThreaded("Review this value.", "Alex");
String author = comment.getAuthor().getName();
IRange range = worksheet.getRange("A1");
range.addCommentThreaded("Review this value.", "Alex");
ICommentThreaded comment = range.getCommentThreaded();
String text = comment.getText();
destination - Indicates for which area the "GETPIVOTDATA" function is generated.
worksheet.getRange("A1:B3").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"West", 90}});
IPivotCache cache = workbook.getPivotCaches().create(worksheet.getRange("A1:B3"));
IPivotTable pivotTable = worksheet.getPivotTables().add(cache, worksheet.getRange("D1"), "SalesPivot");
pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
IRange valueCell = pivotTable.getDataBodyRange().get(0);
String formula = valueCell.generateGetPivotDataFunction(worksheet.getRange("G1"));
worksheet.getRange("A1:B3").setValue(new Object[][] {{"Region", "Amount"}, {"East", 120}, {"West", 90}});
IPivotCache cache = workbook.getPivotCaches().create(worksheet.getRange("A1:B3"));
IPivotTable pivotTable = worksheet.getPivotTables().add(cache, worksheet.getRange("D1"), "SalesPivot");
pivotTable.getPivotFields().get("Region").setOrientation(PivotFieldOrientation.RowField);
pivotTable.addDataField(pivotTable.getPivotFields().get("Amount"), "Sum of Amount", ConsolidationFunction.Sum);
IRange valueCell = pivotTable.getDataBodyRange().get(0);
String formula = valueCell.generateGetPivotDataFunction();
range2 - The range to intersect with this range.
IRange first = worksheet.getRange("A1:C3");
IRange second = worksheet.getRange("B2:D4");
IRange intersection = first.intersect(second);
String address = intersection.getAddress();
ranges - The intersecting ranges.
IRange baseRange = worksheet.getRange("A1:D4");
IRange intersection = baseRange.intersect(worksheet.getRange("B2:D4"), worksheet.getRange("B2:C3"));
String address = intersection.getAddress();
range2 - The range to union with this range.
IRange first = worksheet.getRange("A1:A2");
IRange second = worksheet.getRange("C1:C2");
IRange union = first.union(second);
int areaCount = union.getAreas().getAreaCount();
ranges - Other ranges to union with this range.
IRange union = worksheet.getRange("A1").union(worksheet.getRange("C1"), worksheet.getRange("E1"));
int areaCount = union.getAreas().getAreaCount();
rowOffset - Row offset.columnOffset - Column offset.
IRange range = worksheet.getRange("A1");
IRange offsetRange = range.offset(1, 1);
offsetRange.setValue("B2");
Object value = worksheet.getRange("B2").getValue();
IRange range = worksheet.getRange("A1");
range.setDefaultValue("Not entered");
Object defaultValue = range.getDefaultValue();
IRange range = worksheet.getRange("A1");
range.setDefaultValue("Not entered");
Object value = range.getValue();
value - The default value of the cell, it can be the value data or the formula string. It works when the cell has no data.goal - Specifies the desired goal value.changingCell - Specifies the cell to change.
worksheet.getRange("A1").setValue(10);
worksheet.getRange("B1").setFormula("=A1*2");
boolean solved = worksheet.getRange("B1").goalSeek(50, worksheet.getRange("A1"));
Object input = worksheet.getRange("A1").getValue();
byte[] imageBytes = new byte[] {
(byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, (byte) 0xC4,
(byte) 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41,
0x54, 0x78, (byte) 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, (byte) 0xB4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
(byte) 0xAE, 0x42, 0x60, (byte) 0x82
};
IRange range = worksheet.getRange("A1");
range.setBackgroundImage(imageBytes);
byte[] backgroundImage = range.getBackgroundImage();
backgroundImage - Cell background image byte array.
byte[] imageBytes = new byte[] {
(byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, (byte) 0xC4,
(byte) 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41,
0x54, 0x78, (byte) 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, (byte) 0xB4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
(byte) 0xAE, 0x42, 0x60, (byte) 0x82
};
IRange range = worksheet.getRange("A1");
range.setBackgroundImage(imageBytes);
byte[] backgroundImage = range.getBackgroundImage();
IRange range = worksheet.getRange("A1");
range.setBackgroundImageLayout(BackgroundImageLayout.Center);
BackgroundImageLayout layout = range.getBackgroundImageLayout();
backgroundImageLayout - Background image layout of cell.
IRange range = worksheet.getRange("A1");
range.setBackgroundImageLayout(BackgroundImageLayout.Center);
BackgroundImageLayout layout = range.getBackgroundImageLayout();
Map<String, Object> item = new LinkedHashMap<>();
item.put("Name", "Alice");
item.put("Score", 95);
DataImportResult result = worksheet.getRange("A1").importData(new Map[] {item});
int rowsImported = result.getRowsImported();
items - The items to import. The element type can be:byte, short, int, long, float, double, boolean.Byte, Short, Integer, Long, Float, Double, Boolean, String, CalcError, Classic date and time types: Date, Calendar, JSR310 date and time types: LocalDate, LocalTime, LocalDateTime, OffsetTime, OffsetDateTime, ZonedDateTime, Instant, YearMonth, Year, MonthDay. (Note: Duration and Period are not supported at this time)Map where the key is String: It will be treated as a collection of property names and values.Iterable or array. ClassCastException - The data type of column is inconsistent. Use DataImportOptions.setItemTypeProvider(java.util.function.Function<java.lang.Object, java.lang.Class<?>>) to fix it.IllegalArgumentException - An item is of an unsupported type or options contains incorrect information.
Map<String, Object> item = new LinkedHashMap<>();
item.put("Name", "Alice");
item.put("Score", 95);
DataImportOptions options = new DataImportOptions();
options.setColumnsSelector(source -> new String[] {"Name"});
DataImportResult result = worksheet.getRange("A1").importData(new Map[] {item}, options);
int columnsImported = result.getColumnsImported();
items - The items to import. The element type can be:byte, short, int, long, float, double, boolean.Byte, Short, Integer, Long, Float, Double, Boolean, String, CalcError, Classic date and time types: Date, Calendar, JSR310 date and time types: LocalDate, LocalTime, LocalDateTime, OffsetTime, OffsetDateTime, ZonedDateTime, Instant, YearMonth, Year, MonthDay. (Note: Duration and Period are not supported at this time)Map where the key is String: It will be treated as a collection of property names and values.Iterable or array. options - The import options.ClassCastException - The data type of column is inconsistent. Use DataImportOptions.setItemTypeProvider(java.util.function.Function<java.lang.Object, java.lang.Class<?>>) to fix it.IllegalArgumentException - An item is of an unsupported type or options contains incorrect information. This method also supports reading valid pictures generated by the IMAGE() function.
The returned CellPicture object is a copy of the picture data. Modifying the returned object does not affect the picture stored in the cell. To apply changes, the modified CellPicture must be set back using setCellPicture(CellPicture).
CellPicture object, or null.
CellPicture picture = new CellPicture(new byte[] {
(byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, (byte) 0xC4,
(byte) 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41,
0x54, 0x78, (byte) 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, (byte) 0xB4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
(byte) 0xAE, 0x42, 0x60, (byte) 0x82
}, "Logo");
IRange range = worksheet.getRange("A1");
range.setCellPicture(picture);
CellPicture cellPicture = range.getCellPicture();
picture - The CellPicture object, or null to remove.
CellPicture picture = new CellPicture(new byte[] {
(byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, (byte) 0xC4,
(byte) 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41,
0x54, 0x78, (byte) 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, (byte) 0xB4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
(byte) 0xAE, 0x42, 0x60, (byte) 0x82
}, "Logo");
IRange range = worksheet.getRange("A1");
range.setCellPicture(picture);
String altText = range.getCellPicture().getAltText();
copy(IRange,PasteOption)overload instead.