API Reference
Full reference for the DroidXLS public API. Package: com.droidoffice.xls
DroidXLS (Entry Point)
| Method | Description |
initialize(context, licenseKey) | Initialize with a commercial license key. |
isLicensed: Boolean | Whether a valid license is active. |
licenseStatus: String | Human-readable license status. |
Workbook
| Method / Property | Description |
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): Worksheet | Add 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: List | All worksheets. |
sheetCount: Int | Number of worksheets. |
activeSheetIndex: Int | Active sheet index. |
namedRanges | Workbook-level named ranges. |
Worksheet
| Method / Property | Description |
sheet["B2"] | Get cell by A1 reference. |
cell(row, col) | Get cell by 0-based index. |
name: String | Worksheet name. |
isHidden: Boolean | Whether 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. |
autoFilterRange | Auto filter range. |
protect(password) | Protect sheet. |
addPicture(...) | Add image. |
addChart(type) ... | Add chart with DSL. |
dataValidations | Data validation rules. |
conditionalFormattings | Conditional formatting. |
Cell
| Property | Description |
value: Any? | Set cell value (String, Double, Boolean, LocalDate). |
formula: String? | Set/get formula. |
cellValue: CellValue | Typed cell value. |
stringValue: String | Get value as string. |
numericValue: Double | Get 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
| Method | Description |
FormulaEvaluator(sheet) | Create evaluator for a worksheet. |
recalculateAll() | Recalculate all formulas. |
CsvConverter / HtmlConverter
| Method | Description |
CsvConverter.convertToString(sheet) | Convert to CSV string. |
HtmlConverter.convert(sheet, title) | Convert to HTML string. |