Jason Kelly
Jason Kelly

Reputation: 2655

Creating an XLS file from scratch

I am in the midst of designing a client-side hta application (using javascript only). I'd like to be able to create an xls file from scratch using the Scripting.FileSystemObject"). So basically, the output will be wrote to a file and saved as a .xls format.

How do you do this, I also wish to stay away from the ActiveX.Object("Excel.Application). As I don't want the hta application to be dependant on the users computer.

Thanks for all your help in advance,

Cheers,

Jay

Upvotes: 0

Views: 338

Answers (1)

Patrice M.
Patrice M.

Reputation: 4319

Maybe not the answer you're looking for, but when dealing with Excel files, it's worth noting that there is usually only one true shortcut: if you mean simply a table of values, you really mean a .CSV file.

Excel will gladly open a CSV file, or a resource in CSV format with a mime type appropriate for Excel. Usually, if Office/Excel is installed on the machine, then the file association will be in place. Of course, you cannot embed any formatting, just values, although maybe someone knows how to associate some kind of excel style information when opening the file (I don't).

Now, generating CSV output is straightforward, and you just have to watch for encoding of commas (which is widely referred to, and google-able as, "csv encoding" for lack of better term).

Of course, there are a large number of Excel/Office (scriptable) libraries, a lot of them being commercial in nature. You're probably looking at more work and more coupling (i.e. a solution more dependent on your library).

Upvotes: 1

Related Questions