import java.util.Map;
import java.util.Optional;
+import org.simantics.Simantics;
import org.simantics.db.Resource;
import org.simantics.fileimport.SimanticsResourceFileImport;
+import org.simantics.spreadsheet.graph.ExcelImport;
public class ExcelFileImport extends SimanticsResourceFileImport {
}
@Override
- public Optional<Resource> perform(Resource parent, Path file) throws Exception {
- throw new UnsupportedOperationException("Excel import is not yet supported");
+ public Optional<Resource> perform(Resource possibleSelection, Path file) throws Exception {
+ if(possibleSelection != null) {
+ //Make sure the selection is of valid type here
+ return Optional.ofNullable(ExcelImport.importBookR(possibleSelection, file.toFile()));
+ } else {
+ throw new NullPointerException("No selection provided - Cannot import book");
+ }
}
@Override
return ALLOWED_EXTENSIONS;
}
+ @Override
+ public Resource defaultParentResource() {
+ return null;
+ }
+
}