views:

368

answers:

2

I have CSV file and Macro in VBA. I want to open CSV file in Excel and automatically launch a macro which creates a chart. Is it possible? How to do this (Using language: Java)?

+1  A: 

There are a couple ways to approach this.

First, you could use "Excel Automation" (which is a set of COM objects that actually uses Excel's internal engine to do things programatically). This is typically done using Microsoft languages (Visual Basic or C#), though there may be ways to do this with Java through some kind of adapter (I'd shy away from this method myself, as Excel automation is problematic enough when used as intended, let alone trying to do it from Java). Try research starting here.

Alternately, or you could use some external Java library (such as the Java Excel API) to create the file manually from the .csv source data. Including a macro that produces charts may be more difficult here; my quick research doesn't turn up any that support that level of interaction (e.g. creating and running macros to produce charts).

Generally speaking, this is a non-trivial task that you're going to need to do your own research on. Start by doing a web search for "Java Excel", "Java Excel Automation", "Java Excel Chart", "Java Excel Macro", and any related combination.

You may also want to consider whether there are other solutions to the underlying problem. For example, can you import the .csv data in some other way (for example, into memory with a Python script or into a relational database), and then use the Google Chart API to produce your charts? If the requirements aren't that complex in themselves, you may find more success avoiding Excel here.

Ian Varley