Skip to content

create Excel addin/add larray buttons in CIC tools #349

Open
@gdementen

Description

@gdementen

Using xlwings, it would be relatively easy to have an larray addin adding a ribbon button with something like "open in LArray editor". When something is selected, it would do the opposite of "copy to Excel". When nothing is selected, it would either copy the whole sheet (like in the editor) or copy all the sheets via something like (experimental code in start.py):

def run_from_excel():
    if os.name == 'nt':
        sys.stdout = open(os.devnull, "w")
        sys.stderr = open(os.path.join(os.getenv("TEMP"), "stderr-" + os.path.basename(sys.argv[0])), "w")

    s = Session()
    # -1 is for "active", but using the caller *might* be better ( wb = xw.Book.caller() )
    s.load(-1, engine='xlwings_excel')
    edit(s)

In Excel, the code is simply:

Sub RunViewer()
    RunPython ("from larray_editor.start import run_from_excel; run_from_excel()")
End Sub
  • maybe having two different buttons would be better :
    • copy selection to larray (nothing selected open current sheet)
    • open sheets in larray
  • adding the buttons to the cic tools would probably be better but then we need to either
    • have the buttons only appear if larray is installed (or greyed out if not installed?)
    • have the buttons spit a nice error message if python/larray is not installed
    • bundle the whole thing (python, larray etc.) with the cic tools

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions