Example: TableStyle

This example applies a table style for the range (A1:E10).

import com.ibm.symphony.javaapi.Application;
import com.ibm.symphony.javaapi.spreadsheet.Range;
import com.ibm.symphony.javaapi.spreadsheet.Sheet;
import com.ibm.symphony.javaapi.spreadsheet.Spreadsheet;
import com.ibm.symphony.javaapi.spreadsheet.Spreadsheets;
import com.ibm.symphony.javaapi.spreadsheet.TableStyle;
import com.ibm.symphony.javaapi.spreadsheet.TableStyles;

public class TableStyleExample {

	public void example() {
		try {
			Application application = Application.getInstance();
			Spreadsheets spreadsheets = application.getSpreadsheets();
			Spreadsheet spreadsheet = spreadsheets.openSpreadsheet(
					"D:\\test.ods", true);
			Sheet sheet = spreadsheet.getActiveSheet();
			Range range = sheet.range("A1:E10");
			range.setText("Hello World");
			TableStyles tableStyles = spreadsheet.getTableStyles();
			TableStyle tableStyle = tableStyles.item(2);
			range.autoFormat(tableStyle.getName());

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Related information

TableStyle

TableStyles property in Spreadsheet