/** * Wrap source to XlsWorkbookSourceCodeModule */ protected XlsWorkbookSourceCodeModule getWorkbookSourceCodeModule(ExtensionModule extensionModule, IOpenSourceCodeModule source) throws OpenLCompilationException { try { // TODO Check the cases when source can be UrlSourceCodeModule or // another one. File projectFolder = new File(new File(new URI(source.getUri())).getParent()); return new XlsWorkbookSourceCodeModule(source, new LazyXmlRulesWorkbookLoader(projectFolder, extensionModule)); } catch (URISyntaxException e) { throw new OpenLCompilationException(e.getMessage(), e); } }
private void preprocessWorkbook(IOpenSourceCodeModule source) { String uri = source.getUri(); if (preprocessedWorkBooks.contains(uri)) { return; } preprocessedWorkBooks.add(uri); TablePartProcessor tablePartProcessor = new TablePartProcessor(); XlsWorkbookSourceCodeModule workbookSourceModule = new XlsWorkbookSourceCodeModule(source); WorksheetSyntaxNode[] sheetNodes = createWorksheetNodes(tablePartProcessor, workbookSourceModule); workbookNodes.add(createWorkbookNode(tablePartProcessor, workbookSourceModule, sheetNodes)); messages.addAll(tablePartProcessor.getMessages()); }
srcToIndex = new XlsWorkbookSourceCodeModule(source); } else { try {
/** * Creates virtual {@link XlsSheetGridModel} from poi source sheet. * * @param sheet poi sheet source * @return virtual grid that wraps sheet */ private static XlsSheetGridModel createVirtualGrid(Sheet sheet) { final StringSourceCodeModule sourceCodeModule = new StringSourceCodeModule("", null); final SimpleWorkbookLoader workbookLoader = new SimpleWorkbookLoader(sheet.getWorkbook()); XlsWorkbookSourceCodeModule mockWorkbookSource = new XlsWorkbookSourceCodeModule(sourceCodeModule, workbookLoader); XlsSheetSourceCodeModule mockSheetSource = new XlsSheetSourceCodeModule(new SimpleSheetLoader(sheet), mockWorkbookSource); return new XlsSheetGridModel(mockSheetSource); }
public static void main(String[] args) { IIndexParser[] parsers = { new WorkbookIndexParser(), new WorksheetIndexParser(), new TableIndexParser() }; IIndexer[] indexers = {}; IndexRunner ixr = new IndexRunner(parsers, indexers, new DefaultIndexer()); Index index = new Index(); String file = "C:\\__exigen\\customer\\SRP\\ContractAttributes_5.5.14.xls"; // "tst/xls/TestLookup.xls" for (int i = 0; i < 10; ++i) { FileSourceCodeModule source = new FileSourceCodeModule(file, null); XlsWorkbookSourceCodeModule src = new XlsWorkbookSourceCodeModule(source); ixr.index(src, index); } }
public static void main2(String[] args) { IIndexParser[] parsers = { new WorkbookIndexParser(), new WorksheetIndexParser(), new TableIndexParser() }; IIndexer[] indexers = {}; IndexRunner ixr = new IndexRunner(parsers, indexers, new DefaultIndexer()); Index index = new Index(); String file = "C:\\__exigen\\customer\\SRP\\ContractAttributes_5.5.14.xls"; // "tst/xls/TestLookup.xls" FileSourceCodeModule source = new FileSourceCodeModule(file, null); XlsWorkbookSourceCodeModule src = new XlsWorkbookSourceCodeModule(source); ixr.index(src, index); IndexQuery iq = IndexQueryParser.parse("account id unique"); TreeSet<HitBucket> hitBuckets = iq.executeSearch(index); String[] tokens = tokens(iq.getTokensInclude(), index); for (HitBucket hb : hitBuckets) { String text = hb.getElement().getIndexedText(); String res = HTMLHelper.htmlStringWithSelections(text, tokens); System.out.println("\n++++++++++++++++++++++\n" + hb.getWeight()); System.out.println(res); } }