Created
August 7, 2015 12:47
-
-
Save DrDaleks/83a882257cddef71fef9 to your computer and use it in GitHub Desktop.
Icy Workbooks - sample code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some import statements you might need (in case you hate auto-imports ;)) | |
import org.apache.poi.ss.usermodel.Workbook; // NOTE: this comes from Apache POI | |
import plugins.adufour.workbooks.Workbooks; | |
import plugins.adufour.workbooks.IcySpreadSheet; | |
/** | |
* A test to make sure the plug-in works as intended. Also useful as a sample code | |
*/ | |
public static void test() | |
{ | |
// Create an empty workbook | |
Workbook wb = Workbooks.createEmptyWorkbook(); | |
// Get a (possibly new) sheet | |
IcySpreadSheet 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