Class Sheet
Workbook.
The view follows its tab when other tabs are inserted, moved or deleted.
It holds no native resource; all work goes through the owning workbook's
handle, so a Sheet needs no closing.
Coordinates are 0-based and given as (row, col): cell A1 is
(0, 0). Rectangles are inclusive at both ends.
Use Range for bulk work. A Range crosses into the engine
once per rectangle: Range.setValues(io.keikai.axyra.sheets.CellValue[][]), Range.setNumbers(double[]),
Range.values() and Range.setStyle(io.keikai.axyra.sheets.style.CellStyle) read or write a whole
block in one call. cell(int, int), value(int, int) and
setNumber(int, int, double) cross once per cell; do not loop over
them for large blocks.
Once the tab is deleted from its workbook, every method throws
IllegalStateException.
try (Workbook wb = Workbook.create()) {
Sheet s = wb.createSheet("Sales");
// Bulk writes: one engine call per block.
s.range("A1:B1").setValues(new CellValue[][] {
{CellValue.text("Item"), CellValue.text("Qty")}});
s.range("B2:B4").setNumbers(new double[] {3, 5, 8});
// A formula and a style.
s.cell(4, 1).setFormula("SUM(B2:B4)");
s.range("A1:B1").setStyle(CellStyle.builder().bold().build());
s.setColumnWidth(0, 20);
CellValue total = s.value(4, 1); // 16
wb.save(Path.of("sales.xlsx"));
}
-
Method Summary
Modifier and TypeMethodDescriptionReturns the view's active cell as an A1 reference, such as"B3"(<sheetView><selection activeCell>, ECMA-376 §18.3.1.78), ornullwhen the sheet has no selection.intAdds a chart to this sheet.intaddCheckbox(String name, int fromRow, int fromColumn, int toRow, int toColumn, String linkedCell) Adds a check box form control over a cell rectangle, optionally bound to a linked cell that holds its state.voidaddColumnPageBreak(int column) Inserts a manual vertical page break left of the 0-basedcolumn.intaddConnector(String preset, int fromRow, int fromCol, int toRow, int toCol) Add a connector shape (<xdr:cxnSp>) with the given preset geometry name (e.g.intaddFormControl(FormControl control) Adds a form control: check box, option button, button, combo box, list box, scroll bar, spin button, edit box, label or group box.intaddLinkedPicture(String target, String format, int r1, int c1, int r2, int c2) Adds a linked picture over the cell rectangle from(r1, c1)to(r2, c2): the image is referenced by an externaltarget, a URL or a path, through<a:blip r:link>instead of embedding bytes (ECMA-376 Part 1 §20.1.8.13).intaddPicture(byte[] imageData, String format, int fromRow, int fromColumn, int toRow, int toColumn) Inserts an embedded image over the cell rectangle from(fromRow, fromColumn)to(toRow, toColumn).intaddPicture(byte[] imageData, String format, int fromRow, int fromColumn, int fromRowOffset, int fromColumnOffset, int toRow, int toColumn, int toRowOffset, int toColumnOffset) Inserts an embedded image with a full two-cell anchor, offsets included.intaddPivotChart(int pivotIndex, String chartType, int fromRow, int fromCol, int toRow, int toCol) Add a PivotChart bound to the pivot table atpivotIndexon this sheet, anchored over the given cell rectangle.intaddPivotTable(String name, String location, String sourceRef) Creates an empty pivot table whose top-left cell islocation(A1, such as"H1") over the source rangesourceRef, such as"Data!A1:D100".voidaddProtectedRange(String name, String sqref) Adds an allow-edit range without a password; seeaddProtectedRange(String, String, String).voidaddProtectedRange(String name, String sqref, String password) Adds an allow-users-to-edit-range (protectedRange— ECMA-376 Part 1 §18.3.1.72): the named rangesqrefstays editable while the sheet is protected.voidaddRowPageBreak(int row) Inserts a manual horizontal page break above the 0-basedrow.intaddScenario(String name, String[] cellRefs, String[] values) Adds a what-if scenario to this sheet.intAdds a drawing shape, such as"rect","ellipse"or"roundRect", with optionaltext, over the cell rectangle from(fromRow, fromCol)to(toRow, toCol), 0-based.intaddSparkline(String type, String dataRef, String locationRef) Add a sparkline group ("line","column", or"stacked") that drawsdataRef(e.g.intaddTextBox(String text, int fromRow, int fromCol, int toRow, int toCol) Add a text box holdingtext, anchored over the cell rectangle from(fromRow, fromCol)to(toRow, toCol), 0-based; returns the new shape's 0-based index.booleananchorOleObject(int objectIndex, byte[] iconBytes, String iconFormat, int fromRow, int fromCol, int toRow, int toCol) Display the workbook-level embedded OLE object atobjectIndex(seeWorkbook.addOleObject(java.lang.String, java.lang.String, byte[])) as an icon on this sheet, anchored over the cell rectangle(fromRow, fromCol)–(toRow, toCol)(0-based, exclusive bottom-right edge like a drawing anchor).intapplyAdvancedFilter(Range listRange, Range criteriaRange, boolean uniqueOnly) Run an advanced filter (Excel's Data > Advanced) overlistRangein place, hiding the data rows that do not matchcriteriaRange.intapplyAdvancedFilterCopyTo(Range listRange, Range criteriaRange, Range destination, boolean uniqueOnly) Advanced filter in "Copy to another location" mode: instead of hiding source rows, writes the list header plus each matching row (seeapplyAdvancedFilter(Range, Range, boolean)for the criteria semantics) starting at the top-left cell ofdestination.intExecute the auto-filter: hides every data row failing any column's criteria and shows the rest.booleanautoExpandTables(int row, int col, String typedText) Applies Excel's table auto-expansion for an entry typed at(row, col).Returns the filtered block, header row included, ornullwhen this sheet has no auto-filter.voidautoFitColumn(int col) Sets a column's width to fit the widest text its cells display in the sheet's used rows.voidautoFitRow(int row) Sets a row's height to fit its tallest content, as Excel's AutoFit Row Height does.byte[]Returns the encoded bytes of the sheet background image, ornullwhen there is none.Returns the format token of the sheet background image, such as"png", ornullwhen there is none.intReturns the declaredbaseColWidthin characters, or0when the sheet declares none; the spec default of 8 then applies.cell(int row, int col) Returns a single-cell view at(row, col).chart(int chartIndex) Returns a live view of the chart atchartIndex, its 0-based position incharts().charts()Returns every chart on this sheet, in drawing order.voidRemoves the auto-filter and its criteria.booleanRemoves the sheet background image.voidRemoves every chart from this sheet.voidclearColumnFilter(int columnIndex) Removes the criterion from one column and runs the filter, so rows that now pass are shown again.voidRemoves every conditional-formatting rule from this sheet.voidRemoves every page break on this sheet: the manual ones and the automatic ones kept from the source file.voidRemoves the paper-size declaration, so the saved sheet has nopaperSizeattribute and Excel uses the printer's default paper.voidRemoves every picture from this sheet, embedded and linked.voidRemoves every data-validation rule from this sheet; the cell values stay.int[]Returns the 0-based columns a vertical page break sits left of, ascending, asrowPageBreaks()does for rows.columnStyle(int col) Returns the column-level style: the style that cells in this column without their own style render with (<col style>).intcolumnStyleId(int col) Returns the column-level style id, or0when the column has no column-level style.doublecolumnWidth(int col) Returns a column's width in character units.Returns every conditional-formatting rule on this sheet, in stored order.int[]consolidate(int destRow, int destColumn, ConsolidateFunction function, Range... sources) Consolidates several source ranges of the same shape, possibly on other sheets, into this sheet at(destRow, destColumn), as Excel's Data > Consolidate does by position.booleanconvertTableToRange(String name) Converts the named table back to an ordinary range, as Excel's Table Design > Convert to Range does: drops the table definition and keeps every cell value and style in place.doubleReturns the sheet's declared default column width in character units, or0when none is declared; column widths then derive frombaseColumnWidth().doubleReturns the sheet's default row height in points: the height of every row without a height of its own.voiddeleteColumns(int startCol, int count) Deletescountcolumns starting atstartCol, shifting the columns to the right of them left.voiddeleteRows(int startRow, int count) Deletescountrows starting atstartRow, shifting the rows below up.booleanReturns whether the first printed page uses its own header and footer (ECMA-376 §18.3.1.46differentFirst).booleanReturns whether odd and even printed pages use different headers and footers (ECMA-376 §18.3.1.46differentOddEven).doubleReturns the sheet-levelx14ac:dyDescenttext-descent hint on<sheetFormatPr>, or0when absent.Returns the even-page footer text, ornullwhen none is set.Returns the even-page header text, ornullwhen none is set.int[][]Finds every text cell whose text containstext, ignoring case, across the whole sheet.int[][]Finds text cells asfind(String)does, with Excel's Find options.int[][]find(String text, boolean caseSensitive, boolean matchEntire, boolean wildcard, FindFormat format) Finds cells by text and format, asfind(String, FindFormat)does, with Excel's Find options.int[][]find(String text, FindFormat format) Finds cells asfind(String)does, keeping only the cells whose resolved style matchesformat: Excel's Find with Format.int[][]Finds every text cell whose text matches the regular expressionpattern, ignoring case, across the whole sheet.int[][]Finds text cells asfindRegex(String)does, with a choice of case sensitivity.Returns the first-page footer text, ornullwhen none is set.Returns the first-page header text, ornullwhen none is set.intReturns the number printed on the first page, or0when numbering is automatic.intReturns the number of pages tall the printout is fitted to, or0for no limit (ECMA-376 §18.3.1.63fitToHeight).voidfitToPage(int width, int height) Scales the printout to fitwidthpages wide byheightpages tall, and turns on fit-to-page, sopageScale()is ignored.intReturns the number of pages wide the printout is fitted to, or0for no limit (ECMA-376 §18.3.1.63fitToWidth).footer()Returns the page footer text, in Excel's header codes, ornullwhen none is set.int[]Returns the 0-based indexes, ascending, of the columns that carry a column-level record: a width, a hidden flag, a column style or an outline level.int[]Returns the 0-based indexes, ascending, of the rows that carry a row-level record: a height, a hidden flag, a row style or an outline level.intReturns the number of form controls on this sheet, the size offormControls().Returns every form control on this sheet, in z-order.intReturns the number of frozen columns at the left, or 0 when no columns are frozen.voidfreezePanes(int freezeRow, int freezeCol) Freezes the topfreezeRowrows and the leftfreezeColcolumns, as Excel's View > Freeze Panes does with the cell at(freezeRow, freezeCol)selected.intReturns the number of frozen rows at the top, or 0 when no rows are frozen.voidgroupColumns(int startCol, int endCol) Groups columnsstartColtoendCol, 0-based and inclusive, at outline level 1.voidgroupRows(int startRow, int endRow) Groups rowsstartRowtoendRow, 0-based and inclusive, at outline level 1.intgroupShapes(String name, int... shapeIndexes) Group existing shapes into one<xdr:grpSp>container (Excel's "Group").booleanReturns whether this sheet has an auto-filter.booleanReturns whether the sheet carries a<pageSetup>element (ECMA-376 §18.3.1.63).header()Returns the page header text, ornullwhen none is set.byte[]headerFooterPictureData(String section) Returns the image bytes of the header or footer picture insection, a token as forsetHeaderFooterPicture(java.lang.String, byte[], java.lang.String, double, double), ornullwhen that section has no picture.<T> intimportData(int startRow, int startCol, List<T> items) Imports a collection withImportOptions.defaults(): a header row, then every discovered property as a column.<T> intimportData(int startRow, int startCol, List<T> items, ImportOptions options) Import a collection of Java objects into a range.intindex()Returns the 0-based position of this sheet's tab in its workbook, as it is now.voidinsertColumns(int startCol, int count) Insertscountblank columns beforestartCol, shifting the columns to the right.voidinsertRows(int startRow, int count) Insertscountblank rows beforestartRow, shifting the rows below down.booleanisColumnHidden(int col) Returns whether the column is hidden.booleanisColumnWidthCustom(int col) Returns whether the column has its own width, set bysetColumnWidth(int, double)or by<col width>in the source file, instead of following the sheet default.booleanReturns whether the default row height is flagged as fixed (thesheetFormatPr customHeightflag).booleanReturns whether fit-to-page scaling is on, asfitToPage(int, int)sets it.booleanReturns whether the sheet prints in landscape;falsemeans portrait, the default.booleanReturns whether this sheet declares a paper size.booleanReturns whether this sheet is protected.booleanReturns whether the sheet's protection carries a password.booleanisRowHeightCustom(int row) Returns whether the row has its own height instead of following the sheet default.booleanisRowHidden(int row) Returns whether the row's hidden flag is set, bysetRowHidden(int, boolean), by a filter or a collapsed group, or by the source file.booleanisTextBox(int shapeIndex) Returns whether the shape atshapeIndexis a text box (<xdr:cNvSpPr txBox="1"/>): one added byaddTextBox(java.lang.String, int, int, int, int)or read from a file.Returns the merged-cell regions on this sheet, oneRangeper region.name()Returns the sheet's tab name, as shown in Excel.Returns the six page margins in inches, as a snapshot.booleanReturns whether pages print across, then down;falsemeans down, then across.intReturns the print scale in percent; 100 means actual size.intReturns the paper size as its ECMA-376 numeric code; 9 (A4) when none is declared.int[]pictureAnchor(int pictureIndex) Returns{fromRow, fromCol, toRow, toCol}of the picture's two-cell anchor, 0-based, or an empty array when the index is out of range.int[]pictureAnchorFull(int pictureIndex) Returns{fromRow, fromCol, fromRowOffset, fromColOffset, toRow, toCol, toRowOffset, toColOffset}of the picture's anchor: 0-based cells and offsets in EMU.intReturns the number of pictures on this sheet, embedded and linked.byte[]pictureData(int pictureIndex) Returns the encoded image bytes of the picture atpictureIndex, ornullwhen the index is out of range.pictureFormat(int pictureIndex) Returns the format token of the picture atpictureIndex, such as"png"or"jpeg", ornullwhen the index is out of range.pictureLinkTarget(int pictureIndex) Returns the external link target of the picture atpictureIndex, ornullwhen it is an embedded picture or the index is out of range.intReturns the number of pivot tables on this sheet.pivotLocation(int pivotIndex) Returns the location of the pivot table atpivotIndexas an A1 reference, such as"H1".pivotName(int pivotIndex) Returns the name of the pivot table atpivotIndex.pivotSource(int pivotIndex) Returns the source data reference of the pivot table atpivotIndex, such as"Data!A1:D100".pivotTable(int pivotIndex) Returns a live view of the pivot table atpivotIndex: field areas (row, column, filter, values), aggregation functions, layout, grand totals andPivotTableView.refresh().pivotTable(String name) Returns a live view of the pivot table namedname.Returns the print area as an A1 range string, ornullwhen the sheet has none.booleanReturns whether the sheet prints in black and white.intReturns where cell comments print, as the codesetPrintComments(int)takes.booleanReturns whether the sheet prints in draft quality.intReturns how error cells print, as the codesetPrintErrors(int)takes.booleanReturns whether gridlines are printed (ECMA-376 §18.3.1.65printOptions/gridLines).booleanReturns whether row numbers and column letters are printed.booleanReturns whether the printout is centered horizontally on the page (<printOptions horizontalCentered>, ECMA-376 §18.3.1.70).intReturns the printer resolution in dots per inch.Returns the columns repeated at the left of every printed page, such as"$A:$A", ornullwhen none are set.Returns the rows repeated at the top of every printed page, such as"$1:$2", ornullwhen none are set.booleanReturns whether the printout is centered vertically on the page (<printOptions verticalCentered>, ECMA-376 §18.3.1.70).voidprotect()Protects this sheet with Excel's default allowances and no password.voidProtects this sheet with a password and Excel's default allowances.voidprotect(String password, SheetProtection options) Protects this sheet with the given allowances (ECMA-376 §18.3.1.85) and an optional password.Returns the sheet's allow-edit ranges, in the order they were defined.Returns the protection options, as what users may still do, ornullwhen this sheet is not protected.range(int r1, int c1, int r2, int c2) Returns a range over the rectangle from(r1, c1)to(r2, c2), both corners inclusive and 0-based.Returns a range parsed from A1 notation on this sheet:"A1","$A$1:C10", a column band"B:D"or a row band"2:5".booleanremoveChart(int chartIndex) Removes the chart atchartIndex, its 0-based position incharts().booleanremoveConditionalFormat(int formatIndex) Removes the conditional-formatting rule atformatIndex, its 0-based position inconditionalFormats().booleanremoveFormControl(int controlIndex) Removes the form control atcontrolIndex, its 0-based position informControls().booleanremoveHeaderFooterPicture(String section) Removes the header or footer picture insection, a token as forsetHeaderFooterPicture(java.lang.String, byte[], java.lang.String, double, double).booleanremovePicture(int pictureIndex) Removes the picture atpictureIndex, the 0-based index thatpictureData(int)uses.booleanremoveProtectedRange(String name) Removes the allow-edit range namedname.booleanremoveShape(int shapeIndex) Removes the shape atshapeIndex, the 0-based index thatshapeType(int)uses.booleanremoveTable(String name) Removes the table definition namednameand leaves its cells, values and styles in place.booleanremoveValidation(int validationIndex) Removes the data-validation rule atvalidationIndex, its 0-based position invalidations().byte[]renderChartToPng(int chartIndex, int width, int height) Renders the chart atchartIndexto PNG bytes.renderChartToSvg(int chartIndex, int width, int height) Renders the chart atchartIndexto a standalone SVG document.intreplaceAll(String find, String replace) Replacesfindwithreplacein every text cell of the sheet that contains it, ignoring case.intreplaceAll(String find, String replace, boolean caseSensitive, boolean matchEntire, boolean wildcard) Replaces text asreplaceAll(String, String)does, with Excel's Replace options.intreplaceAll(String find, String replace, boolean caseSensitive, boolean matchEntire, boolean wildcard, FindFormat format) Replaces text by format, asreplaceAll(String, String, FindFormat)does, with Excel's Replace options.intreplaceAll(String find, String replace, FindFormat format) Replaces text asreplaceAll(String, String)does, only in the cells whose resolved style matchesformat.intreplaceAllRegex(String pattern, String replacement) Replaces every match of the regular expressionpattern, ignoring case, in every text cell of the sheet.intreplaceAllRegex(String pattern, String replacement, boolean caseSensitive) Replaces regular-expression matches asreplaceAllRegex(String, String)does, with a choice of case sensitivity.voidreplaceChart(int chartIndex, Chart chart) Applychart's spec onto the chart already atchartIndex, in place, keeping its position incharts().booleanresizeTable(String name, Range newRange) Resizes the named table tonewRange, as Excel's Table Design > Resize Table does.booleanReturns whether this sheet is displayed right-to-left: column A at the right edge.doublerowHeight(int row) Returns a row's height in points (1/72 inch).introwOutlineLevel(int row) Returns a row's outline level, from 0 (not grouped) to 7.int[]Returns the 0-based rows a horizontal page break sits above, ascending: the breaks added here and those read from an opened file, automatic ones included.rowStyle(int row) Returns the row-level style: the style that cells in this row without their own style render with.introwStyleId(int row) Returns the row-level style id (<row s="N" customFormat="1">), or0when the row has no row-level style.intReturns the number of what-if scenarios on this sheet.scenarioName(int scenarioIndex) Returns the name of the scenario atscenarioIndex.intReturns the 0-based first visible column of an unfrozen view; seescrollRow().intReturns the 0-based first visible row of an unfrozen view: the row part of<sheetView topLeftCell>(ECMA-376 Part 1 §18.3.1.87).Returns the view's selected ranges (<selection sqref>) as a space-separated list of A1 ranges, such as"A1:B2 D4", ornullwhen nothing is selected.voidsetActiveCell(String cell, String sqref) Moves the cursor and the selection.voidsetAutoFilter(Range range) Defines an auto-filter overrange; its top row holds the filter buttons.voidsetBackgroundImage(byte[] imageData, String format) Sets the sheet background image.voidsetBaseColumnWidth(int width) Sets thebaseColWidthin characters.voidsetColumnColorFilter(int columnIndex, boolean cellColor, Color color) Filters a column by cell fill color, or by font color whencellColorisfalse: only rows whose cell hascolorstay visible.voidsetColumnCustomFilter(int columnIndex, FilterOperator op, String value) Sets a one-condition custom filter on a column, such as "greater than 100", and runs the filter.voidsetColumnCustomFilter(int columnIndex, FilterOperator op1, String value1, FilterOperator op2, String value2, boolean andJoin) Sets a two-condition custom filter on a column and runs the filter.voidsetColumnDateFilter(int columnIndex, boolean includeBlank, DateGroupItem... items) Sets a date grouping filter assetColumnDateFilter(int, DateGroupItem...)does, optionally keeping blank cells too.voidsetColumnDateFilter(int columnIndex, DateGroupItem... items) A date grouping filter (ECMA-376 §18.3.2.4) on a column: a date cell stays visible if it falls inside any ofitems.voidsetColumnDynamicFilter(int columnIndex, DynamicFilterType type) A dynamic filter (ECMA-376 §18.3.2.5) on a column: today / thisWeek / lastMonth / yearToDate / aboveAverage / and so on.voidsetColumnFilter(int columnIndex, String... values) Keeps only the rows whose cell in the filter column is one ofvalues.voidsetColumnGroupCollapsed(int startCol, int endCol, boolean collapsed) Collapses or expands a grouped column range, assetRowGroupCollapsed(int, int, boolean)does for rows.voidsetColumnHidden(int col, boolean hidden) Hides or shows a column.voidsetColumnsOutlineLevel(int startCol, int endCol, int level) Sets the outline level on columnsstartColtoendCol, 0-based and inclusive.voidsetColumnStyle(int col, CellStyle style) Sets the column-level style: the style that cells in this column without their own style render with (<col style>).voidsetColumnTop10Filter(int columnIndex, boolean percent, double value, boolean bottom) A Top-10 filter (ECMA-376 §18.3.2.10) on a column: keep the topvalueitems — orvaluepercent of the items whenpercentis true;bottomflips to the smallest values.voidsetColumnWidth(int col, double width) Sets a column's width in Excel character units: the number of '0' digits of the workbook's default font that fit in the column.voidsetDefaultColumnWidth(double width) Sets the default column width in character units.voidsetDefaultRowHeight(double points) Sets the default row height in points.voidsetDefaultRowHeightCustom(boolean custom) Sets thesheetFormatPr customHeightflag; seeisDefaultRowHeightCustom().voidsetDifferentFirst(boolean on) Sets whether the first printed page uses its own header and footer, Excel's "Different first page" option.voidsetDifferentOddEven(boolean on) Sets whether odd and even printed pages use different headers and footers, Excel's "Different odd and even pages" option.voidsetDyDescent(double dy) Sets the sheet-levelx14ac:dyDescenthint; seedyDescent().voidsetEvenFooter(String text) Sets the even-page footer text.voidsetEvenHeader(String text) Sets the even-page header text.voidsetFirstFooter(String text) Sets the first-page footer text.voidsetFirstHeader(String text) Sets the first-page header text.voidsetFirstPageNumber(int number) Sets the number printed on the first page (ECMA-376 §18.3.1.63firstPageNumbertogether withuseFirstPageNumber).voidSets the page footer text, in Excel's header codes (seesetHeader(java.lang.String)).voidSets the page header text, in Excel's header codes, for example"&CQuarterly report&RPage &P".booleansetHeaderFooterPicture(String section, byte[] data, String format, double widthPt, double heightPt) Place a picture in a header/footer section (ECMA-376 §18.3.1.32legacyDrawingHF).voidsetLandscape(boolean landscape) Sets the print orientation:truefor landscape,falsefor portrait.voidsetNumber(int row, int col, double value) Writes a number into one cell.voidsetPageMargins(double left, double right, double top, double bottom, double header, double footer) Sets the six page margins in inches (ECMA-376 §18.3.1.62pageMargins).voidSets the page margins from aPageMarginsvalue, in inches.voidsetPageOrderOverThenDown(boolean overThenDown) Sets the page order:trueprints across, then down ("Over, then down");falseprints down, then across, Excel's default (ECMA-376 §18.3.1.63pageOrder).voidsetPageScale(int scalePercent) Sets the print scale in percent and turns fit-to-page off.voidsetPaperSize(int paperSize) Sets the paper size from its ECMA-376 numeric code (§18.18.50ST_PaperSize): 1 = Letter, 5 = Legal, 8 = A3, 9 = A4, 11 = A5, and so on.booleansetPictureLinkTarget(int pictureIndex, String target) Repoints a linked picture at a new source.voidsetPrintArea(String a1Range) Sets the print area as an A1 range on this sheet, such as"$A$1:$F$40".voidsetPrintBlackAndWhite(boolean on) Sets whether the sheet prints in black and white (ECMA-376 §18.3.1.63blackAndWhite).voidsetPrintComments(int mode) Sets where cell comments print (ECMA-376 §18.3.1.63cellComments).voidsetPrintDraft(boolean on) Sets whether the sheet prints in draft quality, without graphics (ECMA-376 §18.3.1.63draft).voidsetPrintErrors(int mode) Sets how error cells print (ECMA-376 §18.3.1.70printOptions/errors).voidsetPrintGridlines(boolean on) Sets whether gridlines are printed.voidsetPrintHeadings(boolean on) Sets whether row numbers and column letters are printed (ECMA-376 §18.3.1.70printOptions/headings).voidsetPrintHorizontallyCentered(boolean centered) Sets whether the printout is centered horizontally on the page.voidsetPrintResolution(int dpi) Sets the printer resolution in dots per inch, for both axes.voidsetPrintTitleColumns(String columnsRange) Sets the columns repeated at the left of every printed page, such as"$A:$A".voidsetPrintTitleRows(String rowsRange) Sets the rows repeated at the top of every printed page, such as"$1:$2".voidsetPrintVerticallyCentered(boolean centered) Sets whether the printout is centered vertically on the page.voidsetRightToLeft(boolean rightToLeft) Sets whether this sheet is displayed right-to-left: column A at the right edge.voidsetRowGroupCollapsed(int startRow, int endRow, boolean collapsed) Collapse or expand a grouped row range (Excel's outline +/- button): hides or shows the detail rows and sets thecollapsedflag on the group's summary row: the row below the group whensummaryBelow()istrue, else the row above.voidsetRowHeight(int row, double points) Sets a row's height in points (1/72 inch) and marks the height as the row's own, so Excel keeps it on open.voidsetRowHidden(int row, boolean hidden) Hides or shows a row.voidsetRowsOutlineLevel(int startRow, int endRow, int level) Sets the outline level on rowsstartRowtoendRow, 0-based and inclusive.voidsetRowStyle(int row, CellStyle style) Sets the row-level style: the style that cells in this row without their own style render with.booleansetScrollPosition(int row, int column) Scrolls an unfrozen view so that(row, column)sits at the top left.voidsetShapeAltText(int shapeIndex, String text) Sets, or clears withnull, the shape's alternative text.voidsetShapeFillColor(int shapeIndex, Color color) Sets the shape's fill to a solid color, replacing any gradient or pattern fill.voidsetShapeFlip(int shapeIndex, boolean flipHorizontal, boolean flipVertical) Sets the shape's horizontal and vertical flip flags.voidsetShapeHyperlink(int shapeIndex, String url) Sets, or clears withnull, the shape's hyperlink URL.voidsetShapeLineColor(int shapeIndex, Color color) Sets the shape's outline color.booleansetShapeName(int shapeIndex, String name) Renames a shape.voidsetShapeRotation(int shapeIndex, double degrees) Sets the shape's rotation in degrees, clockwise.voidsetShapeStyleXml(int shapeIndex, String xml) Sets, or clears withnull, the shape's<xdr:style>theme style-matrix reference from raw inner XML (thelnRef/fillRef/effectRef/fontRefchildren, without the enclosing<xdr:style>tags).voidsetShapeText(int shapeIndex, String text) Replaces the shape's text, or clears it withnull.voidsetShowFormulas(boolean on) Turns the show-formulas display mode on or off; seeshowFormulas().voidsetShowGridlines(boolean on) Shows or hides gridlines in the on-screen view; printing is set bysetPrintGridlines(boolean).voidsetShowRowColHeaders(boolean on) Shows or hides the row numbers and column letters in the on-screen view; printing is set bysetPrintHeadings(boolean).voidsetShowZeros(boolean on) Sets whether cells holding zero show0(true) or blank; the values do not change.booleansetSourceSheetId(int id) Renumbers the sheet's<sheet sheetId>.booleansetSparklineStyle(int group, SparklineStyle style) Replaces the whole style of the sparkline group atgroup: colors, point-highlight flags and axis settings.voidsetSummaryBelow(boolean below) Sets whether row-group summaries sit below their detail rows.voidsetSummaryRight(boolean right) Sets whether column-group summaries sit right of their detail columns.voidsetTabColor(Color color) Sets the tab color.booleansetTableColumnTotals(String tableName, String columnName, TotalsRowFunction function) Sets the totals-row function of one column of the named table (ECMA-376 §18.18.92ST_TotalsRowFunction).booleansetTableColumnTotals(String tableName, String columnName, TotalsRowFunction function, String label, String formula) Sets the totals-row function, label and custom formula of one column of the named table.booleansetTableHeaderRow(String tableName, boolean shown) Shows or hides the named table's header row (ECMA-376 §18.5.1.2headerRowCount).booleansetTableStyle(String tableName, TableStyleInfo style) Replaces the style settings of the named table (ECMA-376 §18.5.1.20tableStyleInfo): the style name and the banding and first/last-column flags.booleansetTableTotalsRow(String tableName, boolean shown) Shows or hides the named table's totals row (ECMA-376 §18.5.1.2totalsRowCount).voidsetViewType(String view) Sets the view the tab opens in.voidsetVisibility(Visibility visibility) Sets whether this sheet's tab is visible, hidden or very hidden.voidsetZoom(int percent) Sets the on-screen zoom in percent.shapeAltText(int shapeIndex) Returns the shape's alternative text (cNvPr/@descr), ornullwhen it has none.int[]shapeAnchor(int shapeIndex) Returns{fromRow, fromCol, toRow, toCol}of the shape's anchor, 0-based, or an empty array when the index has no shape.intReturns the number of shapes on this sheet, text boxes, connectors and groups included.shapeFillColor(int shapeIndex) Returns the shape's solid fill color as an RGB color, ornullwhen the shape has no solid RGB fill: no fill, a gradient, a pattern or a theme color.boolean[]shapeFlip(int shapeIndex) Returns{flipHorizontal, flipVertical}, or an empty array when the index has no shape.shapeHyperlink(int shapeIndex) Returns the hyperlink URL attached to the shape through DrawingMLhlinkClick, ornullwhen the shape has no hyperlink.shapeLineColor(int shapeIndex) Returns the shape's outline color as an RGB color, ornullwhen it has no solid RGB outline.shapeName(int shapeIndex) Returns the shape's drawing name (<xdr:cNvPr name>, ECMA-376 Part 1 §20.5.2.16): what Excel shows in the Name Box and what a macro uses to address the shape.doubleshapeRotation(int shapeIndex) Returns the shape's rotation in degrees, clockwise.shapeStyleXml(int shapeIndex) Returns the raw inner XML of the shape's<xdr:style>theme style-matrix reference (thelnRef/fillRef/effectRef/fontRefchildren), ornullwhen the shape has no such block.shapeText(int shapeIndex) Returns the shape's text, ornullwhen it has none or the index has no shape.shapeType(int shapeIndex) Returns the geometry token of the shape atshapeIndex, such as"rect".Returns what kind of tab this is: worksheet, chart sheet, dialog sheet or Excel 4.0 macro sheet (international or not).booleanReturns whether the grid shows formula text instead of results (<sheetView showFormulas>).booleanReturns whether the on-screen view draws gridlines (<sheetView showGridLines>, ECMA-376 §18.3.1.87).booleanReturns whether the on-screen view shows the row numbers and column letters (showRowColHeaders).booleanshowScenario(int scenarioIndex) Applies the scenario atscenarioIndex: writes each of its changing-cell values into the sheet.booleanReturns whether a cell holding zero shows0(true) or shows blank (<sheetView showZeros>, ECMA-376 §18.3.1.87).intReturns the number of SmartArt diagrams anchored on this sheet.Returns the SmartArt diagrams anchored on this sheet as read-only descriptors: layout family, anchor and visible node texts.voidsortByColor(Range range, int sortColumnIndex, boolean cellColor, boolean hasHeader, Color... colors) Sort the rows ofrangeby cell fill color (or font color whencellColoris false) atsortColumnIndex(0-based, relative to the range start).intReturns the workbook-level id this sheet was read with (<sheet sheetId>inxl/workbook.xml), or0for a sheet created through this API; the writer allocates an id for those on save.intReturns the number of sparkline groups on this sheet.All sparkline groups on this sheet (ECMA-376 Part 4 §18.3.1.32,x14:sparklineGroups): the group type, basic marker/highlight style, series color and each sparkline's data range and draw location.intReturns the 0-based column just right of the vertical split, or0when there is none.voidsplitPanes(int splitRow, int splitColumn) Splits the view into panes that scroll on their own, as Excel's View > Split does.intsplitRow()Returns the 0-based row just below the horizontal split, or0when there is none.intsubtotal(int firstRow, int lastRow, int groupColumn, boolean hasHeaders, SubtotalFunction function, int... subtotalColumns) Insert subtotals into[firstRow, lastRow]as above.intsubtotal(int firstRow, int lastRow, int groupColumn, SubtotalFunction function, int... subtotalColumns) Insert subtotals into the sorted data block[firstRow, lastRow]: after each run of equal values ingroupColumn, a summary row offunctionoversubtotalColumnsis inserted (plus a grand total).booleanReturns whether a row group's summary row sits below its detail rows (<outlinePr summaryBelow>, ECMA-376 §18.3.1.61).booleanReturns whether a column group's summary column sits right of its detail columns (<outlinePr summaryRight>).tabColor()Returns the tab color, ornullwhen the tab has none.tables()Returns every table on this sheet (Excel's ListObjects), with its range, columns, style and totals state.inttextToColumns(String srcRange, int destRow, int destColumn, String delimiters, boolean treatConsecutiveAsOne) Splits text astextToColumns(String, String)does, writing the fields to another place: the fields of source rowigo to rowdestRow + i, starting atdestColumn.inttextToColumns(String srcRange, String delimiters) Splits text in place, as Excel's Text to Columns does in delimited mode.inttextToColumns(String srcRange, String delimiters, boolean treatConsecutiveAsOne) Splits text in place astextToColumns(String, String)does, optionally treating a run of delimiters as one split point: Excel's "Treat consecutive delimiters as one", useful for space-aligned text.voidunfreeze()Removes any frozen panes; the same asfreezePanes(0, 0).booleanungroupShapes(int shapeIndex) Dissolve a group created bygroupShapes(java.lang.String, int...): members return to standalone emission and the group entry is removed.uniqueId()Returns the sheet's revision GUID as stored in the source file (Excel'sxr:uidon the sheet part root), braces included, for example"{B9A12774-C2A8-4D3E-B631-D37318C68856}".voidRemoves sheet protection without checking any password.booleanDisable sheet protection after verifyingpasswordagainst the stored hash (ISO hash, or the legacy 16-bitpasswordattribute of transitional files).booleanupdateFormControl(int controlIndex, FormControl control) Replaces the form control atcontrolIndex, its 0-based position informControls().Returns the smallest range that covers every stored cell, ornullwhen the sheet has no cells.Returns every data-validation rule on this sheet, in stored order.value(int row, int col) Returns the value of one cell: its cached result for a formula cell,CellValue.BLANKfor an empty cell.booleanverifyProtectedRangePassword(String name, String password) Returns whetherpasswordmatches the stored hash of the allow-edit rangename, matched case-insensitively.booleanverifyProtectionPassword(String password) Returns whetherpasswordmatches the sheet's stored hash.viewType()Returns the view the tab opens in (<sheetView view>, ECMA-376 §18.3.1.87):"normal","pageBreakPreview"or"pageLayout".Returns whether this sheet's tab is visible, hidden or very hidden.intzoom()Returns the on-screen zoom in percent; 100 by default.
-
Method Details
-
name
Returns the sheet's tab name, as shown in Excel. -
index
public int index()Returns the 0-based position of this sheet's tab in its workbook, as it is now. ASheetis bound to its tab, not to a position: afterWorkbook.insertSheet(int, java.lang.String),Workbook.moveSheet(int, int)or a delete of another sheet it keeps referring to the same tab, and this value changes.- Throws:
IllegalStateException- if this sheet has been deleted
-
visibility
Returns whether this sheet's tab is visible, hidden or very hidden. -
setVisibility
Sets whether this sheet's tab is visible, hidden or very hidden. AVisibility.VERY_HIDDENtab cannot be unhidden from Excel's user interface; only code can show it again. Nothing stops you from hiding the last visible sheet. Keep at least one sheet visible, because Excel needs one.- Parameters:
visibility- the new state;nullacts asVisibility.HIDDEN
-
sheetType
Returns what kind of tab this is: worksheet, chart sheet, dialog sheet or Excel 4.0 macro sheet (international or not).The engine models worksheet content only, so a chart, dialog or macro tab reads back with an empty grid. A chart sheet survives a save as a chart sheet: an imported one is written back unchanged, and one added with
Workbook.addChartSheet(java.lang.String, io.keikai.axyra.sheets.content.Chart)is generated from its chart. A dialog or macro tab is written back as an ordinary worksheet. -
uniqueId
Returns the sheet's revision GUID as stored in the source file (Excel'sxr:uidon the sheet part root), braces included, for example"{B9A12774-C2A8-4D3E-B631-D37318C68856}". Returnsnullwhen the source declared none: files written before Excel 2014, dialog sheets, and sheets created through this API.Read-only: the value is not written back on save.
-
rightToLeft
public boolean rightToLeft()Returns whether this sheet is displayed right-to-left: column A at the right edge. -
setRightToLeft
public void setRightToLeft(boolean rightToLeft) Sets whether this sheet is displayed right-to-left: column A at the right edge. -
tabColor
Returns the tab color, ornullwhen the tab has none. RGB, theme (with tint) and legacy indexed colors are all returned as they are stored; check the kind withColor.isRgb(),Color.isTheme()orColor.isIndexed()before reading its components. -
setTabColor
Sets the tab color. RGB, theme and indexed colors are all accepted and kept as their kind; a theme color keeps its tint to four decimal places.- Parameters:
color- the color;nullorColor.auto()clears it, since a tab has no automatic color
-
header
Returns the page header text, ornullwhen none is set. The text uses Excel's header codes, for example&L,&Cand&Rfor the sections and&Pfor the page number. WhendifferentOddEven()is on, this is the odd-page header. -
setHeader
Sets the page header text, in Excel's header codes, for example"&CQuarterly report&RPage &P".- Parameters:
text- the header text;nullclears it
-
firstHeader
Returns the first-page header text, ornullwhen none is set. It prints only whendifferentFirst()is on. -
setFirstHeader
Sets the first-page header text. It prints only whendifferentFirst()is on; seesetDifferentFirst(boolean).- Parameters:
text- the header text;nullclears it
-
differentFirst
public boolean differentFirst()Returns whether the first printed page uses its own header and footer (ECMA-376 §18.3.1.46differentFirst). Whentrue, page 1 printsfirstHeader()andfirstFooter()instead of the default ones, for example to leave the page number off a cover page. -
setDifferentFirst
public void setDifferentFirst(boolean on) Sets whether the first printed page uses its own header and footer, Excel's "Different first page" option. Set the text withsetFirstHeader(java.lang.String)andsetFirstFooter(java.lang.String). -
evenHeader
Returns the even-page header text, ornullwhen none is set. It prints only whendifferentOddEven()is on. -
setEvenHeader
Sets the even-page header text. It prints only whendifferentOddEven()is on; seesetDifferentOddEven(boolean).- Parameters:
text- the header text;nullclears it
-
differentOddEven
public boolean differentOddEven()Returns whether odd and even printed pages use different headers and footers (ECMA-376 §18.3.1.46differentOddEven). Whentrue,evenHeader()andevenFooter()print on pages 2, 4, 6, … and the default ones on pages 1, 3, 5, …, for example for mirrored layouts in a bound document. -
setDifferentOddEven
public void setDifferentOddEven(boolean on) Sets whether odd and even printed pages use different headers and footers, Excel's "Different odd and even pages" option. Set the even-page text withsetEvenHeader(java.lang.String)andsetEvenFooter(java.lang.String). -
range
Returns a range over the rectangle from(r1, c1)to(r2, c2), both corners inclusive and 0-based. The range is a view: it reads and writes this sheet's current cells. Use it for bulk reads and writes, such asRange.setValues(io.keikai.axyra.sheets.CellValue[][])andRange.values().- Parameters:
r1- 0-based first rowc1- 0-based first columnr2- 0-based last row, inclusivec2- 0-based last column, inclusive- Throws:
IndexOutOfBoundsException- if a coordinate is negative or past XFD1048576IllegalArgumentException- ifr2 < r1orc2 < c1
-
range
Returns a range parsed from A1 notation on this sheet:"A1","$A$1:C10", a column band"B:D"or a row band"2:5". A band covers the whole grid on its other axis. A sheet-qualified reference such as"Sheet1!A1"is not accepted.- Parameters:
a1- the reference in A1 notation- Throws:
IllegalArgumentException- ifa1isnull, mixes a column and a row endpoint, or cannot be parsedIndexOutOfBoundsException- if a coordinate is past XFD1048576
-
cell
Returns a single-cell view at(row, col). The view reads and writes the live cell. Each call on it crosses into the engine once; for many cells, userange(int, int, int, int)instead.- Parameters:
row- 0-based row indexcol- 0-based column index- Throws:
IndexOutOfBoundsException- if a coordinate is negative or past XFD1048576
-
value
Returns the value of one cell: its cached result for a formula cell,CellValue.BLANKfor an empty cell. One engine call per cell; for a block, useRange.values().- Parameters:
row- 0-based row indexcol- 0-based column index
-
setNumber
public void setNumber(int row, int col, double value) Writes a number into one cell. Only the value changes: the cell keeps its style, comment and hyperlink, and a formula there is dropped, as withCell.setValue(io.keikai.axyra.sheets.CellValue). ANaNclears the cell. One engine call per cell; for a block, useRange.setNumbers(double[]).- Parameters:
row- 0-based row indexcol- 0-based column index
-
importData
Import a collection of Java objects into a range. Each element becomes one row starting at(startRow, startCol); the object's properties become columns. Properties are discovered by reflection — Java records first (component order), else JavaBean getters (getX/isX, ordered by property name), else public instance fields (declared order). An element that is aMapis a row keyed by column name: its keys become the columns, in the order they are first met across the rows (passImportOptions.columnsor use aLinkedHashMapfor a fixed order), and a missing key leaves its cell blank. Values map toCellValue: numbers stay numeric,Booleanto bool,CharSequenceto text,LocalDate/LocalDateTime/Dateto Excel date serials,nullto blank, anything else to itstoString().Rows are written through the bulk
Range.setValues(io.keikai.axyra.sheets.CellValue[][])path in chunks, one engine call per chunk.Dates are written as serial numbers in the workbook's date system (1900 or 1904), with no number format. Apply a date format to those columns, for example with
Range.setStyle(io.keikai.axyra.sheets.style.CellStyle), or they display as plain numbers. ADateis converted in the JVM's default time zone. An emptyitemslist writes only a header row, labelled fromcolumnLabelsorcolumns; with neither set, nothing is written and the method returns 0.- Parameters:
startRow- 0-based row of the first written row: the header row when headers are onstartCol- 0-based column of the first propertyitems- the objects to import; must all be the same class as the first element, or all be mapsoptions- column selection, header, labels, and header style; whennull,ImportOptions.defaults()apply- Returns:
- the number of rows written, including the header row when enabled
- Throws:
AxyraException- ifitemsis null, the elements are of mixed types, an element is a plain value (a string, number, date, collection or array) rather than a row, or anoptions.columns()name is unknown
-
importData
Imports a collection withImportOptions.defaults(): a header row, then every discovered property as a column. SeeimportData(int, int, List, ImportOptions)for the mapping.- Parameters:
startRow- 0-based row of the header rowstartCol- 0-based column of the first property- Returns:
- the number of rows written, the header row included
-
insertRows
public void insertRows(int startRow, int count) Insertscountblank rows beforestartRow, shifting the rows below down. Like Excel, it updates every reference to the moved cells across the workbook: formulas on this and other sheets, defined names (print areas and titles too), chart series, conditional-format and validation ranges, pivot sources and locations, and sparklines. An insert inside a referenced area extends the area.- Parameters:
startRow- 0-based row before which the rows gocount- number of rows; 0 does nothing, and a negative value is not checked
-
deleteRows
public void deleteRows(int startRow, int count) Deletescountrows starting atstartRow, shifting the rows below up. References across the workbook are updated as ininsertRows(int, int). A reference that pointed only into the deleted rows becomes#REF!, and an area that crossed them shrinks.- Parameters:
startRow- 0-based first row to deletecount- number of rows; 0 does nothing- Throws:
AxyraException- if the rows include a table's header row but not the whole table; Excel refuses that delete too
-
insertColumns
public void insertColumns(int startCol, int count) Insertscountblank columns beforestartCol, shifting the columns to the right. References across the workbook are updated as ininsertRows(int, int).- Parameters:
startCol- 0-based column before which the columns gocount- number of columns; 0 does nothing, and a negative value is not checked
-
deleteColumns
public void deleteColumns(int startCol, int count) Deletescountcolumns starting atstartCol, shifting the columns to the right of them left. References across the workbook are updated as indeleteRows(int, int); a reference that pointed only into the deleted columns becomes#REF!.- Parameters:
startCol- 0-based first column to deletecount- number of columns; 0 does nothing
-
setRowHeight
public void setRowHeight(int row, double points) Sets a row's height in points (1/72 inch) and marks the height as the row's own, so Excel keeps it on open. The value is stored as given: it is not clamped to Excel's 0 to 409 range. To fit the height to the content, useautoFitRow(int).- Parameters:
row- 0-based row index; not bounds-checkedpoints- height in points
-
rowHeight
public double rowHeight(int row) Returns a row's height in points (1/72 inch). For a row with no height record, returnsdefaultRowHeight(), or 15 when the sheet declares no default.- Parameters:
row- 0-based row index
-
isRowHeightCustom
public boolean isRowHeightCustom(int row) Returns whether the row has its own height instead of following the sheet default. The height is the row's own aftersetRowHeight(int, double), or when the source file declared<row ht>. Excel keeps such a height when it opens the file. A row without one is auto-fitted to its font on open, even when the two values are equal.The method also returns
truewhen the row has a record whose height differs from the sheet default. A row record thatsetRowHidden(int, boolean)orsetRowStyle(int, io.keikai.axyra.sheets.style.CellStyle)created holds a height of 15 points, so on a sheet whose default is not 15 such a row reportstrue.- Parameters:
row- 0-based row index
-
setColumnWidth
public void setColumnWidth(int col, double width) Sets a column's width in Excel character units: the number of '0' digits of the workbook's default font that fit in the column. Marks the width as the column's own. To fit the width to the content, useautoFitColumn(int).- Parameters:
col- 0-based column index; must be below 16,384 (column XFD), and is not checkedwidth- width in character units
-
columnWidth
public double columnWidth(int col) Returns a column's width in character units. A column with no width of its own returns the sheet's effective default (seedefaultColumnWidth()).- Parameters:
col- 0-based column index
-
defaultRowHeight
public double defaultRowHeight()Returns the sheet's default row height in points: the height of every row without a height of its own. Returns15for a new sheet, and0when a loaded sheet declares no default; Excel then derives the height from the default font. -
setDefaultRowHeight
public void setDefaultRowHeight(double points) Sets the default row height in points. Rows with their own height keep it.- Parameters:
points- the height;0clears the declaration, so the saved sheet carries no default
-
isDefaultRowHeightCustom
public boolean isDefaultRowHeightCustom()Returns whether the default row height is flagged as fixed (thesheetFormatPr customHeightflag). Without the flag, Excel may replace the default with one derived from the default font. -
setDefaultRowHeightCustom
public void setDefaultRowHeightCustom(boolean custom) Sets thesheetFormatPr customHeightflag; seeisDefaultRowHeightCustom(). -
defaultColumnWidth
public double defaultColumnWidth()Returns the sheet's declared default column width in character units, or0when none is declared; column widths then derive frombaseColumnWidth(). A new sheet reports Excel's stock8.43.columnWidth(int)on a column with no width of its own returns the effective width either way. -
setDefaultColumnWidth
public void setDefaultColumnWidth(double width) Sets the default column width in character units. Columns with their own width keep it.- Parameters:
width- the width;0clears the declaration, and widths then derive frombaseColumnWidth()
-
baseColumnWidth
public int baseColumnWidth()Returns the declaredbaseColWidthin characters, or0when the sheet declares none; the spec default of 8 then applies. Excel derives the default column width from it when no default width is declared. -
setBaseColumnWidth
public void setBaseColumnWidth(int width) Sets thebaseColWidthin characters.- Parameters:
width- the base width;0clears the declaration
-
formattedColumns
public int[] formattedColumns()Returns the 0-based indexes, ascending, of the columns that carry a column-level record: a width, a hidden flag, a column style or an outline level. A new sheet returns an empty array. A column keeps its record after a setter restores the default value, for examplesetColumnHidden(c, false)orsetColumnStyle(c, null), so such a column is still listed.- Returns:
- a new array; later edits do not change it
-
formattedRows
public int[] formattedRows()Returns the 0-based indexes, ascending, of the rows that carry a row-level record: a height, a hidden flag, a row style or an outline level. This is the row counterpart offormattedColumns(). A row with a set height and no cells, such as a top spacer row, is listed even thoughusedRange()does not cover it. A row keeps its record after a setter restores the default value, for examplesetRowHidden(r, false), so such a row is still listed.- Returns:
- a new array; later edits do not change it
-
isColumnWidthCustom
public boolean isColumnWidthCustom(int col) Returns whether the column has its own width, set bysetColumnWidth(int, double)or by<col width>in the source file, instead of following the sheet default.- Parameters:
col- 0-based column index
-
columnStyleId
public int columnStyleId(int col) Returns the column-level style id, or0when the column has no column-level style. The id is the workbook's internal index of a shared style, the same kindRange.styleIds()returns; it is valid only within this workbook. UsecolumnStyle(int)for the style itself.- Parameters:
col- 0-based column index
-
columnStyle
Returns the column-level style: the style that cells in this column without their own style render with (<col style>).- Parameters:
col- 0-based column index- Returns:
- a snapshot of the style, or
nullwhen the column has no column-level style
-
setColumnStyle
Sets the column-level style: the style that cells in this column without their own style render with (<col style>). Cells that already have a style keep it. Excel's "format whole column" changes those cells too; to match it, also apply the style to the used cells withRange.setStyle(io.keikai.axyra.sheets.style.CellStyle). Each distinct style is stored once and shared.- Parameters:
col- 0-based column indexstyle- the style, ornullto remove the column-level style
-
rowStyleId
public int rowStyleId(int row) Returns the row-level style id (<row s="N" customFormat="1">), or0when the row has no row-level style. The row counterpart ofcolumnStyleId(int); userowStyle(int)for the style itself.- Parameters:
row- 0-based row index
-
rowStyle
Returns the row-level style: the style that cells in this row without their own style render with.- Parameters:
row- 0-based row index- Returns:
- a snapshot of the style, or
nullwhen the row has no row-level style
-
setRowStyle
Sets the row-level style: the style that cells in this row without their own style render with. Cells that already have a style keep it. Excel's "format whole row" changes those cells too; to match it, also apply the style to the used cells withRange.setStyle(io.keikai.axyra.sheets.style.CellStyle).- Parameters:
row- 0-based row indexstyle- the style, ornullto remove the row-level style
-
showGridlines
public boolean showGridlines()Returns whether the on-screen view draws gridlines (<sheetView showGridLines>, ECMA-376 §18.3.1.87). This is notprintGridlines(), which controls printing. -
setShowGridlines
public void setShowGridlines(boolean on) Shows or hides gridlines in the on-screen view; printing is set bysetPrintGridlines(boolean). -
showRowColHeaders
public boolean showRowColHeaders()Returns whether the on-screen view shows the row numbers and column letters (showRowColHeaders). -
setShowRowColHeaders
public void setShowRowColHeaders(boolean on) Shows or hides the row numbers and column letters in the on-screen view; printing is set bysetPrintHeadings(boolean). -
showZeros
public boolean showZeros()Returns whether a cell holding zero shows0(true) or shows blank (<sheetView showZeros>, ECMA-376 §18.3.1.87). A sheet that never declared the attribute reportstrue, its default. -
setShowZeros
public void setShowZeros(boolean on) Sets whether cells holding zero show0(true) or blank; the values do not change. -
showFormulas
public boolean showFormulas()Returns whether the grid shows formula text instead of results (<sheetView showFormulas>). It is a display mode only: the stored values do not change, and nothing recalculates when it changes. -
setShowFormulas
public void setShowFormulas(boolean on) Turns the show-formulas display mode on or off; seeshowFormulas(). -
viewType
Returns the view the tab opens in (<sheetView view>, ECMA-376 §18.3.1.87):"normal","pageBreakPreview"or"pageLayout". A sheet with no such attribute reports"normal", its default. -
setViewType
Sets the view the tab opens in."normal"clears the attribute rather than writing it, so a sheet that never had one does not gain aview="normal"it did not carry before. The value is not checked: anything other than"normal","pageBreakPreview"or"pageLayout"is written as given and makes the file invalid.- Parameters:
view- the view token; notnull- Throws:
AxyraException- ifviewisnull
-
summaryBelow
public boolean summaryBelow()Returns whether a row group's summary row sits below its detail rows (<outlinePr summaryBelow>, ECMA-376 §18.3.1.61).trueis the default. Grouping reads the flag when it places a summary, so changing it changes where later groups collapse to. -
setSummaryBelow
public void setSummaryBelow(boolean below) Sets whether row-group summaries sit below their detail rows. -
summaryRight
public boolean summaryRight()Returns whether a column group's summary column sits right of its detail columns (<outlinePr summaryRight>).trueis the default. -
setSummaryRight
public void setSummaryRight(boolean right) Sets whether column-group summaries sit right of their detail columns. -
activeCell
Returns the view's active cell as an A1 reference, such as"B3"(<sheetView><selection activeCell>, ECMA-376 §18.3.1.78), ornullwhen the sheet has no selection. -
selectionSqref
Returns the view's selected ranges (<selection sqref>) as a space-separated list of A1 ranges, such as"A1:B2 D4", ornullwhen nothing is selected. -
setActiveCell
Moves the cursor and the selection.sqrefmay name several space-separated ranges;nullselects the active cell alone.Any per-pane selection list read from the source file is dropped, because it records the old cursor. Keeping it would make the saved file reopen at the old position and discard this call.
- Parameters:
cell- the active cell in A1 form, such as"B3"; notnull, and not checkedsqref- space-separated A1 ranges to select, ornullto select only the active cell; not checked- Throws:
AxyraException- ifcellisnull
-
sourceSheetId
public int sourceSheetId()Returns the workbook-level id this sheet was read with (<sheet sheetId>inxl/workbook.xml), or0for a sheet created through this API; the writer allocates an id for those on save.Pivot caches, defined names and external links address a sheet by this id rather than by tab position, so it is not
index(). -
setSourceSheetId
public boolean setSourceSheetId(int id) Renumbers the sheet's<sheet sheetId>.Returns
false, and changes nothing, for0and for an id another sheet already holds. The writer reads0as "unset" and replaces it with an allocated id. Sheet ids are unique within a workbook, and a duplicate makes the package invalid.- Parameters:
id- the new id, 1 or greater- Returns:
trueif the id was changed
-
scrollRow
public int scrollRow()Returns the 0-based first visible row of an unfrozen view: the row part of<sheetView topLeftCell>(ECMA-376 Part 1 §18.3.1.87). Returns 0 when the view is not scrolled.On a sheet with frozen panes, the same attribute anchors the frozen corner and the scroll position is not saved. A frozen sheet read from a file reports 0. A scroll position set before
freezePanes(int, int)is still reported but is not written on save. For a frozen sheet, readfreezeRow()andfreezeColumn(). -
scrollColumn
public int scrollColumn()Returns the 0-based first visible column of an unfrozen view; seescrollRow(). -
setScrollPosition
public boolean setScrollPosition(int row, int column) Scrolls an unfrozen view so that(row, column)sits at the top left.Returns
false, and changes nothing, for a sheet with frozen panes: there the attribute belongs to the frozen corner, so writing a scroll position into it would move the freeze rather than the window.- Parameters:
row- 0-based first visible rowcolumn- 0-based first visible column- Returns:
trueif the position was set
-
hasPageSetup
public boolean hasPageSetup()Returns whether the sheet carries a<pageSetup>element (ECMA-376 §18.3.1.63). Its presence changes Excel's print layout both ways: an extra element switches the default paper to Letter, and a missing one shifts the printed body up. Any page-setup setter, such as orientation, scale, fit-to-page or paper size, makes the element present. -
dyDescent
public double dyDescent()Returns the sheet-levelx14ac:dyDescenttext-descent hint on<sheetFormatPr>, or0when absent. Excel stores the default font's descent here and uses it to size rows without a height of their own. A copy of the sheet without the hint can fit a different number of rows per printed page, which moves every page break of a long table. -
setDyDescent
public void setDyDescent(double dy) Sets the sheet-levelx14ac:dyDescenthint; seedyDescent().- Parameters:
dy- the descent hint;0removes it
-
setRowHidden
public void setRowHidden(int row, boolean hidden) Hides or shows a row. When the hidden state changes, formulas that depend on the row's cells, such asSUBTOTAL(109, ...), are recalculated.- Parameters:
row- 0-based row index
-
isRowHidden
public boolean isRowHidden(int row) Returns whether the row's hidden flag is set, bysetRowHidden(int, boolean), by a filter or a collapsed group, or by the source file.- Parameters:
row- 0-based row index
-
setColumnHidden
public void setColumnHidden(int col, boolean hidden) Hides or shows a column. Formulas are not recalculated: Excel'sSUBTOTALignores hidden columns.- Parameters:
col- 0-based column index; must be below 16,384
-
isColumnHidden
public boolean isColumnHidden(int col) Returns whether the column is hidden.- Parameters:
col- 0-based column index
-
freezePanes
public void freezePanes(int freezeRow, int freezeCol) Freezes the topfreezeRowrows and the leftfreezeColcolumns, as Excel's View > Freeze Panes does with the cell at(freezeRow, freezeCol)selected. Pass 0 on an axis to leave it unfrozen;freezePanes(0, 0)isunfreeze(). On save, a freeze replaces any split fromsplitPanes(int, int).- Parameters:
freezeRow- number of rows to freeze at the topfreezeCol- number of columns to freeze at the left
-
unfreeze
public void unfreeze()Removes any frozen panes; the same asfreezePanes(0, 0). -
freezeRow
public int freezeRow()Returns the number of frozen rows at the top, or 0 when no rows are frozen. -
freezeColumn
public int freezeColumn()Returns the number of frozen columns at the left, or 0 when no columns are frozen. -
splitPanes
public void splitPanes(int splitRow, int splitColumn) Splits the view into panes that scroll on their own, as Excel's View > Split does. Unlike a freeze, every pane scrolls.The split sits on the grid line above 0-based row
splitRowand left of 0-based columnsplitColumn. On save it is written as a distance in twentieths of a point, measured from the current row heights and column widths. When frozen panes are also set, the freeze is saved and the split is dropped.- Parameters:
splitRow- 0-based row below the split, or 0 for no horizontal splitsplitColumn- 0-based column right of the split, or 0 for no vertical split
-
splitRow
public int splitRow()Returns the 0-based row just below the horizontal split, or0when there is none. -
splitColumn
public int splitColumn()Returns the 0-based column just right of the vertical split, or0when there is none. -
addRowPageBreak
public void addRowPageBreak(int row) Inserts a manual horizontal page break above the 0-basedrow. It is saved as the sheet's<rowBreaks>and paginates PDF and image output. Row0and rows past the grid are ignored. -
addColumnPageBreak
public void addColumnPageBreak(int column) Inserts a manual vertical page break left of the 0-basedcolumn. It is saved as<colBreaks>. Column0and columns past the grid are ignored. -
rowPageBreaks
public int[] rowPageBreaks()Returns the 0-based rows a horizontal page break sits above, ascending: the breaks added here and those read from an opened file, automatic ones included.- Returns:
- a new array; later edits do not change it
-
columnPageBreaks
public int[] columnPageBreaks()Returns the 0-based columns a vertical page break sits left of, ascending, asrowPageBreaks()does for rows.- Returns:
- a new array; later edits do not change it
-
clearPageBreaks
public void clearPageBreaks()Removes every page break on this sheet: the manual ones and the automatic ones kept from the source file. -
mergedRegions
Returns the merged-cell regions on this sheet, oneRangeper region. Merge or unmerge withRange.merge()andRange.unmerge().- Returns:
- a new list; later merges do not change it
-
usedRange
Returns the smallest range that covers every stored cell, ornullwhen the sheet has no cells. Rows and columns that only carry a height, width or style are not covered; seeformattedRows()andformattedColumns(). -
find
Finds every text cell whose text containstext, ignoring case, across the whole sheet. Only text values are searched: a number such as 42 is not found by"42". A formula cell matches on its cached text result, not on its formula.- Parameters:
text- the text to look for- Returns:
{row, col}pairs, 0-based, in row-major order; an empty array when nothing matches
-
find
Finds text cells asfind(String)does, with Excel's Find options.- Parameters:
text- the text to look forcaseSensitive- match letter case exactlymatchEntire- the whole cell text must match, not a substringwildcard- treat*,?and~as Excel wildcards- Returns:
{row, col}pairs, 0-based, in row-major order
-
findRegex
Finds every text cell whose text matches the regular expressionpattern, ignoring case, across the whole sheet. Only text values are searched: numbers, booleans and errors never match. A formula cell matches on its cached text result. The pattern uses the Rustregexcrate syntax; a(?-i)group turns case-insensitive matching off for its part.- Parameters:
pattern- the regular expression- Returns:
{row, col}pairs, 0-based, in row-major order; an empty array when nothing matches- Throws:
AxyraException- ifpatternis not a valid regular expression
-
findRegex
Finds text cells asfindRegex(String)does, with a choice of case sensitivity.- Parameters:
pattern- the regular expressioncaseSensitive- match letter case exactly- Returns:
{row, col}pairs, 0-based, in row-major order- Throws:
AxyraException- ifpatternis not a valid regular expression
-
find
Finds cells asfind(String)does, keeping only the cells whose resolved style matchesformat: Excel's Find with Format. SeeFindFormatfor how styles are matched. An emptytextwith a non-empty format finds by format only: it returns every cell that carries the format, whatever its value type.- Parameters:
text- the text to look for; empty to find by format onlyformat- the style to match; notnull- Returns:
{row, col}pairs, 0-based, in row-major order
-
find
public int[][] find(String text, boolean caseSensitive, boolean matchEntire, boolean wildcard, FindFormat format) Finds cells by text and format, asfind(String, FindFormat)does, with Excel's Find options.- Parameters:
caseSensitive- match letter case exactlymatchEntire- the whole cell text must match, not a substringwildcard- treat*,?and~as Excel wildcardsformat- the style to match; notnull- Returns:
{row, col}pairs, 0-based, in row-major order
-
replaceAll
Replacesfindwithreplacein every text cell of the sheet that contains it, ignoring case. Formula cells are skipped, even when their result matches. A changed cell keeps its style and holds the new text as text: a result that looks like a number is not converted. Formulas that read the changed cells see the new values.- Returns:
- the number of cells changed
-
replaceAll
public int replaceAll(String find, String replace, boolean caseSensitive, boolean matchEntire, boolean wildcard) Replaces text asreplaceAll(String, String)does, with Excel's Replace options.- Parameters:
caseSensitive- match letter case exactlymatchEntire- replace only in cells whose whole text matcheswildcard- treat*,?and~infindas Excel wildcards- Returns:
- the number of cells changed
-
replaceAllRegex
Replaces every match of the regular expressionpattern, ignoring case, in every text cell of the sheet.replacementmay refer to capture groups, as"$1"or"${name}". Formula cells are skipped. The pattern uses the Rustregexcrate syntax. Changed cells keep their style, as withreplaceAll(String, String).- Returns:
- the number of cells changed
- Throws:
AxyraException- ifpatternis not a valid regular expression
-
replaceAllRegex
Replaces regular-expression matches asreplaceAllRegex(String, String)does, with a choice of case sensitivity.- Parameters:
caseSensitive- match letter case exactly- Returns:
- the number of cells changed
- Throws:
AxyraException- ifpatternis not a valid regular expression
-
replaceAll
Replaces text asreplaceAll(String, String)does, only in the cells whose resolved style matchesformat. SeeFindFormatfor how styles are matched. An emptyfindtext replaces nothing.- Parameters:
format- the style to match; notnull- Returns:
- the number of cells changed
-
replaceAll
public int replaceAll(String find, String replace, boolean caseSensitive, boolean matchEntire, boolean wildcard, FindFormat format) Replaces text by format, asreplaceAll(String, String, FindFormat)does, with Excel's Replace options.- Parameters:
caseSensitive- match letter case exactlymatchEntire- replace only in cells whose whole text matcheswildcard- treat*,?and~infindas Excel wildcardsformat- the style to match; notnull- Returns:
- the number of cells changed
-
textToColumns
Splits text in place, as Excel's Text to Columns does in delimited mode. Each text cell of the one-columnsrcRange, such as"A1:A10", is split on thedelimiterscharacters. The fields fill the cells to the right, starting in the source column, and overwrite what is there without a prompt.Number and boolean source cells are copied to the destination unchanged. Blank cells are skipped. A field that parses as a number is written as a number. An empty field clears its destination cell. Text inside double quotes is not split.
- Parameters:
srcRange- one-column source range in A1 notationdelimiters- the split characters, such as","or";\t": tab, semicolon, comma and space, plus at most one other character- Returns:
- the number of output columns of the widest row
- Throws:
IllegalArgumentException- ifsrcRangeis more than one column wide or cannot be parsedAxyraException- ifdelimitersnames no delimiter, or more than one character besides tab, semicolon, comma and space
-
textToColumns
Splits text in place astextToColumns(String, String)does, optionally treating a run of delimiters as one split point: Excel's "Treat consecutive delimiters as one", useful for space-aligned text.- Parameters:
treatConsecutiveAsOne-trueto merge runs of delimiters- Returns:
- the number of output columns of the widest row
-
textToColumns
public int textToColumns(String srcRange, int destRow, int destColumn, String delimiters, boolean treatConsecutiveAsOne) Splits text astextToColumns(String, String)does, writing the fields to another place: the fields of source rowigo to rowdestRow + i, starting atdestColumn. The source range must be exactly one column wide, as in Excel.- Parameters:
destRow- 0-based row that receives source row 0destColumn- 0-based first output columntreatConsecutiveAsOne-trueto merge runs of delimiters- Returns:
- the number of output columns of the widest row
- Throws:
IllegalArgumentException- ifsrcRangeis more than one column wide or cannot be parsedAxyraException- ifdelimitersnames no delimiter, or more than one character besides tab, semicolon, comma and space
-
validations
Returns every data-validation rule on this sheet, in stored order. Add a rule withRange.setValidation(io.keikai.axyra.sheets.content.Validation).- Returns:
- a new list of snapshots; later edits do not change it
-
clearValidations
public void clearValidations()Removes every data-validation rule from this sheet; the cell values stay. -
removeValidation
public boolean removeValidation(int validationIndex) Removes the data-validation rule atvalidationIndex, its 0-based position invalidations(). Later rules move down one place.- Returns:
trueif a rule was removed;falsewhen the index is negative or at or past the rule count
-
conditionalFormats
Returns every conditional-formatting rule on this sheet, in stored order. Add a rule withRange.addConditionalFormat(io.keikai.axyra.sheets.content.ConditionalFormat).- Returns:
- a new list of snapshots; later edits do not change it
-
clearConditionalFormats
public void clearConditionalFormats()Removes every conditional-formatting rule from this sheet. -
removeConditionalFormat
public boolean removeConditionalFormat(int formatIndex) Removes the conditional-formatting rule atformatIndex, its 0-based position inconditionalFormats(). Later rules move down one place.- Returns:
trueif a rule was removed;falsewhen the index is negative or at or past the rule count
-
tables
Returns every table on this sheet (Excel's ListObjects), with its range, columns, style and totals state. Create one withRange.createTable(String, String...).- Returns:
- a new list of snapshots; later edits do not change it
-
removeTable
Removes the table definition namednameand leaves its cells, values and styles in place. It is the same operation asconvertTableToRange(java.lang.String). Formulas that use structured references to the table, such asSales[Amount], are not rewritten and stop resolving. The name match is case-sensitive.- Returns:
trueif a table was removed
-
convertTableToRange
Converts the named table back to an ordinary range, as Excel's Table Design > Convert to Range does: drops the table definition and keeps every cell value and style in place. This is the inverse ofRange.createTable(String, String...), and the same operation asremoveTable(java.lang.String).Unlike Excel, formulas that use structured references to the table are not rewritten to A1 references, so they stop resolving. The name match is case-sensitive.
- Returns:
trueif a table was converted
-
resizeTable
Resizes the named table tonewRange, as Excel's Table Design > Resize Table does. The header row must stay where it is, and at least one data row must remain. Columns are matched by sheet position: a kept position keeps its column definition, totals and formulas included. A new position takes its header cell's text as its name, or a generated uniqueColumnNname when that cell is empty.- Parameters:
newRange- the new table area on this sheet, header row included- Returns:
trueif the table was resized;falsewhen no table has that name or the new range breaks a rule above
-
autoExpandTables
Applies Excel's table auto-expansion for an entry typed at(row, col). Typing one row below a table's last data row, inside its column span, grows the table by one row when it has no totals row. Typing in the header row one column right of its last column grows the table by one column namedtypedText, unless another table occupies that column. Only the table definition changes; write the cell value separately.- Parameters:
row- 0-based row of the entrycol- 0-based column of the entrytypedText- the typed text, used as a new column's name;nullacts as an empty string- Returns:
trueif any table expanded
-
smartArtCount
public int smartArtCount()Returns the number of SmartArt diagrams anchored on this sheet. -
smartArts
Returns the SmartArt diagrams anchored on this sheet as read-only descriptors: layout family, anchor and visible node texts. Diagrams read from a file render in PDF and image output and are saved back unchanged. The API has no method that creates or edits a diagram.- Returns:
- a new list; empty when the sheet has none
-
setTableStyle
Replaces the style settings of the named table (ECMA-376 §18.5.1.20tableStyleInfo): the style name and the banding and first/last-column flags. The table part is regenerated on the next save.- Parameters:
style- the new settings; notnull- Returns:
trueif a table with that name exists
-
setTableTotalsRow
Shows or hides the named table's totals row (ECMA-376 §18.5.1.2totalsRowCount). Showing extends the table range one row down and writes the configured totals cells,SUBTOTALformulas and labels, into that row, as Excel does. What was in that row is overwritten. Hiding shrinks the range back and empties the cells of the old totals row. Set the per-column totals withsetTableColumnTotals(java.lang.String, java.lang.String, io.keikai.axyra.sheets.TotalsRowFunction).- Returns:
trueif a table with that name exists
-
setTableHeaderRow
Shows or hides the named table's header row (ECMA-376 §18.5.1.2headerRowCount). Unlike the totals row, this does not resize the table range: the first row of the range is read as the header (shown) or as the first data row (hidden).Range.createTable(java.lang.String, java.lang.String...)always makes a table with a header row. To rebuild a table that has none, passfalsehere; otherwise Excel treats the first data row as the header and may refuse to open the file.- Returns:
trueif a table with that name exists
-
setTableColumnTotals
public boolean setTableColumnTotals(String tableName, String columnName, TotalsRowFunction function) Sets the totals-row function of one column of the named table (ECMA-376 §18.18.92ST_TotalsRowFunction). A built-in function becomes aSUBTOTAL(101..110, Table[Column])cell when the totals row is shown; when it is shown already, the cell is rewritten at once. UsesetTableColumnTotals(String, String, TotalsRowFunction, String, String)forCUSTOM, which needs a formula, or for a label. Table and column names match case-sensitively.- Parameters:
function- the function;nullremoves the column's total- Returns:
trueif the table and column exist;falseforCUSTOM, which needs the five-argument form
-
setTableColumnTotals
public boolean setTableColumnTotals(String tableName, String columnName, TotalsRowFunction function, String label, String formula) Sets the totals-row function, label and custom formula of one column of the named table. When the totals row is shown, its cell for this column is rewritten at once: the function's formula, else the label. Table and column names match case-sensitively.- Parameters:
function- the function, ornullfor a label onlylabel- the text fortotalsRowLabel, ornullformula- the totals formula; required forTotalsRowFunction.CUSTOMand ignored otherwise- Returns:
trueif the totals were set;falsewhen the table or column does not exist, or whenfunctionisCUSTOMandformulaisnull
-
addChart
Adds a chart to this sheet. Build the spec withChart.of(java.lang.String), or from an existing chart withChart.toBuilder(). The chart's drawing part is generated on save.- Returns:
- the new chart's 0-based index in
charts()
-
addPivotChart
public int addPivotChart(int pivotIndex, String chartType, int fromRow, int fromCol, int toRow, int toCol) Add a PivotChart bound to the pivot table atpivotIndexon this sheet, anchored over the given cell rectangle. The pivot must have been refreshed first so its output range is known; the chart's series are derived from that output (one series per data column, categories from the row-label column, grand totals excluded) and the chart carries Excel'spivotSourcebinding (ECMA-376 §21.2.2.153) so it stays linked to the pivot on open.- Parameters:
pivotIndex- the pivot table's 0-based index on this sheetchartType- a chart type token accepted byChart.of(java.lang.String), such as"column","bar"or"pie"; an unknown token gives a column chartfromRow- 0-based top row of the chart anchorfromCol- 0-based left column of the chart anchortoRow- 0-based bottom row of the chart anchortoCol- 0-based right column of the chart anchor- Returns:
- the new chart's 0-based index on this sheet, or
-1when the pivot does not exist (a negative index included), has not been refreshed, or its output has no value column or no body row
-
charts
Returns every chart on this sheet, in drawing order. Edit one withchart(int)orreplaceChart(int, io.keikai.axyra.sheets.content.Chart).- Returns:
- a new list of snapshots; later edits do not change it
-
chart
Returns a live view of the chart atchartIndex, its 0-based position incharts(). Getters read the engine state captured when the view was made or last reloaded; each setter writes to the engine at once.- Parameters:
chartIndex- 0-based chart index- Throws:
AxyraException- ifchartIndexis negative or at or past the chart count
-
replaceChart
Applychart's spec onto the chart already atchartIndex, in place, keeping its position incharts().The engine overlays the spec rather than swapping the chart out, so detail the spec does not carry survives — per-series trendlines, error bars and data labels when the matching series is silent about them, plus the parts of an imported chart the spec has no field for (3-D view angles, manual layouts, an Excel-2016 extended chart's preserved apparatus, a PivotChart binding). Marks the sheet's drawing dirty, so the saved package carries the edit.
This is the read–modify–write counterpart of
addChart(io.keikai.axyra.sheets.content.Chart): read withcharts(), edit throughChart.toBuilder(), write back here. Editing one field at a time throughchart(int)does the same thing one round trip at a time.- Parameters:
chartIndex- 0-based index incharts()chart- the spec to apply- Throws:
AxyraException- ifchartIndexis negative or at or past the chart count
-
clearCharts
public void clearCharts()Removes every chart from this sheet. -
removeChart
public boolean removeChart(int chartIndex) Removes the chart atchartIndex, its 0-based position incharts(). Later charts move down one place.- Returns:
trueif a chart was removed;falsewhen the index is negative or at or past the chart count
-
addCheckbox
public int addCheckbox(String name, int fromRow, int fromColumn, int toRow, int toColumn, String linkedCell) Adds a check box form control over a cell rectangle, optionally bound to a linked cell that holds its state. A shortcut foraddFormControl(FormControl)with aFormControl.checkBox(String)spec.- Parameters:
name- the check box captionfromRow- 0-based top row of the anchorfromColumn- 0-based left column of the anchortoRow- 0-based bottom row of the anchortoColumn- 0-based right column of the anchorlinkedCell- A1 reference of the cell that receives TRUE or FALSE, ornullfor none- Returns:
- the new control's 0-based index in
formControls()
-
formControlCount
public int formControlCount()Returns the number of form controls on this sheet, the size offormControls(). Cheaper than reading the full list. -
addFormControl
Adds a form control: check box, option button, button, combo box, list box, scroll bar, spin button, edit box, label or group box. The control's parts (control properties, legacy drawing shape and worksheet registration) are generated on save.- Returns:
- the new control's 0-based index in
formControls() - Throws:
AxyraException- if the control spec cannot be encoded
-
formControls
Returns every form control on this sheet, in z-order.- Returns:
- a new list of snapshots; later edits do not change it
-
updateFormControl
Replaces the form control atcontrolIndex, its 0-based position informControls(). The replacement is complete: read a control, change it throughFormControl.toBuilder(), and write it back.- Parameters:
controlIndex- 0-based control index- Returns:
trueif a control was replaced;falsewhencontrolIndexis negative or at or past the control count- Throws:
AxyraException- if the control spec cannot be encoded
-
removeFormControl
public boolean removeFormControl(int controlIndex) Removes the form control atcontrolIndex, its 0-based position informControls(). Later controls move down one place.- Returns:
trueif a control was removed;falsewhen the index is negative or at or past the control count
-
addPivotTable
Creates an empty pivot table whose top-left cell islocation(A1, such as"H1") over the source rangesourceRef, such as"Data!A1:D100". Add fields throughpivotTable(int). Its output is built byPivotTableView.refresh(). A pivot created or changed through the API and not refreshed since is also refreshed automatically before the workbook is saved or rendered.The name, location and source are not checked here; a bad source reference fails when the pivot is refreshed.
- Returns:
- the new pivot's 0-based index, for
pivotTable(int)
-
pivotCount
public int pivotCount()Returns the number of pivot tables on this sheet. Valid pivot indexes are0topivotCount() - 1. -
pivotName
Returns the name of the pivot table atpivotIndex.- Parameters:
pivotIndex- 0-based pivot index- Returns:
- the name, or
nullwhenpivotIndexis negative or at or pastpivotCount()
-
pivotLocation
Returns the location of the pivot table atpivotIndexas an A1 reference, such as"H1".- Parameters:
pivotIndex- 0-based pivot index- Returns:
- the location, or
nullwhen the index is out of range
-
pivotSource
Returns the source data reference of the pivot table atpivotIndex, such as"Data!A1:D100".- Parameters:
pivotIndex- 0-based pivot index- Returns:
- the reference, or
nullwhen the index is out of range
-
pivotTable
Returns a live view of the pivot table atpivotIndex: field areas (row, column, filter, values), aggregation functions, layout, grand totals andPivotTableView.refresh().- Parameters:
pivotIndex- 0-based pivot index- Throws:
AxyraException- ifpivotIndexis negative or at or pastpivotCount()
-
pivotTable
Returns a live view of the pivot table namedname. An exact match wins; otherwise the name matches case-insensitively.- Throws:
AxyraException- if no pivot table on this sheet has that name
-
addScenario
Adds a what-if scenario to this sheet.cellRefs[i], an A1 reference on this sheet such as"B2", getsvalues[i]when the scenario is shown; extra entries in the longer array are ignored. A scenario with the same name as an existing one is added as a second scenario. The sheet's cells do not change untilshowScenario(int).- Parameters:
name- the scenario namecellRefs- the changing cells, as A1 references on this sheetvalues- the value for each changing cell, as text- Returns:
- the new scenario's 0-based index
-
scenarioCount
public int scenarioCount()Returns the number of what-if scenarios on this sheet. -
scenarioName
Returns the name of the scenario atscenarioIndex.- Parameters:
scenarioIndex- 0-based scenario index- Returns:
- the name, or
nullwhenscenarioIndexis negative or at or pastscenarioCount()
-
showScenario
public boolean showScenario(int scenarioIndex) Applies the scenario atscenarioIndex: writes each of its changing-cell values into the sheet. A value that parses as a number is written as a number; any other value is written as text, never as a formula. Formulas that read those cells recalculate as for any cell write.- Parameters:
scenarioIndex- 0-based scenario index- Returns:
trueif the scenario was applied;falsewhenscenarioIndexis negative or at or pastscenarioCount()
-
addPicture
public int addPicture(byte[] imageData, String format, int fromRow, int fromColumn, int toRow, int toColumn) Inserts an embedded image over the cell rectangle from(fromRow, fromColumn)to(toRow, toColumn). All indexes are 0-based. The picture's bottom-right corner sits on the top-left edge of(toRow, toColumn), so that cell is outside the picture, as in a DrawingML two-cell anchor. Use the 10-argument overload for sub-cell offsets.- Parameters:
imageData- the encoded image bytesformat-png,jpeg(orjpg),gif,bmp,tiff,emf,wmf,svgorwebp; any other token is stored as an unknown format, andpictureFormat(int)reports it as"png"- Returns:
- the new picture's 0-based index
-
addPicture
public int addPicture(byte[] imageData, String format, int fromRow, int fromColumn, int fromRowOffset, int fromColumnOffset, int toRow, int toColumn, int toRowOffset, int toColumnOffset) Inserts an embedded image with a full two-cell anchor, offsets included. Cell indexes are 0-based. Offsets are in EMU (914,400 per inch, 12,700 per point), measured from the top-left corner of the given cell. They carry a sub-cell position and size that a plain cell rectangle cannot express. An image anchored to one cell usestoRow == fromRowandtoColumn == fromColumnand carries its size in theto*Offsetvalues. Read the eight values back withpictureAnchorFull(int).- Parameters:
format- the image format, as foraddPicture(byte[], String, int, int, int, int)- Returns:
- the new picture's 0-based index
-
pictureCount
public int pictureCount()Returns the number of pictures on this sheet, embedded and linked. -
addLinkedPicture
Adds a linked picture over the cell rectangle from(r1, c1)to(r2, c2): the image is referenced by an externaltarget, a URL or a path, through<a:blip r:link>instead of embedding bytes (ECMA-376 Part 1 §20.1.8.13). Indexes are 0-based; the cell(r2, c2)is outside the picture, as withaddPicture(byte[], java.lang.String, int, int, int, int). UseaddPicture(byte[], java.lang.String, int, int, int, int)for the usual embedded case.- Returns:
- the new picture's 0-based index, or
-1when the picture could not be added
-
pictureLinkTarget
Returns the external link target of the picture atpictureIndex, ornullwhen it is an embedded picture or the index is out of range. -
setPictureLinkTarget
Repoints a linked picture at a new source.Returns
falsefor an embedded picture: its bytes live in the package, so giving it a link would leave the file carrying both the image and a reference to another one. UseaddLinkedPicture(String, String, int, int, int, int)to add a linked picture in the first place.- Returns:
trueif the target was changed;falsealso whentargetis empty orpictureIndexis out of range
-
anchorOleObject
public boolean anchorOleObject(int objectIndex, byte[] iconBytes, String iconFormat, int fromRow, int fromCol, int toRow, int toCol) Display the workbook-level embedded OLE object atobjectIndex(seeWorkbook.addOleObject(java.lang.String, java.lang.String, byte[])) as an icon on this sheet, anchored over the cell rectangle(fromRow, fromCol)–(toRow, toCol)(0-based, exclusive bottom-right edge like a drawing anchor).iconBytesis the image shown on the sheet (iconFormat:"png","jpeg","gif","bmp","tiff","emf","wmf"); double-clicking the icon in Excel opens the embedded content.Returns whether the anchor was added —
falsewhen the object index does not exist, the icon bytes are empty, or this sheet already carries OLE anchors imported from an opened XLSX (merging authored icons into an imported legacy drawing is not supported). -
pictureData
public byte[] pictureData(int pictureIndex) Returns the encoded image bytes of the picture atpictureIndex, ornullwhen the index is out of range. -
pictureFormat
Returns the format token of the picture atpictureIndex, such as"png"or"jpeg", ornullwhen the index is out of range. An unknown format reads back as"png". -
pictureAnchor
public int[] pictureAnchor(int pictureIndex) Returns{fromRow, fromCol, toRow, toCol}of the picture's two-cell anchor, 0-based, or an empty array when the index is out of range. Offsets are left out, so the image may reach into thetocell; usepictureAnchorFull(int)for an exact copy. -
pictureAnchorFull
public int[] pictureAnchorFull(int pictureIndex) Returns{fromRow, fromCol, fromRowOffset, fromColOffset, toRow, toCol, toRowOffset, toColOffset}of the picture's anchor: 0-based cells and offsets in EMU. Returns an empty array when the index is out of range. Pass these eight values to the 10-argumentaddPicture(byte[], String, int, int, int, int, int, int, int, int)to place a copy at exactly the same position. -
clearPictures
public void clearPictures()Removes every picture from this sheet, embedded and linked. -
removePicture
public boolean removePicture(int pictureIndex) Removes the picture atpictureIndex, the 0-based index thatpictureData(int)uses. Later pictures move down one place.- Returns:
trueif a picture was removed;falsewhen the index is negative or at or pastpictureCount()
-
setBackgroundImage
Sets the sheet background image. Excel tiles the image behind the cells on screen; it is never printed. Replaces any existing background.- Parameters:
imageData- the encoded image bytesformat- the image format, as foraddPicture(byte[], String, int, int, int, int); an unknown token is saved as PNG
-
backgroundImage
public byte[] backgroundImage()Returns the encoded bytes of the sheet background image, ornullwhen there is none. -
backgroundImageFormat
Returns the format token of the sheet background image, such as"png", ornullwhen there is none. -
clearBackgroundImage
public boolean clearBackgroundImage()Removes the sheet background image.- Returns:
trueif an image was removed
-
setLandscape
public void setLandscape(boolean landscape) Sets the print orientation:truefor landscape,falsefor portrait. -
isLandscape
public boolean isLandscape()Returns whether the sheet prints in landscape;falsemeans portrait, the default. -
setPrintArea
Sets the print area as an A1 range on this sheet, such as"$A$1:$F$40". The string is stored as given and not checked. APrint_Areaname read from the file for this sheet is replaced.- Parameters:
a1Range- the range, ornullto clear the print area
-
printArea
Returns the print area as an A1 range string, ornullwhen the sheet has none. -
setPrintTitleRows
Sets the rows repeated at the top of every printed page, such as"$1:$2". The string is stored as given and not checked. APrint_Titlesname read from the file for this sheet is replaced.- Parameters:
rowsRange- the row band, ornullto clear it
-
printTitleRows
Returns the rows repeated at the top of every printed page, such as"$1:$2", ornullwhen none are set. -
setPrintTitleColumns
Sets the columns repeated at the left of every printed page, such as"$A:$A". The string is stored as given and not checked.- Parameters:
columnsRange- the column band, ornullto clear it
-
printTitleColumns
Returns the columns repeated at the left of every printed page, such as"$A:$A", ornullwhen none are set. -
setPrintGridlines
public void setPrintGridlines(boolean on) Sets whether gridlines are printed. The on-screen gridlines are set bysetShowGridlines(boolean). -
printGridlines
public boolean printGridlines()Returns whether gridlines are printed (ECMA-376 §18.3.1.65printOptions/gridLines). -
setPrintHeadings
public void setPrintHeadings(boolean on) Sets whether row numbers and column letters are printed (ECMA-376 §18.3.1.70printOptions/headings). It controls the printout only; the on-screen headings are set bysetShowRowColHeaders(boolean). -
setPageOrderOverThenDown
public void setPageOrderOverThenDown(boolean overThenDown) Sets the page order:trueprints across, then down ("Over, then down");falseprints down, then across, Excel's default (ECMA-376 §18.3.1.63pageOrder). -
pageOrderOverThenDown
public boolean pageOrderOverThenDown()Returns whether pages print across, then down;falsemeans down, then across. -
setPrintBlackAndWhite
public void setPrintBlackAndWhite(boolean on) Sets whether the sheet prints in black and white (ECMA-376 §18.3.1.63blackAndWhite). -
printBlackAndWhite
public boolean printBlackAndWhite()Returns whether the sheet prints in black and white. -
setPrintDraft
public void setPrintDraft(boolean on) Sets whether the sheet prints in draft quality, without graphics (ECMA-376 §18.3.1.63draft). -
printDraft
public boolean printDraft()Returns whether the sheet prints in draft quality. -
setPrintErrors
public void setPrintErrors(int mode) Sets how error cells print (ECMA-376 §18.3.1.70printOptions/errors).- Parameters:
mode- 0 as displayed, 1 blank, 2 as a dash, 3 as#N/A; any other code is treated as 0
-
printErrors
public int printErrors()Returns how error cells print, as the codesetPrintErrors(int)takes. -
setFirstPageNumber
public void setFirstPageNumber(int number) Sets the number printed on the first page (ECMA-376 §18.3.1.63firstPageNumbertogether withuseFirstPageNumber).- Parameters:
number- the first page number;0restores automatic numbering
-
firstPageNumber
public int firstPageNumber()Returns the number printed on the first page, or0when numbering is automatic. -
setPrintComments
public void setPrintComments(int mode) Sets where cell comments print (ECMA-376 §18.3.1.63cellComments).- Parameters:
mode- 0 not at all, 1 as displayed on the sheet, 2 at the end of the printout; any other code is treated as 0
-
printComments
public int printComments()Returns where cell comments print, as the codesetPrintComments(int)takes. -
setPrintResolution
public void setPrintResolution(int dpi) Sets the printer resolution in dots per inch, for both axes.- Parameters:
dpi- the resolution, such as 600
-
printResolution
public int printResolution()Returns the printer resolution in dots per inch. -
printHeadings
public boolean printHeadings()Returns whether row numbers and column letters are printed. -
fitToPage
public void fitToPage(int width, int height) Scales the printout to fitwidthpages wide byheightpages tall, and turns on fit-to-page, sopageScale()is ignored.setPageScale(int)turns fit-to-page off again.- Parameters:
width- pages wide;0means no limit in that direction, as Excel's blank "pages wide" box, and a negative value is treated as 0height- pages tall;0means no limit, and a negative value is treated as 0
-
isFitToPage
public boolean isFitToPage()Returns whether fit-to-page scaling is on, asfitToPage(int, int)sets it. Whenfalse, the sheet prints atpageScale(). The flag is<pageSetUpPr fitToPage="1"/>(ECMA-376 §18.3.1.70). -
fitToWidth
public int fitToWidth()Returns the number of pages wide the printout is fitted to, or0for no limit (ECMA-376 §18.3.1.63fitToWidth). It applies only whenisFitToPage()istrue. -
fitToHeight
public int fitToHeight()Returns the number of pages tall the printout is fitted to, or0for no limit (ECMA-376 §18.3.1.63fitToHeight). It applies only whenisFitToPage()istrue. -
setPageScale
public void setPageScale(int scalePercent) Sets the print scale in percent and turns fit-to-page off. Excel accepts 10 to 400; this method does not check the value, and a negative value is stored as 0. The on-screen zoom is set bysetZoom(int).- Parameters:
scalePercent- the scale in percent, 100 for actual size
-
pageScale
public int pageScale()Returns the print scale in percent; 100 means actual size. -
setPaperSize
public void setPaperSize(int paperSize) Sets the paper size from its ECMA-376 numeric code (§18.18.50ST_PaperSize): 1 = Letter, 5 = Legal, 8 = A3, 9 = A4, 11 = A5, and so on.- Throws:
AxyraException- ifpaperSizeis below 1
-
paperSize
public int paperSize()Returns the paper size as its ECMA-376 numeric code; 9 (A4) when none is declared. CheckisPaperSizeDeclared()to tell the two apart. -
isPaperSizeDeclared
public boolean isPaperSizeDeclared()Returns whether this sheet declares a paper size. A loaded sheet whose<pageSetup>has nopaperSizereportsfalse. Excel then prints it on the printer's default paper, whateverpaperSize()reports. -
clearPaperSize
public void clearPaperSize()Removes the paper-size declaration, so the saved sheet has nopaperSizeattribute and Excel uses the printer's default paper. The nextsetPaperSize(int)declares a size again. -
printHorizontallyCentered
public boolean printHorizontallyCentered()Returns whether the printout is centered horizontally on the page (<printOptions horizontalCentered>, ECMA-376 §18.3.1.70). -
setPrintHorizontallyCentered
public void setPrintHorizontallyCentered(boolean centered) Sets whether the printout is centered horizontally on the page. -
printVerticallyCentered
public boolean printVerticallyCentered()Returns whether the printout is centered vertically on the page (<printOptions verticalCentered>, ECMA-376 §18.3.1.70). -
setPrintVerticallyCentered
public void setPrintVerticallyCentered(boolean centered) Sets whether the printout is centered vertically on the page. -
setPageMargins
public void setPageMargins(double left, double right, double top, double bottom, double header, double footer) Sets the six page margins in inches (ECMA-376 §18.3.1.62pageMargins).headerandfooterare the distances from the page edge to the header and footer text.- Throws:
AxyraException- if any value is negative
-
setPageMargins
Sets the page margins from aPageMarginsvalue, in inches. It is the counterpart ofpageMargins(), so a read, change and write needs no unpacking into six arguments.- Parameters:
m- the margins; notnull- Throws:
AxyraException- if any value is negative
-
pageMargins
Returns the six page margins in inches, as a snapshot. -
setZoom
public void setZoom(int percent) Sets the on-screen zoom in percent. It does not affect printing; usesetPageScale(int)for the print scale.- Parameters:
percent- the zoom, from 10 to 400- Throws:
AxyraException- ifpercentis outside 10 to 400
-
zoom
public int zoom()Returns the on-screen zoom in percent; 100 by default. -
protect
public void protect()Protects this sheet with Excel's default allowances and no password. Replaces any existing protection, its password and options included. Protection is saved to the file and enforced by Excel; the SDK does not block edits made through this API. -
protect
Protects this sheet with a password and Excel's default allowances. The password is stored as an ISO write-protection hash (SHA-512 with 100,000 spins, [MS-OFFCRYPTO] §2.4.2.2). Replaces any existing protection. The SDK does not block edits made through this API.- Parameters:
password- the password;nullor empty protects without a password
-
protect
Protects this sheet with the given allowances (ECMA-376 §18.3.1.85) and an optional password. Replaces any existing protection. The SDK does not block edits made through this API.- Parameters:
password- the password;nullor empty protects without a passwordoptions- what users may still do;nullfor Excel's defaults
-
unprotect
public void unprotect()Removes sheet protection without checking any password. To check the password first, useunprotect(String). -
unprotect
Disable sheet protection after verifyingpasswordagainst the stored hash (ISO hash, or the legacy 16-bitpasswordattribute of transitional files). Returnstruewhen the sheet ends up unprotected — including when it was not protected or carries no password; returnsfalse(sheet stays protected) on a mismatch. -
isProtected
public boolean isProtected()Returns whether this sheet is protected. -
isProtectedWithPassword
public boolean isProtectedWithPassword()Returns whether the sheet's protection carries a password.Read-only: unlike
unprotect(String)this leaves the sheet protected, so a caller can decide whether to prompt without changing the workbook to find out. -
verifyProtectionPassword
Returns whetherpasswordmatches the sheet's stored hash. The protection stays in place either way.Answers
truewhenever there is no hash to disagree with — both for a sheet protected without a password and for a sheet that is not protected at all. Read as "supplying this password would let you through", which is what a caller gating anunprotect()on it needs; do not read it as "this sheet has that password". The two cases are told apart byisProtectedWithPassword(), which isfalsefor both of them. -
protection
Returns the protection options, as what users may still do, ornullwhen this sheet is not protected.- Returns:
- a snapshot; later changes do not update it
-
addProtectedRange
Adds an allow-users-to-edit-range (protectedRange— ECMA-376 Part 1 §18.3.1.72): the named rangesqrefstays editable while the sheet is protected. Pass apasswordto gate it, stored as an ISO write-protection hash, ornullfor an ungated range. An emptypasswordis the same asnull. Adding a range whose name matches an existing one case-insensitively replaces it.- Parameters:
name- the range namesqref- space-separated A1 ranges on this sheet, such as"A1:B5 D1"- Throws:
AxyraException- ifnameorsqrefis empty or blank
-
addProtectedRange
Adds an allow-edit range without a password; seeaddProtectedRange(String, String, String).- Throws:
AxyraException- ifnameorsqrefis empty or blank
-
removeProtectedRange
Removes the allow-edit range namedname.- Returns:
trueif a range was removed
-
protectedRanges
Returns the sheet's allow-edit ranges, in the order they were defined.- Returns:
- a new list of snapshots; later edits do not change it
-
verifyProtectedRangePassword
Returns whetherpasswordmatches the stored hash of the allow-edit rangename, matched case-insensitively. Returnsfalsewhen no range has that name and when the range has no password. UnlikeverifyProtectionPassword(String), a missing password does not count as a match. -
setAutoFilter
Defines an auto-filter overrange; its top row holds the filter buttons. Replaces any existing auto-filter on this sheet, with its column criteria. This call does not hide or show rows. Set a column criterion withsetColumnFilter(int, java.lang.String...)or anothersetColumn*Filtermethod, which runs the filter at once, or callapplyAutoFilter(). -
autoFilterRange
Returns the filtered block, header row included, ornullwhen this sheet has no auto-filter.Read counterpart of
setAutoFilter(Range): a caller that did not set the filter itself (an imported workbook, for example) needs to know which block the dropdowns cover. -
hasAutoFilter
public boolean hasAutoFilter()Returns whether this sheet has an auto-filter. UseautoFilterRange()to get the filtered block. -
clearAutoFilter
public void clearAutoFilter()Removes the auto-filter and its criteria. Rows it hid stay hidden; show them withsetRowHidden(int, boolean)or clear the criteria first withclearColumnFilter(int). -
setColumnFilter
Keeps only the rows whose cell in the filter column is one ofvalues. Takes effect at once, as in Excel: rows that fail are hidden and rows that pass are shown. EverysetColumn*FilterandclearColumnFilter(int)runs the filter this way. A criterion replaces any earlier criterion on the same column. Does nothing when this sheet has no auto-filter; callsetAutoFilter(Range)first.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangevalues- the cell texts to keep;nullentries are ignored
-
setColumnCustomFilter
Sets a one-condition custom filter on a column, such as "greater than 100", and runs the filter. Behaves assetColumnFilter(int, java.lang.String...)for replacement and for a sheet without an auto-filter.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangevalue- the value to compare with
-
setColumnCustomFilter
public void setColumnCustomFilter(int columnIndex, FilterOperator op1, String value1, FilterOperator op2, String value2, boolean andJoin) Sets a two-condition custom filter on a column and runs the filter. Behaves assetColumnFilter(int, java.lang.String...)for replacement and for a sheet without an auto-filter.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangeandJoin-trueto require both conditions,falseto require either
-
setColumnColorFilter
Filters a column by cell fill color, or by font color whencellColorisfalse: only rows whose cell hascolorstay visible. Runs the filter at once and behaves assetColumnFilter(int, java.lang.String...)for replacement and for a sheet without an auto-filter. Only the RGB part ofcoloris used; its alpha is dropped.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangecolor- an RGB color; notnull- Throws:
IllegalStateException- ifcoloris a theme, indexed or automatic colorAxyraException- ifcolorisnull
-
setColumnTop10Filter
public void setColumnTop10Filter(int columnIndex, boolean percent, double value, boolean bottom) A Top-10 filter (ECMA-376 §18.3.2.10) on a column: keep the topvalueitems — orvaluepercent of the items whenpercentis true;bottomflips to the smallest values. The threshold is computed from the column data each time the filter runs; non-numeric cells are hidden, and ties at the threshold stay visible. Runs the filter at once.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangepercent-trueto readvalueas a percentage of the itemsvalue- the number of items, or the percentagebottom-trueto keep the smallest values instead
-
setColumnDynamicFilter
A dynamic filter (ECMA-376 §18.3.2.5) on a column: today / thisWeek / lastMonth / yearToDate / aboveAverage / and so on. Runs the filter at once. Date ranges resolve against the current date on the machine's clock, and the column average is computed, each time the filter runs.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter range
-
setColumnDateFilter
A date grouping filter (ECMA-376 §18.3.2.4) on a column: a date cell stays visible if it falls inside any ofitems. Blank cells are hidden; use theincludeBlankoverload to keep them. Runs the filter at once.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter range
-
setColumnDateFilter
Sets a date grouping filter assetColumnDateFilter(int, DateGroupItem...)does, optionally keeping blank cells too.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter rangeincludeBlank-trueto keep rows whose cell is blank
-
clearColumnFilter
public void clearColumnFilter(int columnIndex) Removes the criterion from one column and runs the filter, so rows that now pass are shown again.- Parameters:
columnIndex- 0-based column, counted from the first column of the auto-filter range
-
sortByColor
public void sortByColor(Range range, int sortColumnIndex, boolean cellColor, boolean hasHeader, Color... colors) Sort the rows ofrangeby cell fill color (or font color whencellColoris false) atsortColumnIndex(0-based, relative to the range start). Rows are ordered by their color's position incolors; rows with unlisted colors sort last and keep their order. WhenhasHeaderistrue, the first row stays in place. Only the RGB part of each color is used; its alpha is dropped.- Throws:
IllegalStateException- if a color is a theme, indexed or automatic color
-
applyAutoFilter
public int applyAutoFilter()Execute the auto-filter: hides every data row failing any column's criteria and shows the rest. Returns the number of rows hidden. All filter kinds are evaluated — values, custom, color, Top-10, dynamic (dates resolve against the current date; weeks start on Sunday), and date grouping.Setting or clearing a column criterion already runs it; call this to run the filter again after the data under it changed. Formulas that read the affected rows, such as
SUBTOTAL, recalculate.- Returns:
- the number of data rows hidden after the run, not only the newly hidden ones; 0 when this sheet has no auto-filter
-
applyAdvancedFilter
Run an advanced filter (Excel's Data > Advanced) overlistRangein place, hiding the data rows that do not matchcriteriaRange. Both ranges include a header row; criteria headers are matched to list columns by name. Criteria rows are OR-ed and the cells within one row AND-ed; each criterion cell is empty (no constraint), a comparison (>100, <=50, <>East, =East), or a bare value (numbers match by equality, text "begins with", both honoring*/?wildcards). WhenuniqueOnlyis set, duplicate matching rows are also hidden, keeping the first.- Returns:
- the number of rows hidden
-
applyAdvancedFilterCopyTo
public int applyAdvancedFilterCopyTo(Range listRange, Range criteriaRange, Range destination, boolean uniqueOnly) Advanced filter in "Copy to another location" mode: instead of hiding source rows, writes the list header plus each matching row (seeapplyAdvancedFilter(Range, Range, boolean)for the criteria semantics) starting at the top-left cell ofdestination. Cells are copied whole: value, style and formula.- Returns:
- the number of data rows written, the header row not counted
-
groupRows
public void groupRows(int startRow, int endRow) Groups rowsstartRowtoendRow, 0-based and inclusive, at outline level 1. The rows are not hidden; collapse the group withsetRowGroupCollapsed(int, int, boolean). -
setRowGroupCollapsed
public void setRowGroupCollapsed(int startRow, int endRow, boolean collapsed) Collapse or expand a grouped row range (Excel's outline +/- button): hides or shows the detail rows and sets thecollapsedflag on the group's summary row: the row below the group whensummaryBelow()istrue, else the row above.- Parameters:
startRow- 0-based first row of the groupendRow- 0-based last row of the group, inclusive
-
setColumnGroupCollapsed
public void setColumnGroupCollapsed(int startCol, int endCol, boolean collapsed) Collapses or expands a grouped column range, assetRowGroupCollapsed(int, int, boolean)does for rows.- Parameters:
startCol- 0-based first column of the groupendCol- 0-based last column of the group, inclusive
-
setRowsOutlineLevel
public void setRowsOutlineLevel(int startRow, int endRow, int level) Sets the outline level on rowsstartRowtoendRow, 0-based and inclusive.0ungroups; values above 7 are stored as 7. Rows are not hidden; usesetRowGroupCollapsed(int, int, boolean)to collapse a group. -
groupColumns
public void groupColumns(int startCol, int endCol) Groups columnsstartColtoendCol, 0-based and inclusive, at outline level 1. The columns are not hidden; collapse the group withsetColumnGroupCollapsed(int, int, boolean). -
setColumnsOutlineLevel
public void setColumnsOutlineLevel(int startCol, int endCol, int level) Sets the outline level on columnsstartColtoendCol, 0-based and inclusive.0ungroups; values above 7 are stored as 7. Columns are not hidden; usesetColumnGroupCollapsed(int, int, boolean)to collapse a group. -
rowOutlineLevel
public int rowOutlineLevel(int row) Returns a row's outline level, from 0 (not grouped) to 7.- Parameters:
row- 0-based row index
-
autoFitRow
public void autoFitRow(int row) Sets a row's height to fit its tallest content, as Excel's AutoFit Row Height does. Each cell contributes one line of its font, times its line count when the cell wraps text. Cells inside a merged region are ignored, as in Excel. A row with no content fits to the row style's font, or to the workbook's default font.- Parameters:
row- 0-based row index
-
autoFitColumn
public void autoFitColumn(int col) Sets a column's width to fit the widest text its cells display in the sheet's used rows. The width is measured on the formatted value, for example8,060.00, so a number never shows####. Does nothing on an empty sheet.- Parameters:
col- 0-based column index
-
subtotal
public int subtotal(int firstRow, int lastRow, int groupColumn, SubtotalFunction function, int... subtotalColumns) Insert subtotals into the sorted data block[firstRow, lastRow]: after each run of equal values ingroupColumn, a summary row offunctionoversubtotalColumnsis inserted (plus a grand total). Data rows get outline level 1. Rows are 0-based and inclusive;groupColumnandsubtotalColumnsare 0-based sheet columns. Returns the number of rows inserted.Like Excel, the grand total is one
SUBTOTALover the whole data body rather than aSUMof the group summaries: SUBTOTAL ignores the summaries caught inside that span, so the span keeps totalling correctly when a row is later inserted into a group.Every row of the block is data — pass
hasHeadersto the overload below for Excel's Data > Subtotal behaviour instead. -
subtotal
public int subtotal(int firstRow, int lastRow, int groupColumn, boolean hasHeaders, SubtotalFunction function, int... subtotalColumns) Insert subtotals into[firstRow, lastRow]as above. WithhasHeadersthe block follows Excel's Data > Subtotal contract: leading blank rows and the first non-blank row (the header) stay in place and never form a group of their own. WithhasHeadersfalse every row of the block is data. Returns the number of rows inserted. -
consolidate
public int[] consolidate(int destRow, int destColumn, ConsolidateFunction function, Range... sources) Consolidates several source ranges of the same shape, possibly on other sheets, into this sheet at(destRow, destColumn), as Excel's Data > Consolidate does by position. Cell(i, j)of the result aggregates cell(i, j)of every source withfunction.Each source must have the same shape as the first; other sources are skipped. Only numeric cells are read; other cells count as empty, so
ConsolidateFunction.COUNT_Acounts numeric cells only, the same asCOUNT. The result is written as numbers, not as linked formulas, so later source edits do not update it.- Parameters:
destRow- 0-based top row of the resultdestColumn- 0-based left column of the result- Returns:
{rows, columns}written;{0, 0}when no source could be used
-
addSparkline
Add a sparkline group ("line","column", or"stacked") that drawsdataRef(e.g."Sheet1!A1:A10") intolocationRef(e.g."B1"), the way Excel's Insert > Sparklines does: each cell of a one-row or one-column location gets its own sparkline over one row (or column) of the data, so"B2:G4"into"H2:H4"is three sparklines. AdataRefwithout a sheet name refers to this sheet; the data is stored sheet-qualified. An unrecognizedtypecreates a line sparkline.- Returns:
- the new group's 0-based index
- Throws:
AxyraException- if the location is not one row or column, is on another sheet, or the data has no row or column count matching it, or a reference cannot be parsed
-
setSparklineStyle
Replaces the whole style of the sparkline group atgroup: colors, point-highlight flags and axis settings. Anullcolor or axis value instyleclears that setting; it does not keep the old one. Read the current style withsparklines()andSparklineGroup.style(), change it, and pass it back.- Parameters:
group- 0-based sparkline group indexstyle- the new style; notnull- Returns:
trueif the group was restyled;falsewhengroupis negative or at or pastsparklineGroupCount()
-
sparklineGroupCount
public int sparklineGroupCount()Returns the number of sparkline groups on this sheet. -
sparklines
All sparkline groups on this sheet (ECMA-376 Part 4 §18.3.1.32,x14:sparklineGroups): the group type, basic marker/highlight style, series color and each sparkline's data range and draw location. The read-side counterpart ofaddSparkline(String, String, String).- Returns:
- a new list of snapshots; later edits do not change it
-
addShape
Adds a drawing shape, such as"rect","ellipse"or"roundRect", with optionaltext, over the cell rectangle from(fromRow, fromCol)to(toRow, toCol), 0-based. The shape gets the fill, outline and text settings Excel gives a newly inserted shape in this workbook's theme. Passing"textBox"adds a text box, asaddTextBox(java.lang.String, int, int, int, int)does.- Parameters:
text- the shape's text, ornullfor none- Returns:
- the new shape's 0-based index
-
groupShapes
Group existing shapes into one<xdr:grpSp>container (Excel's "Group").shapeIndexesare this sheet's shape indexes; at least two ungrouped, non-group shapes are required. The members keep their indexes and the group is appended as a new shape entry whose anchor is the members' bounding box. Returns the group's shape index, or-1when the set is not groupable. -
ungroupShapes
public boolean ungroupShapes(int shapeIndex) Dissolve a group created bygroupShapes(java.lang.String, int...): members return to standalone emission and the group entry is removed. Returns whethershapeIndexwas such a group (imported verbatim groups are not dissolvable — their children exist only inside the captured XML). -
addTextBox
Add a text box holdingtext, anchored over the cell rectangle from(fromRow, fromCol)to(toRow, toCol), 0-based; returns the new shape's 0-based index. It is written the way Excel's Insert > Text Box writes one (arectflagged<xdr:cNvSpPr txBox="1"/>), so readers tell it from a shape:isTextBox(int)answerstrue, whileshapeType(int)keeps reporting its geometry. -
addConnector
Add a connector shape (<xdr:cxnSp>) with the given preset geometry name (e.g."straightConnector1","bentConnector3","curvedConnector3","line"), anchored over the cell rectangle from(fromRow, fromCol)to(toRow, toCol), 0-based. The connector shares the shape index space withaddShape(java.lang.String, java.lang.String, int, int, int, int);shapeType(int)reports it as"connector:<preset>".- Returns:
- the new shape's 0-based index
-
shapeCount
public int shapeCount()Returns the number of shapes on this sheet, text boxes, connectors and groups included. -
removeShape
public boolean removeShape(int shapeIndex) Removes the shape atshapeIndex, the 0-based index thatshapeType(int)uses. Later shapes move down one place.- Returns:
trueif a shape was removed
-
shapeType
Returns the geometry token of the shape atshapeIndex, such as"rect". A connector is reported as"connector:<preset>", for example"connector:straightConnector1", and a group as"group". -
isTextBox
public boolean isTextBox(int shapeIndex) Returns whether the shape atshapeIndexis a text box (<xdr:cNvSpPr txBox="1"/>): one added byaddTextBox(java.lang.String, int, int, int, int)or read from a file.falsefor an unknown index. -
shapeText
Returns the shape's text, ornullwhen it has none or the index has no shape. -
shapeFillColor
Returns the shape's solid fill color as an RGB color, ornullwhen the shape has no solid RGB fill: no fill, a gradient, a pattern or a theme color. -
shapeLineColor
Returns the shape's outline color as an RGB color, ornullwhen it has no solid RGB outline. -
shapeStyleXml
Returns the raw inner XML of the shape's<xdr:style>theme style-matrix reference (thelnRef/fillRef/effectRef/fontRefchildren), ornullwhen the shape has no such block. The reference is theme-relative, so it round-trips as long as the workbook theme is preserved. -
shapeRotation
public double shapeRotation(int shapeIndex) Returns the shape's rotation in degrees, clockwise. -
shapeFlip
public boolean[] shapeFlip(int shapeIndex) Returns{flipHorizontal, flipVertical}, or an empty array when the index has no shape. -
shapeAnchor
public int[] shapeAnchor(int shapeIndex) Returns{fromRow, fromCol, toRow, toCol}of the shape's anchor, 0-based, or an empty array when the index has no shape. -
setShapeFillColor
Sets the shape's fill to a solid color, replacing any gradient or pattern fill. Only the RGB part ofcoloris used; its alpha is dropped. Does nothing whenshapeIndexhas no shape.- Parameters:
color- an RGB color, ornullto clear the fill- Throws:
IllegalStateException- ifcoloris a theme, indexed or automatic color
-
setShapeLineColor
Sets the shape's outline color. Only the RGB part ofcoloris used; its alpha is dropped. Does nothing whenshapeIndexhas no shape.- Parameters:
color- an RGB color, ornullto clear the outline color- Throws:
IllegalStateException- ifcoloris a theme, indexed or automatic color
-
setShapeStyleXml
Sets, or clears withnull, the shape's<xdr:style>theme style-matrix reference from raw inner XML (thelnRef/fillRef/effectRef/fontRefchildren, without the enclosing<xdr:style>tags). Pair withshapeStyleXml(int)to carry a theme-relative fill, line, effect and font to a copy. The XML is not checked. Does nothing whenshapeIndexhas no shape. -
setShapeRotation
public void setShapeRotation(int shapeIndex, double degrees) Sets the shape's rotation in degrees, clockwise. Does nothing whenshapeIndexhas no shape. -
setShapeText
Replaces the shape's text, or clears it withnull. The new text takes the formatting of the old first paragraph and first run; the formatting of other runs is dropped. A\nstarts a new paragraph. Does nothing whenshapeIndexhas no shape. -
setShapeFlip
public void setShapeFlip(int shapeIndex, boolean flipHorizontal, boolean flipVertical) Sets the shape's horizontal and vertical flip flags. Does nothing whenshapeIndexhas no shape. -
shapeHyperlink
Returns the hyperlink URL attached to the shape through DrawingMLhlinkClick, ornullwhen the shape has no hyperlink. -
setShapeHyperlink
Sets, or clears withnull, the shape's hyperlink URL. It is saved as a drawing-level external hyperlink relationship plus the<a:hlinkClick r:id>element on the shape. Does nothing whenshapeIndexhas no shape. -
shapeAltText
Returns the shape's alternative text (cNvPr/@descr), ornullwhen it has none. -
setShapeAltText
Sets, or clears withnull, the shape's alternative text. Does nothing whenshapeIndexhas no shape. -
shapeName
Returns the shape's drawing name (<xdr:cNvPr name>, ECMA-376 Part 1 §20.5.2.16): what Excel shows in the Name Box and what a macro uses to address the shape. A shape added through this SDK gets a generated name. Returnsnullwhen there is no shape at that index. -
setShapeName
Renames a shape. Returnsfalse, and changes nothing, for an empty name or an index with no shape: a blankcNvPr/@namewould leave the shape unreachable from both the Name Box and any macro.- Returns:
trueif the shape was renamed
-
renderChartToPng
public byte[] renderChartToPng(int chartIndex, int width, int height) Renders the chart atchartIndexto PNG bytes. Pivot tables changed through the API and not refreshed since are refreshed first. Under license enforcement without a license, the image carries the evaluation banner and counts against the evaluation export budget.- Parameters:
chartIndex- 0-based chart index on this sheetwidth- image width in pixels; values below 1 are raised to 1height- image height in pixels; values below 1 are raised to 1- Returns:
- the PNG bytes, or
nullwhen the index is out of range - Throws:
AxyraException- if the evaluation export budget is used up
-
renderChartToSvg
Renders the chart atchartIndexto a standalone SVG document.The vector counterpart of
renderChartToPng(int, int, int): it draws with the same chart renderer, so every chart type the PNG draws is drawn here too. Text comes out as<text>elements and the plot as paths, so the picture scales and prints at any resolution. Pivot tables changed through the API and not refreshed since are refreshed first. The document counts against the evaluation export budget under license enforcement; it carries no evaluation banner.- Parameters:
chartIndex- 0-based chart index on this sheetwidth- document width in pixels; values below 1 are raised to 1height- document height in pixels; values below 1 are raised to 1- Returns:
- the SVG text, or
nullwhen the index is out of range - Throws:
AxyraException- if the evaluation export budget is used up
-