Skip to content

Instantly share code, notes, and snippets.

@DrDaleks
Created August 7, 2015 12:56
Show Gist options
  • Save DrDaleks/dd6b5a2ac3ce0ebfc4de to your computer and use it in GitHub Desktop.
Save DrDaleks/dd6b5a2ac3ce0ebfc4de to your computer and use it in GitHub Desktop.
Icy Workbooks - sample script
importClass(Packages.plugins.adufour.workbooks.Workbooks)
importClass(Packages.plugins.adufour.workbooks.IcySpreadSheet)
importClass(Packages.java.awt.Color)
// Create an empty workbook
wb = Workbooks.createEmptyWorkbook();
// Get a (possibly new) sheet
sheet = Workbooks.getSheet(wb, "Test");
// Set the header row (all at once, easier to write!)
sheet.setRow(0, "Col 0", "Col 1", "Some other column"); // etc.
// Assign a few cell values
// NB: give any object (unknown types are converted to text)
sheet.setValue(0, 0, "Name");
sheet.setValue(1, 0, 3);
// Need to insert a formula?
// NB: this is the standard formula syntax. The first (corner) cell is called "A1"
sheet.setFormula(1, 1, "A2 * A2");
// How about changing the background color?
sheet.setFillColor(1, 0, Color.cyan);
// Finally, show the workbook on screen
// with a nice window title and whether the table should be editable
Workbooks.show(wb, "Workbook test", false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment