X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FExcelImport.java;h=a8bb342b33a2e8cb8fb5e796c365bbbc4b12be97;hp=81fd2cfd4fb183277c7ea047819c6a66edd343a0;hb=c9a552af1020b5e6d4cf0da0a00bd758de772c2a;hpb=0d82e7808541ed486f6027a28038d44d2d93711a diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/ExcelImport.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/ExcelImport.java index 81fd2cfd4..a8bb342b3 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/ExcelImport.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/ExcelImport.java @@ -39,12 +39,17 @@ import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.db.service.XSupport; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; -import org.simantics.spreadsheet.graph.SpreadsheetStyle.SpreadsheetStyleBuilder; -import org.simantics.spreadsheet.graph.formula.SpreadsheetEvaluationEnvironment; -import org.simantics.spreadsheet.graph.parser.SheetFormulaParser; -import org.simantics.spreadsheet.graph.parser.ast.AstValue; +import org.simantics.spreadsheet.Spreadsheets; import org.simantics.spreadsheet.resource.SpreadsheetResource; -import org.simantics.spreadsheet.util.SpreadsheetUtils; +import org.simantics.spreadsheet.solver.SpreadsheetBook; +import org.simantics.spreadsheet.solver.SpreadsheetStyle; +import org.simantics.spreadsheet.solver.SpreadsheetStyle.SpreadsheetStyleBuilder; +import org.simantics.spreadsheet.solver.formula.CellValueVisitor; +import org.simantics.spreadsheet.solver.formula.SpreadsheetEvaluationEnvironment; +import org.simantics.spreadsheet.solver.formula.parser.SheetFormulaParser; +import org.simantics.spreadsheet.solver.formula.parser.ast.AstValue; +import org.simantics.spreadsheet.synchronization.ExcelArrayFormula; +import org.simantics.spreadsheet.synchronization.ExcelFormula; import org.simantics.utils.DataContainer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +61,7 @@ public class ExcelImport { private static final double POINT_TO_PIXEL_RATIO = 1.33; public static void importBook(Resource container, File file) { - importBook(container, file); + importBookR(container, file); } public static Resource importBookR(Resource container, File file) { @@ -124,7 +129,7 @@ public class ExcelImport { graph.claim(sheet, L0.ConsistsOf, L0.PartOf, newCell); } - BTree bt = new BTree(graph, SpreadsheetUtils.SPREADSHEET_BTREE_SIZE, SR.Lines, SR.LineNode, L0.PartOf, true); + BTree bt = new BTree(graph, Spreadsheets.SPREADSHEET_BTREE_SIZE, SR.Lines, SR.LineNode, L0.PartOf, true); result.add(bt); Resource lines = bt.rootOfBTree(); @@ -172,7 +177,7 @@ public class ExcelImport { Cell val = row.getCell(i, Row.RETURN_BLANK_AS_NULL); if(val != null) { - String cellName = SpreadsheetUtils.cellName(rowN, i); + String cellName = Spreadsheets.cellName(rowN, i); int ccIndx = val.getColumnIndex(); if(columnWidths.size()<=ccIndx){ @@ -219,8 +224,12 @@ public class ExcelImport { } else if(Cell.CELL_TYPE_STRING == val.getCellType()) { graph.claimLiteral(cell, SR.Cell_content, SR.Cell_content_Inverse, L0.Variant, Variant.ofInstance(val.toString()), Bindings.VARIANT); } else if(Cell.CELL_TYPE_NUMERIC == val.getCellType()) { - Double value = Double.parseDouble(val.toString()); - graph.claimLiteral(cell, SR.Cell_content, SR.Cell_content_Inverse, L0.Variant, Variant.ofInstance(value), Bindings.VARIANT); + try { + Double value = Double.parseDouble(val.toString()); + graph.claimLiteral(cell, SR.Cell_content, SR.Cell_content_Inverse, L0.Variant, Variant.ofInstance(value), Bindings.VARIANT); + } catch (Exception e) { + graph.claimLiteral(cell, SR.Cell_content, SR.Cell_content_Inverse, L0.Variant, Variant.ofInstance(val.toString()), Bindings.VARIANT); + } } else { graph.claimLiteral(cell, SR.Cell_content, SR.Cell_content_Inverse, L0.Variant, Variant.ofInstance(val.toString()), Bindings.VARIANT); System.err.println("Unprocessed cell type " + val.getCellType() + ", SheetName: " + sheetName + ", Row: " + rowN + ", Col:" + i); @@ -590,7 +599,7 @@ public class ExcelImport { SheetFormulaParser p = new SheetFormulaParser(new StringReader("(-(0.2/2)+SQRT((0.2/2)^2-4*((0.2/2)^2-(3*0.17625)/(PI()*4.7))))")); AstValue v = p.relation(); System.err.println("v="+v); - SpreadsheetBook book = new SpreadsheetBook(); + SpreadsheetBook book = new SpreadsheetBook("http:/"); Object o = v.accept(new CellValueVisitor(SpreadsheetEvaluationEnvironment.getInstance(book), null)); System.err.println("o="+o); }