API Reference

Full reference for the DroidXLS public API. Package: com.droidoffice.xls

DroidXLS (Entry Point)

MethodDescription
initialize(context, licenseKey)Initialize with a commercial license key.
isLicensed: BooleanWhether a valid license is active.
licenseStatus: StringHuman-readable license status.

Workbook

Method / PropertyDescription
Workbook()Create a new empty workbook.
Workbook.open(inputStream)Open an existing .xlsx file.
Workbook.open(inputStream, password)Open a password-protected .xlsx file.
Workbook.openAsync(inputStream)Open asynchronously (suspend fun).
save(outputStream)Save as .xlsx.
save(outputStream, password)Save with AES-256 password protection.
saveAsync(outputStream)Save asynchronously (suspend fun).
addSheet(name): WorksheetAdd a new worksheet.
insertSheet(index, name)Insert at specific position.
copySheet(index, newName)Copy an existing worksheet.
moveSheet(from, to)Move to new position.
removeSheet(index)Remove a worksheet.
getSheet(name): Worksheet?Get worksheet by name.
sheets: ListAll worksheets.
sheetCount: IntNumber of worksheets.
activeSheetIndex: IntActive sheet index.
namedRangesWorkbook-level named ranges.

Worksheet

Method / PropertyDescription
sheet["B2"]Get cell by A1 reference.
cell(row, col)Get cell by 0-based index.
name: StringWorksheet name.
isHidden: BooleanWhether the sheet is hidden.
freeze(row, col)Set freeze pane.
insertRows(index, count)Insert rows.
deleteRows(index, count)Delete rows.
setColumnWidth(col, width)Set column width.
setRowHeight(row, height)Set row height.
addMergedRegion(range)Merge cells.
autoFilterRangeAuto filter range.
protect(password)Protect sheet.
addPicture(...)Add image.
addChart(type) ...Add chart with DSL.
dataValidationsData validation rules.
conditionalFormattingsConditional formatting.

Cell

PropertyDescription
value: Any?Set cell value (String, Double, Boolean, LocalDate).
formula: String?Set/get formula.
cellValue: CellValueTyped cell value.
stringValue: StringGet value as string.
numericValue: DoubleGet value as number.
style ...Apply styles with DSL.

CellStyle DSL

cell.style {
    font {
        bold = true
        size = 12.0
        name = "Arial"
        color = OfficeColor.RED
    }
    fill {
        patternType = PatternType.SOLID
        foregroundColor = OfficeColor.Rgb(255, 230, 200)
    }
    border {
        all = BorderStyle.THIN
        allColor = OfficeColor.BLACK
    }
    alignment {
        horizontal = HorizontalAlignment.CENTER
        vertical = VerticalAlignment.CENTER
        wrapText = true
    }
    numberFormat(NumberFormat.THOUSANDS_DECIMAL)
}

FormulaEvaluator

MethodDescription
FormulaEvaluator(sheet)Create evaluator for a worksheet.
recalculateAll()Recalculate all formulas.

CsvConverter / HtmlConverter

MethodDescription
CsvConverter.convertToString(sheet)Convert to CSV string.
HtmlConverter.convert(sheet, title)Convert to HTML string.