This example applies the second table style for the range.
Range range = sheet.range("A1:B2"); range.setText("Hello World"); range.autoFormat(spreadsheet.getTableStyles().item(2).getName());
Related information
autoFormat method