A node.js chart service powered by Excel

Updated 17:15 EEST: added a diagram of the flow and updated chartServer.js

In a previous article I have shown how to use Excel to generate image charts with Microsoft Excel. In this article I will take this one step further and add a HTTP interface to that script so you can invoke it from a browser.

The ingredients are node.js and Microsoft Excel.  node.js offers an extremely lightweight ( 5.5 MB) framework to run a JavaScript server that receives HTTP requests, dispatches the requests to excelPieChart.vbs which in turn produces image charts via Excel. These images are served back as the response for the HTTP requests.


Installing and starting this server should take less than 2 minutes, with the biggest part of it being the download of node.js. The solution does not require any node.js modules other than the standard ones.

Using the service is even simpler:


http://giediprime:8000/chart?labels="High|Medium|Low"&data="2|25|8"&title="node.js chart example"


What is node.js

Quoting from http://node.js:

Node.js® is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

In simpler words node.js is a an application that allows you to run JavaScript outside a browser. The application comes with a list of useful JavaScript libraries that allow creating interesting applications immediately and with very little code.

NOTE: instead of javascript and node.js I could have used a Java servlet deployed in Apache Tomcat or WebSphere or other similar solutions like .net but node.js allowed for fast prototyping and testing.

Solution flow

node.js runs chartService.js which implements a tiny HTTP server  The server receives HTTP requests, decodes their parameters and uses them in command line calls to excelPieChart.vbs

DISCLAIMER: the example is provided as-is without warranty of any kind, express or implied.

NOTE: the server implements a number of validity checks. The main concern is security and the possibility for remotely running arbitrary commands on the server.  The parameter validation should reject most illegal request and avoid this behavior but considering the limited time I spent prototyping this example it is possible for carefully crafted requests to allow command execution on server.  If you use this code make sure you review it again for security and grant access only to legitimate users.

 Installing the solution

  1. download and install node.js from http://nodejs.org/
  2. download the nodeJSChartService.zip from RPE devWorks wiki
  3. inflate the archive on your file system
  4. run chartService.js in node.js
d:\tools\chartService> node chartServer.js "d:\tmp"

The 3rd argument in the command line is the path to a temp folder on your machine where the service can create the temporary chart images.

You should see the following response in the console

D:\tools\chartService>node chartServer.js "d:\tmp"
Using temp folder: d:\tmp
Server running at

You should now test the service from a browser:

http://giediprime:8000/chart?labels="High|Medium|Low"&data="2|25|8"&title="node.js chart example"

Test setup

The easiest setup is to download node.exe and put it in the same folder with chartServer.js and the excelPieChart.vbs scripts:

 Volume in drive D has no label.
 Volume Serial Number is 545B-943F

 Directory of D:\tools\chartService

2014-08-22  01:12 PM   <DIR> .
2014-08-22  01:12 PM   <DIR> ..
2014-08-22  12:59 PM   chartServer.js
2014-08-22  11:56 AM   excelPieChart.vbs
2014-08-22  11:40 AM   node.exe

Author: Dragos Cojocari

Architect for Rational Publishing Engine

7 thoughts on “A node.js chart service powered by Excel”

  1. I am exploring solutions using node.js, D3 and phantom.js that would allow using powerful chart services like the new Google Charts API to generate images to be used in RPE documents. Phantom.js solutions look almost trivial .

  2. Nice article Dragos. Node.js is very interesting. Much simpler than Java. Have you looked at using Express for HTTP?

    1. Thanks Arthur. I have seen Express being referenced in various Node.js articles and I think I will use it for a next iteration of this service. But for this first iteration of the service I wanted the most simple solution possible, once that requires no additional Node.js packages.

  3. Hey Dragos, if I use this in an image, is just a script where I set up that string? i.e.
    var server = “http://doors.ng.int:8000/chart?labels=”;
    var title = “Priority”;
    var labels = “Mandatory|1|2|3”;
    var data += _PMand + “|” + _P1 + “|” _P2 + “|” + _P3;

    var strOut = server + “\”” + labels + “\”” + “&data=\”” + data + “\”” + “&title=” + “\”” + title + “\””;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s