Class Workbook
- All Implemented Interfaces:
AutoCloseable
Sheet, Range and cell values are lightweight Java-side
views that hold no native resource; the workbook's handle is the
single source of truth. Use try-with-resources (or close()) to
release the underlying memory; after close, any derived view throws
IllegalStateException.
Calculation is automatic, as in Excel: opening keeps the results the file
carries, and every write recalculates its dependents, so reads and saved
files are current. Only in CalcMode.MANUAL do results wait for
recalculate().
Not thread-safe: use one workbook from one thread at a time; separate workbooks can be used from separate threads concurrently.
-
Method Summary
Modifier and TypeMethodDescriptionThe active (selected) sheet.intaddChartSheet(String name, Chart chart) Append a chart-sheet tab namednamehostingchart— a dedicated full-page chart tab (ECMA-376 §18.3.1.12chartsheet), as opposed to a chart floating on a worksheet viaSheet.addChart(io.keikai.axyra.sheets.content.Chart).voidAdd or replace a workbook-scoped defined name.voidAdd or replace a name scoped to a sheet.intaddOleObject(String name, String progId, byte[] data) Embed an OLE object (raw bytes + optional ProgID); returns its index.voidvoidaddSlicer(String name, String source, String pivotTable, int sheetIndex, int row, int col, int endRow, int endCol) Add a slicer that DISPLAYS: bound to the pivot fieldsourceofpivotTable, anchored on sheetsheetIndexwith a two-cell drawing anchor spanningrow/coltoendRow/endCol(0-based, exclusive-corner semantics of ECMA-376 §20.5.2.32).voidaddSlicer(String name, String source, String pivotTable, String cacheName, int sheetIndex, int row, int col, int endRow, int endCol) Add a slicer that DISPLAYS, preserving an explicit backing cache name.voidaddTimeline(String name, String source, String dateField) Add a timeline (a date-based slicer) bound to a source pivot over adateField.voidaddTimeline(String name, String source, String dateField, int sheetIndex, int row, int col, int endRow, int endCol) Add a timeline that DISPLAYS: filters pivot tablesourceoverdateField, anchored on sheetsheetIndexspanningrow/coltoendRow/endCol.allDependents(Sheet sheet, int row, int column) All transitive dependents of a cell (does not include the cell itself).The authoring application (ApplicationofdocProps/app.xml), ornull.The authoring application version (AppVersion), ornull.author()The author (OOXMLcreator), ornull.calcMode()The workbook calculation mode.category()The document category (cp:category), ornull.chartSheetChart(int index) A live view of the chart hosted by the chart sheet atindex— the same read-back/edit viewSheet.chart(int)returns.intNumber of chart-sheet tabs in the workbook (authored + imported).chartSheetName(int index) The tab name of the chart sheet atindex(its position among the chart sheets, in tab order); out-of-range throwsIndexOutOfBoundsException.voidclose()voidAppend a deep copy of EVERY sheet (visible and hidden) of each source workbook, in argument order, auto-suffixing colliding names — the cross-workbook merge counterpart ofcopySheetFrom(Workbook, int)(same migration semantics and exclusions, except as follows).comments()The comments/description (OOXMLdescription), ornull.company()The company (CompanyofdocProps/app.xml), ornull.The data connections defined in this workbook (Power Query and other), read fromxl/connections.xml.The content status (cp:contentStatus, e.g.Append a deep copy ofsourceundernewNameand return it.copySheetFrom(Workbook source, int sheetIndex) Append a deep copy of sheetsheetIndexof ANOTHER workbook and return the new view.copySheetFrom(Workbook source, int sheetIndex, String newName) Append a deep copy of sheetsheetIndexof ANOTHER workbook undernewNameand return the new view.static Workbookcreate()Create a new empty workbook (sparse backend — the general-purpose default).static WorkbookCreate a new empty workbook on the columnar storage backend — behaviorally identical tocreate()but far leaner in memory for large, dense, numeric workbooks (roughly 4.6× smaller at rest at 10M cells), and saving at or below the sparse path.created()The creation timestamp (dcterms:created, W3CDTF), ornull.createSheet(String name) Append a new sheet and return a view of it.The custom document properties, in file order — an immutable read view (empty list when the workbook has none).The workbook's CUSTOM table-style definitions (<tableStyles>+ their differential-format payloads) plus the default table/pivot style names, as one opaque JSON value object — ornullwhen the workbook defines none.booleandate1904()Whether the workbook uses the 1904 date system (ECMA-376 Part 1 §18.2.28<workbookPr date1904>).The workbook default ("Normal") style — what unstyled cells render with.voiddeleteSheet(int index) Delete the sheet atindex.dependents(Sheet sheet, int row, int column) The direct dependents of a cell — the cells whose formulas read it.TheDocSecurityflags ofdocProps/app.xml, ornullwhen the workbook records none.The author-recorded document version (cp:versionofdocProps/core.xml), ornull.Evaluate an ad-hoc formula (leading=optional) in the first sheet's context.Evaluate an ad-hoc formula in the given sheet's context.intNumber of external workbook references (ECMA-376 §18.14).Every external workbook reference — the linked workbooks that formulas such as[Book2]Sheet1!A1resolve against.externalLinkSource(int index) The current source path (primary relationship target) of the external workbook reference atindex, ornullwhen the index is out of range.The first defined name matchingname, ornull.formulaToA1(String formula, int anchorRow, int anchorColumn) Convert a formula's references from R1C1 back to A1 style.formulaToR1C1(String formula, int anchorRow, int anchorColumn) Convert a formula's cell references from A1 to R1C1 style, relative to the 1-based(anchorRow, anchorColumn).doubleGoal seek: find the value for thechangingcell that makes thetargetcell equaltargetValue.booleanhasNamedStyle(String name) Whether a named style is registered.The base URI relative hyperlinks resolve against (HyperlinkBaseofdocProps/app.xml), ornull.TheHyperlinksChangedflag ofdocProps/app.xml, ornullwhen the workbook records none.insertSheet(int index, String name) Insert a new empty sheet atindex(0..sheetCount inclusive), shifting later sheets right, and return a view of it.booleanWhether the workbook structure is locked.booleanWhether the workbook structure is protected (alias ofisStructureLocked()).booleanWhether the workbook windows are locked (§18.2.29lockWindows).booleanWhether a modify password is stored.keywords()The document keywords, ornull.language()The document language (dc:language, e.g.The user who last saved the workbook (cp:lastModifiedByofdocProps/core.xml), ornull.When the workbook was last printed (cp:lastPrinted, a W3CDTF timestamp), ornull.static LicenseInfoThe current process-global licensing status.TheLinksUpToDateflag ofdocProps/app.xml, ornullwhen the workbook records none.locale()The workbook display locale as a BCP-47 tag (default"en-US").manager()The manager (ManagerofdocProps/app.xml), ornull.modified()The last-modified timestamp (dcterms:modified, W3CDTF), ornull.voidmoveSheet(int from, int to) Move the sheet atfromto positionto, shifting the sheets in between.intNumber of registered named cell styles.names()All defined names, in definition order.The embedded OLE objects in this workbook.static Workbookopen(InputStream in, String format) Parse a workbook by reading all ofin(of the givenformat).static WorkbookOpen a workbook from a file.static WorkbookOpen a workbook from a file, decrypting withpasswordwhen the file is an agile-encrypted workbook ([MS-OFFCRYPTO] §2.3.4 — whatsaveEncrypted(java.nio.file.Path, java.lang.String)and Excel 2013+/365 write).static WorkbookParse a workbook from an in-memory byte array of the givenformat.static WorkbookParse a workbook from an in-memory byte array, decrypting withpasswordwhen the bytes are an agile-encrypted workbook.precedents(Sheet sheet, int row, int column) The direct precedents of a cell — the cells its formula reads (may be cross-sheet).voidprotect(boolean lockStructure) Lock the workbook structure (no adding/removing/renaming sheets).voidprotect(boolean lockStructure, boolean lockWindows) Lock the workbook structure and/or windows.voidprotectStructure(String password) Lock the workbook structure (ECMA-376 §18.2.29lockStructure) with a password (ISO Write Protection hash, [MS-OFFCRYPTO] §2.4.2.2).voidprotectStructure(String password, boolean lockWindows) Lock the workbook structure and optionally the windows (§18.2.29).A range parsed from a sheet-qualified A1 reference — the spelling a defined name stores, e.g.voidFull recalculation: recompute every formula cell.voidRecalculate only cells marked dirty since the last calculation.voidregisterFunction(String name, UserFunction function) Register a user-defined function callable from formulas byname.voidregisterNamedStyle(String name, CellStyle style) Register a reusable named cell style (e.g.voidregisterTypedFunction(String name, TypedUserFunction function) Register a typed user-defined function callable from formulas byname.booleanremoveChartSheet(int index) Remove the chart sheet atindex(its position among the chart sheets); returns whether it existed.booleanremoveCustomProperty(String name) Remove the custom document propertyname; returns whether it existed.booleanremoveExternalLink(int index) Removes the external workbook reference atindex(0-based, inexternalLinks()order): drops both the descriptor and the preservedexternalLinkpart so it is not re-emitted on save.booleanremoveName(String name) Remove all defined names with the given name; returns whether any matched.booleanremoveNamedStyle(String name) Delete a named cell style.booleanremoveOleObject(int index) Remove the embedded OLE object atindex; returns whether it existed.voidRemove the write protection / read-only recommendation.voidrenameSheet(int index, String newName) Rename the sheet atindextonewName, rewriting formula references (OldName!A1becomesNewName!A1) and named ranges.byte[]renderPdf(PdfOptions options) Render the workbook to PDF bytes honoringoptions(page range, sheet subset, fit override, encryption).voidRender the whole workbook to a PDF file.voidrenderPdf(Path file, PdfOptions options) Render the workbook to a PDF file honoringoptions.byte[]renderRangeImage(int sheetIndex, String rangeA1, String format, ImageOptions options) Render an A1 range of a sheet to the given raster format.byte[]renderRangePng(int sheetIndex, String rangeA1, ImageOptions options) Render an A1 range (e.g.byte[]renderRangeSvg(int sheetIndex, String rangeA1, ImageOptions options) Render an A1 range of a sheet to SVG bytes (seerenderRangePng(int, java.lang.String, io.keikai.axyra.sheets.io.ImageOptions)).byte[]renderSheetImage(int sheetIndex, String format, ImageOptions options) Render one sheet to the given raster format:"png","jpeg","gif","bmp"or"tiff".byte[]renderSheetPng(int sheetIndex, ImageOptions options) Render one sheet (the first page of its print layout) to PNG bytes.byte[]renderSheetSvg(int sheetIndex, ImageOptions options) Render one sheet (the first page of its print layout) to SVG bytes.revision()The revision number (cp:revision), ornull.voidsave(OutputStream out, String format) Serialize toformatand write the bytes toout.voidWrite the workbook to a file; the format comes from the extension.voidsave(Path file, SaveOptions options) Write with export options (XLSX honors them; other formats ignore them).byte[]Serialize the workbook to the givenformat(an extension token, with or without the leading dot) and return the bytes — for writing to any sink without touching the filesystem.voidsaveCsv(Path file, CsvOptions options) Write one sheet as delimited text, choosing which sheet, the separator, and whether numbers are written as display text (whatsave("x.csv")and Excel write) or as stored values for a data feed.voidsaveEncrypted(Path file, String password) Write the workbook withpasswordas its password to open.voidsaveHtml(Path file, HtmlOptions options) Write the workbook as HTML in the shapeoptionsasks for — the package (a document plus its sidecar directory) or one self-contained document.TheScaleCropflag ofdocProps/app.xml, ornullwhen the workbook records none.voidsetActiveSheet(int index) Activate the sheet atindex; out-of-range throwsAxyraException.voidsetApplication(String application) Set theApplicationname written todocProps/app.xml.voidsetAppVersion(String appVersion) SetAppVersion(Excel's form isMM.mmmm, e.g.voidSet the author (OOXMLcreator).voidsetCalcMode(CalcMode mode) Set the workbook calculation mode.voidsetCategory(String category) Setcp:category.voidsetComments(String comments) Set the comments/description (OOXMLdescription).voidsetCompany(String company) SetCompany.booleansetConnectionCommand(String name, String command) Set the command text (e.g.booleansetConnectionString(String name, String connectionString) Set the connection string of the named connection; returns whether a connection matched.voidsetContentStatus(String status) Setcp:contentStatus.voidsetCreated(String timestamp) Setdcterms:created(a W3CDTF timestamp).voidsetCustomProperty(String name, boolean value) Set (or replace) the boolean-typed custom document propertyname.voidsetCustomProperty(String name, double value) Set (or replace) the number-typed custom document propertyname.voidsetCustomProperty(String name, String value) Set (or replace) the text-typed custom document propertyname.voidsetCustomProperty(String name, LocalDate value) Set (or replace) the date-typed custom document propertyname.voidsetCustomTableStyles(String json) Install custom table-style definitions produced bycustomTableStyles().voidsetDate1904(boolean on) Switch the workbook date system.voidsetDefaultFont(CellStyle style) Replace the workbook default ("Normal") font with the font attributes ofstyle(name, size, color, bold, …); its non-font attributes are ignored.voidsetDocSecurity(Integer docSecurity) SetDocSecurity(nullclears it).voidsetDocumentVersion(String version) Setcp:version;nullclears it.booleansetExternalLinkSource(int index, String newPath) Repoints the external workbook reference atindexto a new source path (the relationship target written intoexternalLinkrels on save).voidsetHyperlinkBase(String base) SetHyperlinkBase.voidsetHyperlinksChanged(Boolean hyperlinksChanged) SetHyperlinksChanged(nullclears it).voidsetIterativeCalc(boolean enabled, int maxIterations, double maxChange) Enable/disable iterative (circular-reference) calculation.voidsetKeywords(String keywords) Set the document keywords.voidsetLanguage(String language) Setdc:language(an RFC 5646 language tag, e.g.voidsetLastModifiedBy(String user) Setcp:lastModifiedBy.voidsetLastPrinted(String timestamp) Setcp:lastPrinted(a W3CDTF timestamp, e.g.static LicenseInfosetLicense(byte[] token) Install a license token (raw bytes of thepayload.signatureenvelope) and return the resultingLicenseInfo.static LicenseInfosetLicense(byte[] token, LicenseMode mode) Install a license token, choosing what happens when it is not in force.static LicenseInfoInstall a license token by reading all ofin.static LicenseInfosetLicense(String token) Install a license token from its text form (UTF-8).static LicenseInfosetLicense(String token, LicenseMode mode) Install a license token from its text form (UTF-8), choosing what happens when it is not in force.voidsetLinksUpToDate(Boolean linksUpToDate) SetLinksUpToDate(nullclears it).voidSet the workbook display locale ("de-DE","ja-JP", ...).voidsetManager(String manager) SetManager.voidsetModified(String timestamp) Setdcterms:modified(a W3CDTF timestamp).booleansetOleObjectData(int index, byte[] data) Replace the embedded OLE object's bytes in place; returns whether the index existed.voidsetRevision(String revision) Setcp:revision.voidsetScaleCrop(Boolean scaleCrop) SetScaleCrop(nullclears it).voidsetSharedDoc(Boolean sharedDoc) SetSharedDoc(nullclears it).booleansetSlicerSelection(String slicerName, String... selectedValues) Replace a slicer's item selection (clicking slicer buttons): only rows whose value is amongselectedValuespass the linked pivot's nextrefresh().booleansetSlicerStyle(String slicerName, String styleName) Set a slicer's style by name — a built-inSlicerStyleLight1..6/SlicerStyleDark1..6/SlicerStyleOther1..2, or a custom slicer style.voidsetSubject(String subject) Set the document subject.voidSet the workbook theme (color scheme + major/minor fonts).booleansetTimelineRange(String timelineName, LocalDate start, LocalDate end) Set the selected date range of the named timeline — the range its bound pivot is filtered to on the nextpivotrefresh().voidSet the document title (nullclears it).voidsetWriteProtection(String password) Write-protect the workbook with a modify password (<fileSharing>— ECMA-376 Part 1 §18.2.12): Excel prompts for the password on open and offers read-only otherwise.voidsetWriteProtection(String password, String userName, boolean readOnlyRecommended) Write-protect the workbook:passwordgates editing (null = none),userNamerecords who reserved the file, andreadOnlyRecommendedshows the open-read-only prompt.TheSharedDocflag ofdocProps/app.xml, ornullwhen the workbook records none.sheet(int index) The sheet atindex(0-based).The sheet with the given name, compared ignoring case as Excel compares sheet names; a sheet whose name matches exactly wins.intNumber of sheets.intsheetPageCount(int sheetIndex) Number of printed pages the sheet paginates to — the valid range forImageOptions.Builder.page(int)and the PDF export's page numbering.sheets()A snapshot list of all sheet views, in order.byte[]sign(byte[] privateKey, byte[] certificate) Serialize the workbook to an XLSX package and digitally sign it (an OPC package signature per ECMA-376 Part 2 §13: RSA-SHA256, or ECDSA-P256-SHA256 whenprivateKeyis an EC P-256 key), returning the signed file bytes.voidSign likesign(byte[], byte[])and write the result tofile.The digital-signature validation reports for this workbook's source file, captured when it was opened — an immutable read view, empty for unsigned or programmatically created workbooks.intNumber of slicers in the workbook.slicers()Every slicer in the workbook, each joined with its cache so the filtered field and the linked pivot tables travel with it.String[]slicerSelection(String slicerName) The selected item values of a slicer, ornullif it does not exist.splitToFiles(Path dir, String pattern) Split this workbook into one single-sheet file per sheet, written todir(created if missing), and return the written paths in sheet order.subject()The document subject, ornull.theme()The workbook theme (color scheme + major/minor fonts), ornullwhen the workbook has no theme.intNumber of timelines in the workbook.timelineRange(String timelineName) The selected date range of the named timeline as[start, end](either may benullwhen unbounded), ornullwhen the timeline is unknown or has no active selection.Every timeline in the workbook, each joined with its cache so the filtered date field and granularity level travel with it.title()The document title, ornull.voidRemove workbook structure/window locks.booleanunprotectStructure(String password) Clear the workbook protection after verifyingpasswordagainst the stored hash.booleanupdateNamedStyle(String name, CellStyle style) Redefine a named cell style and PROPAGATE the change: every cell (and row/column default) currently styled with it is restyled — Excel's "Modify…" on a cell style.The VBA code modules in this macro-enabled workbook (read-only): each module's editor name, kind ("standard"/"class"/"document"), and MS-OVBA-decompressed source text.booleanverifyWritePassword(String password) Verifiespasswordagainst the stored modify-password hash;falsewhen the workbook is not write-protected.The write-protection state, or null when the workbook carries no<fileSharing>element.xmlMaps()The XML map definitions in this workbook (read-only): each map's id, name, root element, schema id and XSD schema text, read fromxl/xmlMaps.xml.
-
Method Details
-
create
Create a new empty workbook (sparse backend — the general-purpose default). -
createColumnar
Create a new empty workbook on the columnar storage backend — behaviorally identical tocreate()but far leaner in memory for large, dense, numeric workbooks (roughly 4.6× smaller at rest at 10M cells), and saving at or below the sparse path. Prefer this when generating big data exports; for small or scattered workbooks the difference is negligible andcreate()is fine. Workbooks read from a file always use the reader's representation regardless of this choice. -
open
Open a workbook from a file. Lazy: does not recalculate.The format comes from the extension, then from the container when the two disagree (a ZIP named
.xlsis read as the package it actually is). Readable:.xlsx/.xlsm/.xltx/.xltm/.xlsb,.xls(BIFF8, including a password-protected one viaopen(Path, String)),.csv/.tsv/.txt,.json,.html/.htm,.ods/.ots/.sxc/.fods, and SpreadsheetML 2003.xml.A format the engine knows but does not read —
.numbers,.pdf, an image — is refused with a message that names it and says why, and an unrecognised extension is refused with a list of what does work. Both arrive asAxyraIoException. -
open
Open a workbook from a file, decrypting withpasswordwhen the file is an agile-encrypted workbook ([MS-OFFCRYPTO] §2.3.4 — whatsaveEncrypted(java.nio.file.Path, java.lang.String)and Excel 2013+/365 write). If the file is not encrypted, the password is ignored and the file opens normally.Error cases (all thrown as
AxyraIoException):- Wrong password — the message starts with "wrong password".
- Legacy encryption — Standard/RC4 schemes (EncryptionInfo version 2.x/3.x, Excel 2007-era defaults) are not supported; the message names agile encryption as the supported scheme.
- An encrypted file opened via the password-less
open(Path)fails with a message saying a password is required.
-
save
Write the workbook to a file; the format comes from the extension.Workbook containers:
.xlsx/.xlsm/.xltx/.xltm,.xlsb,.xls(BIFF8),.ods. Text:.csv,.tsv/.txt(tab-separated),.json. Web:.html/.htm.Rendered output is routed to the renderer rather than to a workbook writer:
.pdfpaginates the whole workbook, and.svg,.png,.jpg/.jpeg,.gif,.bmpand.tif/.tiffeach hold the first printed page of the active sheet. For control over the page range, fit or encryption userenderPdf(Path, io.keikai.axyra.sheets.io.PdfOptions); for image scale, page or gridlines userenderSheetImage(int, String, io.keikai.axyra.sheets.io.ImageOptions).An
.html/.htmname writes two things: the document itself and a<stem>_files/directory beside it holding one page per sheet, the stylesheet, the sheet tab strip and the images — the shape Excel's Save as Web Page produces. For one self-contained file instead, seesaveHtml(Path, io.keikai.axyra.sheets.io.HtmlOptions).A format the engine knows but cannot write, and an extension it does not recognise, are both refused as
AxyraIoException— the first naming the format, the second listing what does work. -
saveHtml
Write the workbook as HTML in the shapeoptionsasks for — the package (a document plus its sidecar directory) or one self-contained document.- See Also:
-
save
Write with export options (XLSX honors them; other formats ignore them).ODS keeps a formula as OpenFormula when it has a faithful translation; one that has not (an Excel-only function, a structured or external reference) is written as its value.
- Throws:
IllegalArgumentException- if the options explicitly ask to keep formulas andfile's format cannot carry them (CSV, TSV, TXT), or it is ODS and some formula has no OpenFormula translation (the message names the first) — the file would otherwise hold static values the caller believes are live formulas
-
saveCsv
Write one sheet as delimited text, choosing which sheet, the separator, and whether numbers are written as display text (whatsave("x.csv")and Excel write) or as stored values for a data feed.- Throws:
IllegalArgumentException- if no sheet has the chosen nameAxyraException- if no sheet has the chosen index
-
saveEncrypted
Write the workbook withpasswordas its password to open. The format follows the file extension:- Any extension but
.xls: an agile-encrypted XLSX package ([MS-OFFCRYPTO] §2.3.4, AES-256 — what Excel 2013+/365 writes and whatopen(Path, String)reads back), inside an encrypted CFB container. .xls: a BIFF8 workbook encrypted with 128-bit RC4 CryptoAPI ([MS-OFFCRYPTO] §2.3.5), the only password to open the legacy format has. RC4 is a weak cipher and the password hash is not iterated, so this keeps the file from being opened casually, not from a determined attacker; a workbook that needs real protection belongs in.xlsx.
This never writes a readable file: a password that cannot protect anything is refused rather than silently ignored.
- Throws:
NullPointerException- ifpasswordisnull— usesave(Path)to write an unencrypted workbookIllegalArgumentException- ifpasswordis empty; Excel refuses an empty password as protection, and writing the package in the clear would leave the caller believing it was protected
- Any extension but
-
saveBytes
Serialize the workbook to the givenformat(an extension token, with or without the leading dot) and return the bytes — for writing to any sink without touching the filesystem.Accepts every token
save(Path)routes, rendered output included:"pdf"and"svg"come back as bytes here just as they would as a file. The one difference is"html", which has nowhere to put its sidecar directory and so returns a single self-contained document. -
save
Serialize toformatand write the bytes toout.- Throws:
IOException
-
sign
public byte[] sign(byte[] privateKey, byte[] certificate) Serialize the workbook to an XLSX package and digitally sign it (an OPC package signature per ECMA-376 Part 2 §13: RSA-SHA256, or ECDSA-P256-SHA256 whenprivateKeyis an EC P-256 key), returning the signed file bytes.Signing must be the last step. The signature covers the saved bytes; this workbook object is not changed by signing, and any further edit followed by
save(Path)/saveBytes(String)produces an unsigned file — the writer deliberately drops signature parts rather than emit a signature that no longer verifies. Re-sign after every save that must stay signed.Consumers (including
signatures()on reopen) verify the signature against the embedded certificate. Whether the certificate is trusted is a policy decision outside this API.- Parameters:
privateKey- the signing key: PKCS#8 DER or PEM (an RSA PKCS#1 key is also accepted)certificate- the signer's X.509 certificate, DER or PEM, whose public key matchesprivateKey- Returns:
- the signed XLSX package bytes
- Throws:
AxyraIoException- when the key material cannot be parsed or does not match, or signing fails
-
sign
Sign likesign(byte[], byte[])and write the result tofile.- Throws:
IOException
-
signatures
The digital-signature validation reports for this workbook's source file, captured when it was opened — an immutable read view, empty for unsigned or programmatically created workbooks.Each report tells the signer, algorithm, claimed signing time and a
SignatureInfo.Statusverdict:VALID(all signed digests and the signature verify),INVALID(the content was modified after signing), orUNSUPPORTED(algorithm outside the implemented subset — deliberately not a guess either way). Certificate trust chains, expiry and revocation are not evaluated.The reports describe the file as it was opened; they do not change as the in-memory workbook is edited, and they are not carried into saved output (saving drops signature parts — see
sign(byte[], byte[])). -
openBytes
Parse a workbook from an in-memory byte array of the givenformat. -
openBytes
Parse a workbook from an in-memory byte array, decrypting withpasswordwhen the bytes are an agile-encrypted workbook. Same semantics and error cases asopen(Path, String): a wrong password, a legacy (Standard/RC4) encryption scheme, or an encrypted file opened without a password all throwAxyraIoExceptionwith a distinct message; a password for non-encrypted bytes is ignored. -
open
Parse a workbook by reading all ofin(of the givenformat).- Throws:
IOException
-
renderPdf
Render the whole workbook to a PDF file. -
renderPdf
Render the workbook to PDF bytes honoringoptions(page range, sheet subset, fit override, encryption).nulloptions render likerenderPdf(Path). -
renderPdf
Render the workbook to a PDF file honoringoptions. -
renderSheetPng
Render one sheet (the first page of its print layout) to PNG bytes.nulloptions use the defaults (96 DPI, sheet gridline flag). -
renderSheetSvg
Render one sheet (the first page of its print layout) to SVG bytes. -
renderSheetImage
Render one sheet to the given raster format:"png","jpeg","gif","bmp"or"tiff". -
renderRangeImage
Render an A1 range of a sheet to the given raster format. -
renderRangePng
Render an A1 range (e.g."B2:F20") of a sheet to PNG bytes. The range replaces the sheet's print area for the export, so pagination and gridline rules apply to just that rectangle. -
renderRangeSvg
Render an A1 range of a sheet to SVG bytes (seerenderRangePng(int, java.lang.String, io.keikai.axyra.sheets.io.ImageOptions)). -
sheetPageCount
public int sheetPageCount(int sheetIndex) Number of printed pages the sheet paginates to — the valid range forImageOptions.Builder.page(int)and the PDF export's page numbering. An empty sheet reports 0 (its image export still yields one blank page). -
setSlicerStyle
Set a slicer's style by name — a built-inSlicerStyleLight1..6/SlicerStyleDark1..6/SlicerStyleOther1..2, or a custom slicer style. Returns whether the slicer exists. -
setSlicerSelection
Replace a slicer's item selection (clicking slicer buttons): only rows whose value is amongselectedValuespass the linked pivot's nextrefresh(). An empty array clears the filter (Excel's "Clear Filter"). Returns whether the slicer exists. -
slicerSelection
The selected item values of a slicer, ornullif it does not exist. -
addSlicer
-
addSlicer
public void addSlicer(String name, String source, String pivotTable, int sheetIndex, int row, int col, int endRow, int endCol) Add a slicer that DISPLAYS: bound to the pivot fieldsourceofpivotTable, anchored on sheetsheetIndexwith a two-cell drawing anchor spanningrow/coltoendRow/endCol(0-based, exclusive-corner semantics of ECMA-376 §20.5.2.32). On save the engine synthesizes the full display apparatus — slicer part, slicer cache, workbook registration, worksheet<x14:slicerList>extension and the drawing graphicFrame — so a from-scratch workbook shows the control in Excel.Pass
pivotTable = nullfor a slicer without pivot linkage (structure only — such a slicer cannot be bound and is not emitted). The backing cache is auto-namedSlicer_<source>; use theaddSlicer(String, String, String, String, int, int, int, int, int)overload to preserve an existing cache name when round-tripping.Reference: ECMA-376 Part 4 §18.10; [MS-XLSX] x14 slicer.
-
addSlicer
public void addSlicer(String name, String source, String pivotTable, String cacheName, int sheetIndex, int row, int col, int endRow, int endCol) Add a slicer that DISPLAYS, preserving an explicit backing cache name. Same asaddSlicer(String, String, String, int, int, int, int, int)butcacheName(when non-null/non-empty) overrides the auto-derivedSlicer_<source>name — round-tripping an existing slicer passes the source cache name so the reserved#N/AdefinedName and the cache identity are preserved rather than renamed (which would grow the user-definedName count on a round-trip).Reference: ECMA-376 Part 4 §18.10; [MS-XLSX] x14 slicer.
-
slicerCount
public int slicerCount()Number of slicers in the workbook. -
slicers
Every slicer in the workbook, each joined with its cache so the filtered field and the linked pivot tables travel with it. Symmetric withaddSlicer(String, String).The descriptor models the structural facts (name, caption, filtered field, linked pivots, column count) plus the on-sheet anchor; the interactive selection state is not modelled — see
Slicer. -
addTimeline
Add a timeline (a date-based slicer) bound to a source pivot over adateField. Symmetric withtimelines(). -
addTimeline
public void addTimeline(String name, String source, String dateField, int sheetIndex, int row, int col, int endRow, int endCol) Add a timeline that DISPLAYS: filters pivot tablesourceoverdateField, anchored on sheetsheetIndexspanningrow/coltoendRow/endCol. Same anchored-synthesis contract asaddSlicer(String, String, String, int, int, int, int, int).Reference: [MS-XLSX] x15 timeline / timelineCacheDefinition.
-
timelineCount
public int timelineCount()Number of timelines in the workbook. -
timelines
Every timeline in the workbook, each joined with its cache so the filtered date field and granularity level travel with it. Symmetric withaddTimeline(String, String, String).The descriptor models what the timeline filters; the on-sheet drawing anchor and the selected date range are not modelled — see
Timeline. -
setTimelineRange
Set the selected date range of the named timeline — the range its bound pivot is filtered to on the nextpivotrefresh(). The range is inclusive of both endpoints; passnullfor an open-ended bound. Returns whether the timeline matched. -
timelineRange
The selected date range of the named timeline as[start, end](either may benullwhen unbounded), ornullwhen the timeline is unknown or has no active selection. -
externalLinkCount
public int externalLinkCount()Number of external workbook references (ECMA-376 §18.14). -
externalLinks
Every external workbook reference — the linked workbooks that formulas such as[Book2]Sheet1!A1resolve against. The engine serves the values cached at the source's last save; the linked file is never opened. SeeExternalLink. -
removeExternalLink
public boolean removeExternalLink(int index) Removes the external workbook reference atindex(0-based, inexternalLinks()order): drops both the descriptor and the preservedexternalLinkpart so it is not re-emitted on save. Returnstrueif a link existed at that index. -
setExternalLinkSource
Repoints the external workbook reference atindexto a new source path (the relationship target written intoexternalLinkrels on save). Returnstrueif the index was valid. -
externalLinkSource
The current source path (primary relationship target) of the external workbook reference atindex, ornullwhen the index is out of range. -
setLicense
Install a license token (raw bytes of thepayload.signatureenvelope) and return the resultingLicenseInfo. Licensing is process-global: this affects every workbook in the JVM, not just this one. A bad or tampered token never throws — it degrades toLicenseStatus.EVALUATION(fail-open), writes one line naming the cause to standard error, andLicenseInfo.reason()carries it. UsesetLicense(byte[], LicenseMode)withLicenseMode.REQUIREDto fail fast instead.This SDK reports the
javaplatform: a key issued for another platform, a key for another product, and an embedded OEM token (which licenses the host product it ships in, not this SDK) are all refused with a reason. When a key is put in force, its customer console message is printed to standard error once per process. -
setLicense
Install a license token, choosing what happens when it is not in force.- Throws:
AxyraException- underLicenseMode.REQUIREDwhen the token does not put a license in force; the message names the cause
-
setLicense
Install a license token from its text form (UTF-8). -
setLicense
Install a license token from its text form (UTF-8), choosing what happens when it is not in force. -
setLicense
Install a license token by reading all ofin.- Throws:
IOException
-
licenseStatus
The current process-global licensing status. -
recalculate
public void recalculate()Full recalculation: recompute every formula cell. Never called implicitly. -
recalculateDirty
public void recalculateDirty()Recalculate only cells marked dirty since the last calculation. -
evaluate
Evaluate an ad-hoc formula (leading=optional) in the first sheet's context. Returns the result as aCellValue; a formula error is aCellValue.Error, not an exception. -
evaluate
Evaluate an ad-hoc formula in the given sheet's context. -
calcMode
The workbook calculation mode. -
setCalcMode
Set the workbook calculation mode. -
setIterativeCalc
public void setIterativeCalc(boolean enabled, int maxIterations, double maxChange) Enable/disable iterative (circular-reference) calculation. -
date1904
public boolean date1904()Whether the workbook uses the 1904 date system (ECMA-376 Part 1 §18.2.28<workbookPr date1904>). Legacy Mac workbooks count date serials from 1904-01-01 instead of 1899-12-30. -
setDate1904
public void setDate1904(boolean on) Switch the workbook date system. This changes the epoch every stored date serial is interpreted against; existing serial values are NOT rebased, matching the OOXML flag semantics — a date-formatted cell shifts its displayed date by ~4 years when the flag flips. -
locale
The workbook display locale as a BCP-47 tag (default"en-US").The locale is a runtime rendering setting: it selects the month and weekday names, AM/PM markers, decimal / thousands separators, and the locale-adaptive builtin date formats used when cell values are turned into display text (
Cell.formattedText(), PDF / image rendering). It is not persisted into saved xlsx files — Excel stores no workbook display locale — and it never affects formula text, which stays canonical en-US per ECMA-376. -
setLocale
Set the workbook display locale ("de-DE","ja-JP", ...).nullor an empty tag clears back to"en-US". Unknown tags are kept but render as en-US. Seelocale()for scope. -
registerFunction
Register a user-defined function callable from formulas byname. The function receives its arguments coerced todouble[]and returns adouble. It must not call back into this workbook while it runs. For string/range/error arguments and non-numeric results, useregisterTypedFunction(String, io.keikai.axyra.sheets.formula.TypedUserFunction). -
registerTypedFunction
Register a typed user-defined function callable from formulas byname. Arguments arrive asCellValues — number, text, boolean, error, blank; a range argument arrives as a row-majorCellValue.Array— and the function returns anyCellValue(seeTypedUserFunctionfor the exact shapes). It must not call back into this workbook while it runs.Registrations share one per-workbook namespace with
registerFunction(String, io.keikai.axyra.sheets.formula.UserFunction): names are case-insensitive and the last registration for a name wins. This is a distinct method rather than aregisterFunctionoverload because an overload would make every implicitly typed lambda (args -> ...) ambiguous at compile time, breaking existing numeric registrations. -
sheetCount
public int sheetCount()Number of sheets. -
sheet
The sheet atindex(0-based). -
sheet
The sheet with the given name, compared ignoring case as Excel compares sheet names; a sheet whose name matches exactly wins.- Throws:
IllegalArgumentException- if there is no such sheet
-
createSheet
Append a new sheet and return a view of it. The name must satisfy Excel's sheet-name rules (non-empty, at most 31 characters, no: \ / ? * [ ], no leading/trailing apostrophe, notHistory) and be unique in the workbook (case-insensitive).- Throws:
AxyraException- if the name is invalid or already used
-
insertSheet
Insert a new empty sheet atindex(0..sheetCount inclusive), shifting later sheets right, and return a view of it. The name must satisfy Excel's sheet-name rules (non-empty, at most 31 characters, no: \ / ? * [ ], no leading/trailing apostrophe, unique in the workbook); an invalid name or index throwsAxyraException.Existing
Sheetviews keep referring to their own tabs; theirSheet.index()reflects the shift. -
deleteSheet
public void deleteSheet(int index) Delete the sheet atindex. Cross-sheet formula references to the deleted sheet become#REF!, and the active sheet moves the way Excel moves it: the next sheet activates, or the previous one when the deleted sheet was last. Deleting the only remaining sheet throwsAxyraException(a workbook must contain at least one sheet).Existing
Sheetviews of other sheets keep referring to their own tabs; a view of the deleted sheet throwsIllegalStateExceptionon use. -
renameSheet
Rename the sheet atindextonewName, rewriting formula references (OldName!A1becomesNewName!A1) and named ranges. The name is validated against Excel's sheet-name rules (seeinsertSheet(int, java.lang.String)); an invalid or duplicate name throwsAxyraException. -
moveSheet
public void moveSheet(int from, int to) Move the sheet atfromto positionto, shifting the sheets in between. Formula references (including 3D sheet ranges) and the active sheet follow Excel's semantics. -
activeSheet
The active (selected) sheet. -
setActiveSheet
public void setActiveSheet(int index) Activate the sheet atindex; out-of-range throwsAxyraException. -
addChartSheet
Append a chart-sheet tab namednamehostingchart— a dedicated full-page chart tab (ECMA-376 §18.3.1.12chartsheet), as opposed to a chart floating on a worksheet viaSheet.addChart(io.keikai.axyra.sheets.content.Chart). Returns the new chart sheet's 0-based index (its position among the workbook's chart sheets, seechartSheetCount()).The chart spec is the same
ChartbuilderSheet.addChart(io.keikai.axyra.sheets.content.Chart)takes (series, axes, legend, title, …); its anchor is ignored — a chart sheet always fills the page. Series references must point at ranges on regular worksheets and be sheet-qualified (e.g."Data!$B$2:$B$10") — the chart sheet has no cells of its own.Ordering: the new tab is appended AFTER all existing tabs (Excel's default position when adding a chart sheet), so it also appears as the last entry of the
sheetCount()tab order. The tab shares the worksheet name namespace; the name must satisfy Excel's sheet-name rules (seeinsertSheet(int, java.lang.String)) orAxyraExceptionis thrown. Extended (Office 2016+) chart types — waterfall, histogram, funnel, treemap, sunburst, box & whisker, pareto, map — are not supported on chart sheets and throwAxyraException. -
chartSheetCount
public int chartSheetCount()Number of chart-sheet tabs in the workbook (authored + imported). -
chartSheetName
The tab name of the chart sheet atindex(its position among the chart sheets, in tab order); out-of-range throwsIndexOutOfBoundsException. -
chartSheetChart
A live view of the chart hosted by the chart sheet atindex— the same read-back/edit viewSheet.chart(int)returns. Editing through the view marks the chart sheet modified, so an imported byte-preserved chartsheet is regenerated from the model on the next save.Returns
nullwhen the chart of an IMPORTED chartsheet could not be parsed into the model — the original bytes still round-trip verbatim on save; only the read-back is unavailable. An out-of-rangeindexthrowsIndexOutOfBoundsException. -
removeChartSheet
public boolean removeChartSheet(int index) Remove the chart sheet atindex(its position among the chart sheets); returns whether it existed. The workbook tab disappears and later tabs shift left, exactly likedeleteSheet(int). -
copySheet
Append a deep copy ofsourceundernewNameand return it.- Throws:
IllegalArgumentException- ifsourcebelongs to another workbookAxyraException- ifnewNamebreaks Excel's sheet-name rules or is already used
-
copySheetFrom
Append a deep copy of sheetsheetIndexof ANOTHER workbook and return the new view. Styles, shared strings and formulas are re-interned into this workbook's pools, so formatting and text survive the move; if the source name collides here the copy is auto-renamed Excel-style (Sheet1→Sheet1 (2)).References qualified with the copied sheet's own name follow the rename; references to other sheets of the source workbook become links to it, as Excel makes them (
SUM(Data!A1:A2)becomesSUM([1]Data!A1:A2), link 1 being the source file), and keep answering the source's values. Sheet-scoped defined names come along, and so do the workbook-scoped names the sheet uses, pointing at the source; a name this workbook already defines is added scoped to the copied sheet instead. Pivot tables, slicers and timelines do not come along.- Throws:
IllegalArgumentException- ifsourceis this workbookIndexOutOfBoundsException- ifsheetIndexis out of range
-
copySheetFrom
Append a deep copy of sheetsheetIndexof ANOTHER workbook undernewNameand return the new view. Same semantics ascopySheetFrom(Workbook, int), but the name is explicit: it must satisfy Excel's sheet-name rules and be unique in this workbook, orAxyraExceptionis thrown. Anullname means "source name, auto-suffixed on collision".- Throws:
IllegalArgumentException- ifsourceis this workbookIndexOutOfBoundsException- ifsheetIndexis out of range
-
combine
Append a deep copy of EVERY sheet (visible and hidden) of each source workbook, in argument order, auto-suffixing colliding names — the cross-workbook merge counterpart ofcopySheetFrom(Workbook, int)(same migration semantics and exclusions, except as follows).Each source's sheets are copied as one group: a reference from one copied sheet to another follows that sheet's rename (
SUM(Data!A1:A2)becomesSUM('Data (2)'!A1:A2)whenDatahad to be renamed), so a combined region keeps summing its own data. The source's workbook-scoped names come along, rewritten the same way; a name this workbook already defines is added as a sheet-scoped name on each copied sheet, so the copies resolve it to their own data.All arguments are validated before any sheet is copied, so an invalid argument does not leave a partial merge behind.
- Throws:
IllegalArgumentException- if any source is this workbook
-
splitToFiles
Split this workbook into one single-sheet file per sheet, written todir(created if missing), and return the written paths in sheet order.patternnames each file and must contain a{name}(sheet name, sanitized for the file system) or{index}(0-based sheet index) placeholder — e.g."{name}.xlsx"or"part-{index}.xlsx".Each output is built by copying the sheet into a fresh workbook with
copySheetFrom(Workbook, int)(same migration semantics and exclusions). A hidden sheet is made visible in its own file, since a workbook needs at least one visible sheet. This workbook is not modified.- Throws:
IllegalArgumentException- ifpatternhas no placeholderAxyraIoException- if a file cannot be written
-
sheets
A snapshot list of all sheet views, in order. -
title
The document title, ornull. -
setTitle
Set the document title (nullclears it). -
subject
The document subject, ornull. -
setSubject
Set the document subject. -
author
The author (OOXMLcreator), ornull. -
setAuthor
Set the author (OOXMLcreator). -
keywords
The document keywords, ornull. -
setKeywords
Set the document keywords. -
comments
The comments/description (OOXMLdescription), ornull. -
setComments
Set the comments/description (OOXMLdescription). -
lastModifiedBy
The user who last saved the workbook (cp:lastModifiedByofdocProps/core.xml), ornull. -
setLastModifiedBy
Setcp:lastModifiedBy. -
lastPrinted
When the workbook was last printed (cp:lastPrinted, a W3CDTF timestamp), ornull. Excel only updates this on an actual print. -
setLastPrinted
Setcp:lastPrinted(a W3CDTF timestamp, e.g.2024-03-01T09:00:00Z). -
created
The creation timestamp (dcterms:created, W3CDTF), ornull. -
setCreated
Setdcterms:created(a W3CDTF timestamp). -
modified
The last-modified timestamp (dcterms:modified, W3CDTF), ornull. -
setModified
Setdcterms:modified(a W3CDTF timestamp). -
revision
The revision number (cp:revision), ornull. -
setRevision
Setcp:revision. Preserved verbatim; never auto-incremented. -
contentStatus
The content status (cp:contentStatus, e.g. "Draft"), ornull. -
setContentStatus
Setcp:contentStatus. -
category
The document category (cp:category), ornull. -
setCategory
Setcp:category. -
language
The document language (dc:language, e.g.en-GB), ornull. -
setLanguage
Setdc:language(an RFC 5646 language tag, e.g.en-GB). -
documentVersion
The author-recorded document version (cp:versionofdocProps/core.xml), ornull.Free text. Excel neither writes nor interprets it — a producer that sets it does so for its own readers — but it must survive a round trip, which is why it is modelled rather than dropped. Not to be confused with
appVersion(), the authoring application's version indocProps/app.xml. -
setDocumentVersion
Setcp:version;nullclears it. -
application
The authoring application (ApplicationofdocProps/app.xml), ornull. -
setApplication
Set theApplicationname written todocProps/app.xml. -
appVersion
The authoring application version (AppVersion), ornull. -
setAppVersion
SetAppVersion(Excel's form isMM.mmmm, e.g.16.0300). -
company
The company (CompanyofdocProps/app.xml), ornull. -
setCompany
SetCompany. -
manager
The manager (ManagerofdocProps/app.xml), ornull. -
setManager
SetManager. -
hyperlinkBase
The base URI relative hyperlinks resolve against (HyperlinkBaseofdocProps/app.xml), ornull. -
setHyperlinkBase
SetHyperlinkBase. -
docSecurity
TheDocSecurityflags ofdocProps/app.xml, ornullwhen the workbook records none. -
setDocSecurity
SetDocSecurity(nullclears it). -
scaleCrop
TheScaleCropflag ofdocProps/app.xml, ornullwhen the workbook records none. -
setScaleCrop
SetScaleCrop(nullclears it). -
linksUpToDate
TheLinksUpToDateflag ofdocProps/app.xml, ornullwhen the workbook records none. -
setLinksUpToDate
SetLinksUpToDate(nullclears it). -
hyperlinksChanged
TheHyperlinksChangedflag ofdocProps/app.xml, ornullwhen the workbook records none. -
setHyperlinksChanged
SetHyperlinksChanged(nullclears it). -
customProperties
The custom document properties, in file order — an immutable read view (empty list when the workbook has none). Each entry carries a typedCustomProperty.Value; write throughsetCustomProperty(String, String)and its overloads, remove withremoveCustomProperty(String). -
setCustomProperty
Set (or replace) the text-typed custom document propertyname. An existing property with the same name keeps its position; a new one is appended. Names are case-sensitive. -
setCustomProperty
Set (or replace) the number-typed custom document propertyname. -
setCustomProperty
Set (or replace) the boolean-typed custom document propertyname. -
setCustomProperty
Set (or replace) the date-typed custom document propertyname. Stored as the midnight-UTC timestamp of the given calendar date (the underlying variant type carries a full timestamp). -
removeCustomProperty
Remove the custom document propertyname; returns whether it existed. Removing the last property makes a saved file omit the custom properties part entirely. -
theme
The workbook theme (color scheme + major/minor fonts), ornullwhen the workbook has no theme. Theme colors are whatColor.theme(...)references resolve against. -
setTheme
Set the workbook theme (color scheme + major/minor fonts). -
defaultStyle
The workbook default ("Normal") style — what unstyled cells render with. Its font attributes (seesetDefaultFont(io.keikai.axyra.sheets.style.CellStyle)) determine the grid metrics of every sheet. -
setDefaultFont
Replace the workbook default ("Normal") font with the font attributes ofstyle(name, size, color, bold, …); its non-font attributes are ignored. The default font is layout-critical, not just cosmetic: Excel derives the pixel width of a column character unit (the max-digit-width) from it and auto-fits height-less rows to it, so two workbooks with the same widths/heights but different default fonts lay out on different grids. -
formulaToR1C1
Convert a formula's cell references from A1 to R1C1 style, relative to the 1-based(anchorRow, anchorColumn). Quoted strings and function names are preserved. (A defined name spelled like a cell reference is treated as a reference.) -
formulaToA1
Convert a formula's references from R1C1 back to A1 style. -
precedents
The direct precedents of a cell — the cells its formula reads (may be cross-sheet). Empty for a non-formula cell. The dependency graph is built on demand. -
dependents
The direct dependents of a cell — the cells whose formulas read it. -
allDependents
All transitive dependents of a cell (does not include the cell itself). -
xmlMaps
The XML map definitions in this workbook (read-only): each map's id, name, root element, schema id and XSD schema text, read fromxl/xmlMaps.xml. Empty when the workbook defines no XML maps. The definitions are preserved byte-exact on save. -
connections
The data connections defined in this workbook (Power Query and other), read fromxl/connections.xml. Empty when the workbook has none. -
setConnectionCommand
Set the command text (e.g. a SQL statement or an M query reference) of the named connection; returns whether a connection matched. Every other byte of the connections part is preserved. -
setConnectionString
Set the connection string of the named connection; returns whether a connection matched. -
vbaModules
The VBA code modules in this macro-enabled workbook (read-only): each module's editor name, kind ("standard"/"class"/"document"), and MS-OVBA-decompressed source text. Empty when the workbook has no VBA project. ThevbaProject.binis preserved byte-exact on save regardless. -
oleObjects
The embedded OLE objects in this workbook. -
addOleObject
Embed an OLE object (raw bytes + optional ProgID); returns its index. -
setOleObjectData
public boolean setOleObjectData(int index, byte[] data) Replace the embedded OLE object's bytes in place; returns whether the index existed. Name and ProgID are kept, and — unlikeremoveOleObject(int)— any worksheet anchors from an opened XLSX stay intact: the sheet keeps displaying the object's icon, now backed by the new content. -
removeOleObject
public boolean removeOleObject(int index) Remove the embedded OLE object atindex; returns whether it existed. On workbooks opened from XLSX this also drops the imported worksheet<oleObjects>anchors, so the remaining embedded parts are kept but no longer displayed on the sheets. -
registerNamedStyle
Register a reusable named cell style (e.g."Good","Title"). Apply it to cells withRange.applyNamedStyle(String). -
namedStyleCount
public int namedStyleCount()Number of registered named cell styles. -
hasNamedStyle
Whether a named style is registered. -
removeNamedStyle
Delete a named cell style. Cells styled with it revert to the default style — Excel's "Delete" on a custom cell style clears that formatting from its users. Returns whether the name existed. -
updateNamedStyle
Redefine a named cell style and PROPAGATE the change: every cell (and row/column default) currently styled with it is restyled — Excel's "Modify…" on a cell style. Returns whether the name existed. -
addName
Add or replace a workbook-scoped defined name. -
addName
Add or replace a name scoped to a sheet. -
removeName
Remove all defined names with the given name; returns whether any matched. -
customTableStyles
The workbook's CUSTOM table-style definitions (<tableStyles>+ their differential-format payloads) plus the default table/pivot style names, as one opaque JSON value object — ornullwhen the workbook defines none. A table whosetableStyleInfonames a custom style renders with Excel's default formatting when the definition is missing, so a faithful rebuild must carry this alongsidesetTableStyle. Pass the value tosetCustomTableStyles(String)on the destination workbook. -
setCustomTableStyles
Install custom table-style definitions produced bycustomTableStyles(). -
names
All defined names, in definition order. -
findName
The first defined name matchingname, ornull. -
range
A range parsed from a sheet-qualified A1 reference — the spelling a defined name stores, e.g."Sheet1!$A$1:$C$10"or"'Q1 Data'!B2". Whole-column and whole-row bands ("Sheet1!$B:$B") expand to the grid's limits.- Throws:
IllegalArgumentException- if the reference names no sheet, names a sheet this workbook does not have, or is not a single rectangular area — a constant, a multi-area union, an external or 3-D reference
-
goalSeek
Goal seek: find the value for thechangingcell that makes thetargetcell equaltargetValue. Returns the solution (and leaves the changing cell set to it), orDouble.NaNif it does not converge. The changing cell must be a numeric input the target depends on. -
protect
public void protect(boolean lockStructure) Lock the workbook structure (no adding/removing/renaming sheets). -
protect
public void protect(boolean lockStructure, boolean lockWindows) Lock the workbook structure and/or windows. -
unprotect
public void unprotect()Remove workbook structure/window locks. -
isStructureLocked
public boolean isStructureLocked()Whether the workbook structure is locked. -
protectStructure
Lock the workbook structure (ECMA-376 §18.2.29lockStructure) with a password (ISO Write Protection hash, [MS-OFFCRYPTO] §2.4.2.2).nullor empty locks without a password. -
protectStructure
Lock the workbook structure and optionally the windows (§18.2.29). -
unprotectStructure
Clear the workbook protection after verifyingpasswordagainst the stored hash. Returnstruewhen the workbook ends up unprotected — including when it was not protected or carries no password;false(protection kept) on a mismatch. -
isStructureProtected
public boolean isStructureProtected()Whether the workbook structure is protected (alias ofisStructureLocked()). -
isWindowsLocked
public boolean isWindowsLocked()Whether the workbook windows are locked (§18.2.29lockWindows). -
setWriteProtection
Write-protect the workbook with a modify password (<fileSharing>— ECMA-376 Part 1 §18.2.12): Excel prompts for the password on open and offers read-only otherwise. The password is stored as an ISO Write Protection hash ([MS-OFFCRYPTO] §2.4.2.2) — this is a tamper deterrent, not encryption; usesaveEncrypted(Path, String)for an open password. -
setWriteProtection
Write-protect the workbook:passwordgates editing (null = none),userNamerecords who reserved the file, andreadOnlyRecommendedshows the open-read-only prompt. An entirely empty request removes the protection. -
removeWriteProtection
public void removeWriteProtection()Remove the write protection / read-only recommendation. -
isWriteProtected
public boolean isWriteProtected()Whether a modify password is stored. -
writeProtection
The write-protection state, or null when the workbook carries no<fileSharing>element. -
verifyWritePassword
Verifiespasswordagainst the stored modify-password hash;falsewhen the workbook is not write-protected. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-