Coder Social home page Coder Social logo

bartolomeus-649 / excelscript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabianoliver/excelscript

0.0 1.0 0.0 171 KB

Roslyn-based Excel AddIn that allows to write, compile, and run C# code right in Excel using simple user-defined functions

C# 100.00%

excelscript's Introduction

ExcelScript

Roslyn-based Excel AddIn that allows to write, compile, and run C# code right in Excel using simple user-defined functions

Aside from doing simple immediate evaluations, some of the core features are:

  • You can create re-usable scripts on the fly in your worksheets, which will be stored in an in-memory cache with a used-defined string key.
  • You can then invoke that script using its key anywhere as often as you like
  • You can define and pass parameters to your scripts, so they can be invoked with arguments
  • Range-objects are fully supported as input parameters (ExcelScript takes care of converting & marshalling these internally)
  • You can create the parameter definitions & script manually, or just parse a function and have the AddIn extract and generate all necessary handles automatically
  • You can even register your script, meaning the AddIn will register a User Defined function with the name and all parameters you defined to invoke your script
  • A helper function lets you format & syntax highlight your C#-code in Excel
  • You can serialize/deserialize your scripts to strings or files

Some bonus features:

  • You can debug your scripts. To do so, try the following:
    1. Open the addin and the Example.xlsm
    2. Attach the debugger of your choice to the Excel.exe process (e.g. open Visual Studio -> Debug -> Attach to Process -> Excel)
    3. In any script, e.g. lets say on Sheet "Parse" in cell B18, enter "System.Diagnostics.Debugger.Break();"
    4. When this script is run, your debugger should behave as expected; break execution, show the code, show local variables, etc.
  • The library supports execution in different AppDomains. By default, a script will run in a shared appdomain between all other scripts; you could also pass in an option to run in a shared appdomain with the main addin (ExcelDna's default domain), or to create a seperate appdomain for that script.
  • By default, all functions are marked non-volatile. Unfortunately, that means that after opening a workbook, you need to refresh each formula that creates a script by hand or macro. ExcelScript offers an experimental way around this, though:
    1. Open The ExcelScript-AddIn.xll.config
    2. set TagDirtyMethodCalls to true
    3. This will mark each cell creating a handle (script, parameter and so on) to dirty once. Could be particularly useful in manual calculation mode (in auto calculation mode, all scripts would run on the next recalculation, so not very useful).

Project includes an exemplary Excel-file to demonstrate usage. Please see the Wiki on Github for further guidelines.

excelscript's People

Contributors

fabianoliver avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.