Tag Archives: excel

Javascript Export HTML table to MS Excel (JScript)

Here’s a little code snippet to export an HTML table to MS Excel through utilising ActiveXObject(“Excel.Application”) from Internet Explorer.

The JavaScript (in this case utilising Microsoft’s JScript) runs over the table displayed pulling out the relevant data and exporting into the instantiated copy of Excel. This is a working example based loosely on Microsoft’s http://support.microsoft.com/kb/234774 Knowledgebase Article “How to automate Excel from an HTML Web page by using JScript”.

Worth noting is that the garbage collection between the JScript and MS Excel doesn’t work too well and more often than not one can be left with the instantiated copy of MS Excel still in memory (see it in the Task Manager). One must manually remove these instances.

Perhaps dynamically inputting a module to clean up from within MS Excel on the workbook deactivating might clear this up – not tried this though!?

  • Share/Bookmark

Export Access to Excel with Custom Headers

Have you noticed how the “out the box” solution to export your dataset from MS Access to MS Excel doesn’t give much room to give custom headers to your worksheet?

Through utlising ActiveX you can instantiate a copy of MS Excel in memory to add in your own custom headers etc. prior to exporting your MS Access dataset into the worksheet.

The below code example shows you how to add 5 custom headers to your sheet. Just add in your own SQL query where it is indicated.

  • Share/Bookmark

Excel Split Firstname Lastname 2 Columns

Excellent post in the MSDN microsoft.public.excel.programming community regarding the splitting of a firstname and lastname into two seperate columns.  The honours go to someone called “Bam”.

Last Name
=IF(ISERROR(LEFT(B2,FIND(“,”,B2,1)-1)),RIGHT(B2,LEN(B2)-(FIND(” “,B2,1))),LEFT(B2,FIND(“,”,B2,1)-1))

First Name
=IF(ISERROR(RIGHT(B1,LEN(B1)-(FIND(“,”,B1,1)+1))),LEFT(B1,FIND(” “,B1,1)+1-1),RIGHT(B1,LEN(B1)-(FIND(“,”,B1,1)+1)))

  • Share/Bookmark

Hyperion Essbase – Excel – Auto-connect

A few folk have asked how to just connect automatically to Essbase from Excel VBA. Please find below a simple VBA sub stripped back to show this. Use the following to initialise with your own details in place.

Call initialise("xxx","xxx","xxx","xxx","xxx")

  • Share/Bookmark

Hyperion Essbase -> Excel -> Access -> automagic

Accessing Hyperion Essbase is no problem directly from their MS Excel plugins. Though what happens if one wants to import on-the-fly and put that into MS Access so you can deliver your MI: Management Information, alongside current data without having to analyse and alter Hyperion Essbase output in Excel before exporting to textfile format or CSV before manipulation?

Well, why not try the below code!

The below function run within MS Access will write an “Essbase connection plugin” before instantiating a copy of MS Excel to run Essbase from. Unfortunately if you don’t write out and pull in the textfile to create a module in Excel as is within the code Microsoft’s security permissions now deny access. Give them their due – it was a good move for certain issues.

After the “plugin” is pulled into the MS Excel workbook it fires a connection to Essbase and in this case draws down and partitions the relevant info to worksheets. Note the code will require setting up against whatever Essbase fields you require from your system.

The code as you will see at the bottom will clear down any previous retrieval before using MS Access’  TransferSpreadsheet import functionality to pull in the retreived workbook. The code also requires a table within MS Access to hold your Hyperion Essbase login details. In this case the table is called tbl_essbase_credentials and can be seen within the code. The Excel workbook is cleared down and you are left with your Hyperion Essbase MS Excel retrieval in your MS Access database.

Way to go!

So the process from MS Access is to run function and -> create a module for import into MS Excel -> start a virtual copy of MS Excel -> import the module into the virtual copy of MS Excel -> run virtual module to connect to Hyperion Essbase and download required data -> save MS Excel workbook and transfer the spreadsheet into MS Access -> clean up. All from within MS Access!

  • Share/Bookmark

Export Excel to HTML

Having found on more than a few occasions that MS Excel’s output to HTML is more than a little bloated and not very editable I needed a way to output clean HTML markup to a simple shared folder area.

This was originally used in Excel 97 and has not been tested in later versions though will most likely work fine.

  • Share/Bookmark