Node.JS/C++/Python - edit Excel .xlsx file - c++

I'm looking for a way of editing and save a specified cell in Excel 2010 .xlsx file from Node.JS. I realize, that maybe there are no production-ready solutions for NodeJS at this time. However, NodeJS supports C++ libraries, so could you suggest me any suitable lib compatible with Node?
Also, I had an idea to process this task via Python (xlrd, xlwt) and call it with NodeJS. What do you think of this? Are there any more efficient methods to edit XLSX from NodeJS? Thanks.

Basically you have 2 possibilities:
node.js does not support C++ libraries but it is possible to write bindings for node.js that interact with a C/C++ library. So you need to get your feet wet on writing a C++ addon for the V8 (the JavaScript engine behind node.js)
find a command line program which does what you want to do. (It does not need to be Python.) You could call this from your JavaScript code by using a child-process.
First option is more work, but would be result in faster executing time (when done right). Second possibility is easier to realise.
P.S.: To many question for one question. I've no idea about the xls-whatever stuff, besides it's "actually" only XML.

Related

How to get C++ to interact with the menus of a windows program/ how to get C++ to fully control another program

I am trying use C++ to automate the production of PDFs followed by transferring them into an Excel worksheet and formatting the information (Data Mining).
I am able to open/run the 3rd party program using C++ CreateProcess() or System().
But I am unable to interact with the menu of the program to import data and produce PDFs.
I have been stuck for 2 days (C++ novice) but I have done a lot of searching so I think it can be done.
Three quick questions:
Is C++ the best way to create an executable to accomplish this?
How would one get C++ (or a more recommended language) to talk to an opened program? (It is not a Microsoft program, it's an individually developed program). Once I get this I should be able to use C++ to talk to Excel and finish the job using a macro.
Out of curiosity, is there a way to accomplish all of this just by using an Excel macro? I know Excel can copy data from a PDF, but I am not sure if it can interact with another program to produce the PDFs.
Thanks a lot in advance. I really really really need your help.

Executing a console application from msvc c++

Capturing console output from a .NET application (C#)
I'm wanting to do a similar thing that is asked in that question except that I am using c++ and not c#. I have a small well tested java application that has some functions that are about to be rewritten in some of my c++ code and I'm wanting to write some unit tests for this using boost unit to test that the results are the same. Essentially I want to call this java command line application from c++. I'd rather not use the JNI if at all possible so executing the other command line application via the c++ code would be preferred.
How do I invoke a console application from my c++ application and capture all the output that is generated in the console? (I'd very much rather not have to write to an intermediate file but if that's the only way to do it then so be it)
It seems like this should be somewhat straightforward but I'm having a huge amount of trouble finding anything by searching the web as the keywords tend to find results about other things (c# and compiling from command line being 2 examples). I wouldn't be at all surprised if this question is a duplicate but I cannot find another question that is the same. If it does already exist I'm more than happy to close this question upon a link to the other one being found.
It depends on the operating system you're targeting as there's no process handling functionality in the standard C++ library. On Windows for example you would create two pipes (using the CreatePipe function) to redirect the Java app's input and output, and then run the Java app using the CreateProcess function. There's an example of this here.
But I'd really recommend using JNI instead, which is a light-years better form of interop/IPC than pipes. You'll eventually realize that if you go the pipes route.

Remote interop with OpenOffice Writer

I found some documentation about interop with OpenOffice using technologies like COM, but before delving in more deeply I wondered if anyone's worked on this kind of thing?
We have a need for the following, all wrapped up in a method call from a client PC (client talks to server using COM):
Client sends a map of name/value pairs to a server app
Server opens a Word template (.dot currently) file and looking up bookmarks using names from 1, replaces the text with values
Server saves file as a Word .doc file
We were doing this using Word but some changes in Windows 2008 mean if you run without a desktop/interactive-user, Word won't start. It's obviously a big hack but we're looking for a quick solution rather than re-engineering due to time constraints... so I wondered if we can simply run up OO Writer on the server to do the same job? I know how ugly it all is so don't really need suggestions to create a brand new C# open XML SDK application.
Multiple simultaneous requests can be ruled out as a potential problem (or at least it's never been a problem using Word so unless OO is different it'll be ignored).
If you are thinking OpenOffice might help, you could use JODReports or Docmosis to help, though you'd need a small Java program to bridge from your C++ app (cmd line or whatever). These tools will let you control OpenOffice a little easier for doing your merge task than working with the OO API directly (hopefully a lower learning curve).

best way to programmatically modify excel spreadsheets

I'm looking for a library that will allow me to programatically modify Excel files to add data to certain cells. My current idea is to use named ranges to determine where to insert the new data (essentially a range of 1x1), then update the named ranges to point at the data. The existing application this is going to integrate with is written entirely in C++, so I'm ideally looking for a C++ solution (hence why this thread is of limited usefulness). If all else fails, I'll go with a .NET solution if there is some way of linking it against our C++ app.
An ideal solution would be open source, but none of the ones I've seen so far (MyXls and XLSSTREAM) seem up to the challenge. I like the looks of Aspose.Cells, but it's for .NET or Java, not C++ (and costs money). I need to support all Excel formats from 97 through the present, including the XLSX and XLSB formats. Ideally, it would also support formats such as OpenOffice, and (for output) PDF and HTML.
Some use-cases I need to support:
reading and modifying any cell in the spreadsheet, including formulas
creating, reading, modifying named ranges (the ranges themselves, not just the cells)
copying formatting from a cell to a bunch of others (including conditional formatting) -- we'll use one cell as a template for all the others we fill in with data.
Any help you can give me finding an appropriate library would be great. I'd also like to hear some testimonials about the various suggestions (including the ones in my post) so I can make more informed decisions -- what's easy to use, bug-free, cheap, etc?
The safest suggestion is to just use OLE. It uses the COM, which does not require .NET at all.
http://en.wikipedia.org/wiki/OLE_Automation <--about halfway down is a C++ example.
You may have to wrap a few functionalities into functions for usability, but it's really not ugly to work with.
EDIT: Just be aware that you need a copy of Excel for it to work. Also, there's some first-party .h files that you can find specific to excel. (it's all explained in the Wikipedia article)
I don't know if this is an option for you, but the new office 2007 formats are in zipped XML format, which makes it very doable to do your own modifications. See here for the specifications.
SpreadsheetGear for .NET will handle your requirements and has an API which is very similar to Excel.
When you insert cells, your defined names (and any other formulas / charts / etc...) will automatically be fixed up to reference the new range (just as they would in Excel). So you would not need to update your defined names (although there is complete support for creating and updating defined names if that is what you want to do).
SpreadsheetGear is a .NET component, but you can build your own wrapper which is callable from C++.
You can see what our customers say and download the free, fully functional evalution here.
Have you already tried using the Excel COM interfaces? Obviously Excel needs to be install on the machine, and it's a pain to deal with...
I would argue that a .net solution with COM interop for linking into your C++ application is the best solution. In more than ten years of working with them, I've never seen a COM automation of Excel that didn't leak memory somewhere.
If you need to automate Excel, I recommend Visual Studio Tools for Office. If you don't need to automate, only modify files and those files can be in Office 2007 format, you're better off finding a library that manipulates the files directly instead of opening Excel to do it.
I ended up using Aspose.Cells as I mentioned in my original post, since it seemed like the easiest path. I'm very happy with the way it turned out, and their support is very good. I had to create a wrapper around it in C# that exported a COM interface to my C++ application.

Is there an easy way to provide a Matlab-based Web App or Web Service?

A colleague and I have spent a few years developing a really cool Matlab application, MDLcompress. Within Matlab, I can type "MDLcompress('filename.txt')" and it will tell me all sorts of really cool stuff about the contents of filename.txt. We'd like to allow other people to use MDLcompress without downloading the code, installing Matlab, etc. Ideally, we'd have a simple web page where they selected a file from their machine, it got uploaded to my workstation (which is already running tomcat for other purposes, if that makes things easier), kicked off a process along the lines of "matlab < MDLcompress.m filename.txt > results.txt" and then displayed results.txt in their browser or showed a link to let them download it.
Trouble is, my Matlab skills far exceed my web skills. Google has 100 generic tutorials, but nothing as simple as I want, at least not specific to Matlab.
Thanks in advance
If you are mostly proficient in MATLAB you can write web application in MATLAB with MATLAB Web Server
Edit:
Matlab Web Server is discontinued, so it is not for you if you use recent version of Matlab. May be this tutorial will help to create CGI module from Matlab code.
A possible way is to compile the matlab code into C,
and then make the C file into an apache module, and use an apache server.
I have no idea how complicated this is, but it may work.
Based on the tags, I assume you're trying to deploy to Tomcat or similar. The most straightforward way to do this is to use MATLAB Builder JA to create a Java wrapper for your code, then use the standard tools to deploy the Java as a web service.
If you can afford to lose some of Matlab's more powerful proprietary features, there are several open-source numerical computation engines that use syntax mostly compatible with that of Matlab. One of the most mature of these is GNU Octave.
There are several examples of online Octave interfaces. Octave Online is a new interface that supports a live prompt and an online editor. I am a member of the team developing Octave Online. You can find more examples of online Octave interfaces on the Octave wiki. The Octave mailing list is a good resource for prior online Octave projects.
We have developed a toolbox called Modelit Webserver Toolbox that should allow you to do this. We use this ourselves to run a Routing algorithm implemented in Matlab for an online route planner (the link is on our website). You can use the toolbox in conjunction with Tomcat and Matlab (2006b and up) or a compiled Matlab executable. The toolbox also provides a mechanism to run several jobs in parallel.