1 package org.simantics.spreadsheet.fileimport;
3 import java.nio.file.Path;
4 import java.util.HashMap;
6 import java.util.Optional;
8 import org.simantics.Simantics;
9 import org.simantics.db.Resource;
10 import org.simantics.fileimport.SimanticsResourceFileImport;
11 import org.simantics.spreadsheet.graph.ExcelImport;
13 public class ExcelFileImport extends SimanticsResourceFileImport {
15 private static final Map<String, String> ALLOWED_EXTENSIONS = new HashMap<>(2);
18 ALLOWED_EXTENSIONS.put("*.xls", "Excel file *.xls");
19 ALLOWED_EXTENSIONS.put("*.xlsx", "Excel file *.xlsx");
23 public Optional<Resource> perform(Resource parent, Path file) throws Exception {
24 return Optional.ofNullable(ExcelImport.importBookR(parent, file.toFile()));
28 public Map<String, String> allowedExtensionsWithFilters() {
29 return ALLOWED_EXTENSIONS;
33 public Resource defaultParentResource() {
34 return Simantics.getSession().getRootLibrary();