List of usage examples for org.apache.poi.ss.usermodel Workbook getSheet
Sheet getSheet(String name);
From source file:com.adobe.ags.curly.controller.DataImporterController.java
License:Apache License
private void openWorkbook(Workbook workbook) throws IOException { try {/*from w w w . j a v a 2s . co m*/ for (int i = 0; i < workbook.getNumberOfSheets(); i++) { worksheetSelector.getItems().add(workbook.getSheetName(i)); } sheetReader = (String sheetName) -> readSheet(workbook.getSheet(sheetName)); Platform.runLater(() -> worksheetSelector.getSelectionModel().selectFirst()); } finally { workbook.close(); } }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * simple data./*ww w. j av a2 s . c om*/ * @throws Exception if failed */ @Test public void data_simple() throws Exception { Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version); ModelDeclaration model = load("simple.dmdl", "simple"); SheetBuilder builder = new SheetBuilder(workbook, version, model); builder.addData("MODEL"); Sheet sheet = workbook.getSheet("MODEL"); assertThat(sheet, not(nullValue())); assertThat(cell(sheet, 0, 0), is("value")); }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * copy a data sheet./*from w ww . ja v a 2 s . co m*/ * @throws Exception if failed */ @Test public void data_copy() throws Exception { Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version); ModelDeclaration model = load("simple.dmdl", "simple"); SheetBuilder builder = new SheetBuilder(workbook, version, model); builder.addData("MODEL"); builder.addData("COPY"); Sheet sheet = workbook.getSheet("COPY"); assertThat(sheet, not(nullValue())); assertThat(cell(sheet, 0, 0), is("value")); }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * primitives.//ww w . j a va2s . c o m * @throws Exception if failed */ @Test public void data_primitives() throws Exception { Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version); ModelDeclaration model = load("basic_type.dmdl", "simple"); SheetBuilder builder = new SheetBuilder(workbook, version, model); builder.addData("PRIMITIVES"); Sheet sheet = workbook.getSheet("PRIMITIVES"); assertThat(sheet, not(nullValue())); checkDataSheet(sheet, model); }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * check rule.//from w w w . j a v a 2 s. c o m * @throws Exception if failed */ @Test public void rule() throws Exception { Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version); ModelDeclaration model = load("basic_type.dmdl", "simple"); SheetBuilder builder = new SheetBuilder(workbook, version, model); builder.addRule("RULE"); Sheet sheet = workbook.getSheet("RULE"); checkRuleSheet(sheet, model); }
From source file:com.asakusafw.testdata.generator.excel.SheetBuilderTest.java
License:Apache License
/** * copy a rule sheet./*from w w w .ja v a2 s . c o m*/ * @throws Exception if failed */ @Test public void rule_copy() throws Exception { Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version); ModelDeclaration model = load("simple.dmdl", "simple"); SheetBuilder builder = new SheetBuilder(workbook, version, model); builder.addRule("MODEL"); builder.addRule("COPY"); Sheet sheet = workbook.getSheet("COPY"); assertThat(sheet, not(nullValue())); for (RuleSheetFormat format : RuleSheetFormat.values()) { assertThat(format.name(), cell(sheet, format, 0, 0), is(format.getTitle())); } }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGeneratorTest.java
License:Apache License
/** * data./*from w ww .j av a2s .co m*/ * @throws Exception if occur */ @Test public void data() throws Exception { ModelDeclaration model = load("simple.dmdl", "simple"); WorkbookGenerator generator = new WorkbookGenerator(folder.getRoot(), WorkbookFormat.DATA); generator.generate(model); Workbook workbook = open(folder.getRoot(), model, WorkbookFormat.DATA); Sheet sheet = workbook.getSheet(WorkbookFormat.DATA.getSheets().get(0).getName()); checkDataSheet(sheet, model); }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGeneratorTest.java
License:Apache License
/** * data using xlsx.//from w ww. j a v a 2 s .com * @throws Exception if occur */ @Test public void datax() throws Exception { ModelDeclaration model = load("simple.dmdl", "simple"); WorkbookGenerator generator = new WorkbookGenerator(folder.getRoot(), WorkbookFormat.DATAX); generator.generate(model); Workbook workbook = open(folder.getRoot(), model, WorkbookFormat.DATAX); Sheet sheet = workbook.getSheet(WorkbookFormat.DATAX.getSheets().get(0).getName()); checkDataSheet(sheet, model); }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGeneratorTest.java
License:Apache License
/** * rule./*from www . ja v a2 s. c o m*/ * @throws Exception if occur */ @Test public void rule() throws Exception { ModelDeclaration model = load("simple.dmdl", "simple"); WorkbookGenerator generator = new WorkbookGenerator(folder.getRoot(), WorkbookFormat.RULE); generator.generate(model); Workbook workbook = open(folder.getRoot(), model, WorkbookFormat.RULE); Sheet sheet = workbook.getSheet(WorkbookFormat.RULE.getSheets().get(0).getName()); checkRuleSheet(sheet, model); }
From source file:com.asakusafw.testdata.generator.excel.WorkbookGeneratorTest.java
License:Apache License
/** * rule using xlsx./*from w w w . j a va 2s . c o m*/ * @throws Exception if occur */ @Test public void rulex() throws Exception { ModelDeclaration model = load("simple.dmdl", "simple"); WorkbookGenerator generator = new WorkbookGenerator(folder.getRoot(), WorkbookFormat.RULEX); generator.generate(model); Workbook workbook = open(folder.getRoot(), model, WorkbookFormat.RULEX); Sheet sheet = workbook.getSheet(WorkbookFormat.RULEX.getSheets().get(0).getName()); checkRuleSheet(sheet, model); }