def do_compilation(fname, seed, sheet=None): sp = ExcelCompiler(filename=fname) sp.evaluate(AddressRange(seed, sheet=sheet)) sp.to_file() sp.export_to_gexf() return sp
pass # export the graph, can be loaded by a viewer like gephi print("Exporting to gexf...") excel.export_to_gexf(fname + ".gexf") # As an alternative to using evaluate to put cells in the graph and # as a way to trim down the size of the file to just that needed. excel.trim_graph(input_addrs=['Sheet1!A1'], output_addrs=['Sheet1!D1']) # As a sanity check, validate that the compiled code can produce # the current cell values. assert {} == excel.validate_calcs(output_addrs=['Sheet1!D1']) print("Serializing to disk...") excel.to_file(fname) # To reload the file later... print("Loading from compiled file...") excel = ExcelCompiler.from_file(fname) # test evaluation print(f"D1 is {excel.evaluate('Sheet1!D1')}") print("Setting A1 to 1") excel.set_value('Sheet1!A1', 1) print(f"D1 is now {excel.evaluate('Sheet1!D1')} (the same should happen in Excel)") print("Done")
pass # export the graph, can be loaded by a viewer like gephi print("Exporting to gexf...") excel.export_to_gexf(fname + ".gexf") # As an alternative to using evaluate to put cells in the graph and # as a way to trim down the size of the file to just that needed. excel.trim_graph(input_addrs=['Sheet1!A1'], output_addrs=['Sheet1!D1']) # As a sanity check, validate that the compiled code can produce # the current cell values. assert {} == excel.validate_calcs(output_addrs=['Sheet1!D1']) print("Serializing to disk...") excel.to_file(fname) # To reload the file later... print("Loading from compiled file...") excel = ExcelCompiler.from_file(fname) # test evaluation print("D1 is %s" % excel.evaluate('Sheet1!D1')) print("Setting A1 to 1") excel.set_value('Sheet1!A1', 1) print("D1 is now %s (the same should happen in Excel)" % excel.evaluate( 'Sheet1!D1'))