Excel automation replacement - excel

Where I work, there are some tools that create Excel files by means of Excel's win32com automation (not sure if this is the precise name).
We want to remove Excel. Is there a way to "fake" Excel interface so that we don't have to modify the original tools?
I would like to have a tool in any programming language that when Excel is called through win32com, the tool processes the calls creating the .xlsx.

Related

VSTO Excel Add-In and SpreadsheetGear

We're working on a Excel Add-In in C# .Net 4.
One of the requirements is to update a worksheet with results of some processing.
The issue is, we need to do this both while the Excel file is open (with the Add-In), and also in batch (while the file is closed).
We have a SpreadsheetGear licence already to generate Excel files.
Is it possible to modify an XLS file whilst it is open in Excel, using SpreadsheetGear?
Or must we have two sets of code to generate the same information? One using Excel Interop for open files, and one using SpreadsheetGear on closed files?
Got a direct response from SpreadsheetGear.
SpreadsheetGear runs on a totally separate process from Excel and has
no way to access their runtime and/or currently opened workbooks—our
product was built from the ground up using the .NET Framework
libraries and has absolutely no dependencies from Excel. The only way
to access files like you require would be to first save them to disk
from Excel and then open them with SpreadsheetGear.
So it looks as if we'll have to implement two sets of code to do the same thing.

How to write to an Excel file through Matlab using OpenOffice?

I would like to write a module in Matlab for writing to an excel file. I am using Openoffice in Windows Vista.
I have a module which would work with Microsoft excel, since I donot have Microsoft office, it would throw an exception.
Here is the Matlab code segment which I would like to change to work for openoffice
Excel = actxserver ('Excel.Application');
This code segment is throwing an exception. Any idea how to change the code to work for open office?
I am not familiar with the Matlab API's that I need to use to read/write excel files
That's not exactly Matlab's doing there. You're creating an Excel ActiveX object and create the file through that. The result is that Excel itself is writing the file as you're only controlling Excel.
OpenOffice seems to allow something similar, even though ActveX. Here is an introduction. But you likely have to re-create all code that creates the file from scratch, as the APIs are incompatible.
As #Joey says, you need to re-write all of the excel-related code in order to get Excel to create the XLS file. If you need to write something that allows you to switch between Excel and OpenOffice depending on what is installed, then I would do it using the MATLAB OOP features by creating an abstract base class that implements the process and deriving classes to wrap the Excel- and OOO-based low-level commands.

Is this possible in Excel: Open XLS via commandline, OnLoad import CSV data, Print as PDF, Close Doc?

Thinking that to solve a problem I've got this is the fastest solution:
Generate a custom CSV file on the file (this is already done via Perl).
Have a XLS document opened via commandline via a scripting language (clients already got a few Perl scripts running in this pipeline.)
Write VBA or record a macro that executes the following OnLoad:
Imports a the data from the CSV file into the report template,
Print the file via PDF driver to fixed location using data in the CSV to name the file.
Closes the XLS file.
So, is this possible via Excel macros, if not is it possible via VBA -- thanks!
NOTE: Appears I've got to have a copy of MS Office anyway, so this is much faster to get going than using Visual Studio Tools for Office (VSTO). The report template is going to be on a server, and this way the end user can build as many reports as they like, "test" by printing a PDF using a demo CSV file, and import/embed the marco or VBA when they're done. I'd looked in Jasper Reports, but the end user is putting ad-hoc static text and groupings all over the report and I figure this way they can build reports how ever they want and then automate them. Both of these questions by me and the resulting comments/feedback are related to this question:
In Excel, is it possible to automate reading of CSV data into a template and printing it to PDF from the commandline?
Is it possible to deploy a VB application made in Excel as a stand alone app?
FOCUS OF QUESTION: Again, focus of the question is if this is possible via Excel marcos, if not macros VBA, and if there's any huge issue with this approach; for example, I know this is going to be "slow" since Excel would be loaded per job, but there's 16GB of ram on the server and it's not used at all. Figure since I've got to have a copy of office on the server anyway, this is a much faster approach.
If you've got any questions, let me know via comments.
I suppose you could launch the report file from perl and then have a macro inside the report file automatically look for the newest csv file to import. Then you could process and output. So you just need to launch the proper excel file with the embedded macros from perl and then let excel and VBA take over.

Programatically converting from MS word to Excel

Is there anyway to problematically take a MS Word file and convert to excel. (Obviously, word would to guess where to put stuff). Any language would be fine
That's a pretty wide-open question. The content of the Word document will affect how easy/hard this is.
One method you could look at is using Word automation to open the Word document and then write out a new file using comma-separated format and just name the file with a .xls extension. Upon opening this file up in Excel it should "just work".
If you need rich formatting in your output Excel document, you could use Excel automation to build your output document. Using this you'd have both Word automation (read) and Excel automation (write) in your program.
Another option that I've used (but it's a bit pricey) in a server environment is the Aspose libraries Aspose. They have a pretty nice API (at least for Word, which is what I've used) and they eliminate the automation angle.
See http://blogs.msdn.com/brian_jones/archive/2009/04/01/importing-a-table-from-wordprocessingml-to-spreadsheetml.aspx
Here is a resource on automating office applications: Office Object Models

Using Office to programmatically convert documents?

I'm interested in using Office 2007 to convert between the pre-2007 binary formats (.doc, .xls, .ppt) and the new Office Open XML formats (.docx, .xlsx, .pptx)
How would I do this? I'd like to write a simple command line app that takes in two filenames (input and output) and perhaps the source and/or destination types, and performs the conversion.
Microsoft has a page which gives several examples of writing scripts to "drive" MS Word. One such example shows how to convert from a Word document to HTML. By changing the last parameter to any values listed here, you can get the output in different formats.
The easiest way would be to use Automation thru the Microsoft.Office.Interop. libraries. You can create an instance of a Word application, for example. There are methods attached to the Application object that will allow you to open and close documents, plus pretty much anything else you can accomplish in VBA by recording a macro.
You could also just write the VBA code in your Office application to do roughly the same thing. Both approaches are equally valid, depending on your comfort in programming in C#, VB.NET or VBA.

Resources