Please help!

I have the following code in the head section of my web page:

var serverLoc = "http://www.mydomain.com/mypath/";
var serverFile = serverLoc+"myexcel.xls";

var ehandle = new ActiveXObject("Excel.Application"); //error occurs
var eWBhandle = ehandle.Workbooks.Open(serverFile);
var eShandle = eWBhandle.ActiveSheet;
var cell1 = eShandle.Cells(1,1).Value;
// get more data

It works fine when I'm launching the page on my local machine referencing an xls on my hard drive (serverLoc). But when I upload the page to a server along with the xls file (changing the path of the file, of course), I get the above error. Note, I am simply reading the contents of the xls and pulling certain data out to be displayed on my page.

My ActiveXObject internet settings are set to prompt me. Even if I open the flood gates and change the setting to Enable, I still get the above error. As a result, anything I do beyond the open of the spreadsheet does nothing.

I really need help in resolving this or coming up with an alternate approach. Ultimately, I need to provide my users with a low tech solution of adding/changing some data (storing it in an external file of some sort) that I can then read to display on a page. We're talking about maybe a dozen records with about 10 cells of information. So a "database" isn't really called for and, as I said, I need a low tech solution because this user group is not tech savvy. In fact, I would have to teach them how to use Excel.

And I can't expect visitors to the site to open up their security so they don't encounter an error as well as the inability to see the data my users are maintaining externally via a file. If it was a matter of changing an internet setting to prompt the user to allow running my ActiveXObject, I could inform them of that requirement but wouldn't want to force them to completely expose themselves with an enable setting. But a prompt or enable doesn't fix the problem anyway.

I had read somewhere that getting a signed certificate and attaching it to my code (and this is above my head) would solve this problem. But if this is truly the solution, then I need help in understanding how this works precisely. How do I attach it to my code exactly? So just thinking out loud here. Bottom line.....

any and all help is appreciated!!!


7 Years
Discussion Span
Last Post by fxm


My first thought would be "Mime Type".

The server on which I hold my sites incorporates a multifaceted monster called CPanelII, which includes a "Mime Types" link on the front page.

The Mime Types page shows a whole raft of defaults plus the ability to add/modify. The intro at top of page reads as follows:

MIME types tell browsers how to handle specific extensions. For example, the text/html MIME type equates to .htm, .html, and .shtml extensions on most servers, and this tells your browser to interpret all files with those extensions as HTML files. You can alter or add new MIME types specifically for your site (note that you can not alter the system defined MIME type values). MIME types are often used to handle new technologies as they appear. When WAP technology first appeared no one had these extensions set up on their server. With MIME types, however, you could have set it up yourself and begun serving WAP pages immediately.

And the entry for Excel files reads:

Mime Type: application/vnd.ms-excel
Extension: xls

Other servers may have different systems but the overall effect will be the same. The web space rented as part of your ISP account is unlikely to provide this sort of flexibility, though it's just possible there might be some equivalent Apache directive which you could put in an htaccess file alongside the .xls you want to serve.

All servers are different. If in doubt, contact the administrators.



I'm a complete newbie at this, but for this approach to work it appears to me that - in addition to having Excel - all users would have to enable
"Initialize and script ActiveX controls not marked as safe for scripting"
for the Internet zone. Clearly not acceptable. Finer control of security would appear to require putting your site in their trusted zones, which in turn requires AFAICT an https: address.

If the data is as simple as you suggest, using XMLHttpRequest you could probably GET, display, update and PUT a simple set of values. No need for Excel, works with non-IE browsers, and with a proper choice of format the values can be displayed in an HTML element.

But, as I say, I'm a complete newbie at this.


And of course if values for each user are separate (instead of being posted to a "central" table to be available to you or others) you could use cookies.


Come to think of it, you can eliminate rafts of problems [permissions, file management, etc., etc.] by not maintaining any local xls/txt/cookie files and instead using a Google [online] spreadsheet (or, depending on how you need to manage user access, spreadsheets).


Okay. I've been all over the web and doing some rather painful research. Airshow, I really don't know where you were going with the MIME types thing. Can you expand on your comment (I have 0 experience or knowledge in this area so assume you're talking to someone doing programming 101)?

fxm, I did look at Google docs but wow, trying to find the appropriate syntax to then access a Google spreadsheet has surfaced simple to highly complex coding and presumably to ultimately do the same or very similar things. So it's been highly confusing. But since you brought it up, can you tell me what is wrong with this code snippet which I gathered from some source (as I said I've been all over the place at this point)?

So, I created a Google spreadsheet and made it public and accessible to everyone without the need to sign-in (or at least I believe I did what was required to do so). I grabbed the key for the spreadsheet. But the script referencing my spreadsheet had slightly different syntax in the original code snippet. After the key part of the path, there was an additional "/od6" and then the rest of it. The od6 was the worksheet id for the example I grabbed the code from. I removed that from mine since my spreadsheet has only one sheet but perhaps there is an id attached to even one sheet. I just couldn't find any information as to how to find this. It's not simply the sheet name I've given it, is it (well I left it as Sheet1)?

So from my web page, I want to read that spreadsheet (not edit it, just read it) then do something with the data I've captured out of each row/cell in the spreadsheet. So under my head section, I have:

<script type="text/javascript" src="http://www.google.com/jsapi"></script> <!-- do I even need this? -->

var worksheetJSON;
var chartData = Array();
var ds = {"gallery": [
{"name": "name", "breed": "breed", "sex": "sex", "dob": "dob", "status": "status", "profile": "profile", "image": "image", "srg": "srg"}

function loadWorksheetJSON(json) {
worksheetJSON = json;
for(i=0;i<worksheetJSON.feed.entry.length;i++) {
entry = worksheetJSON.feed.entry;
entrycell = Array();
alert(colstr); <!-- nothing happens, errors out on above line -->

<!-- go build display string using chartdata -->

<script src="http://spreadsheets.google.com/feeds/list/0AvRNyZCu4FyldFowU1hOdUJPbHJNUkVWZm1USTAyOEE/public/values?alt=json-in-script&callback=loadWorksheetJSON"></script>

So I don't know if there is anything missing in the above but obviously I've got a syntax problem. Also, I have no idea if I'm using the ds var correctly. I "assume" that it simply maps, positionally, to the columns in my spreadsheet (not that "name", "breed", etc., are actually the column headings in the spreadsheet but are the first and second columns).

I have posted this on a Google forum but I'm spreading the net since I've spent quite a lot of time on trying to solve this issue. So any ideas?


Edited by happygeek: fixed formatting



I may be wrong about MIME-Type. As I said, that was my first thought.

I don't know about Google spreadsheets but if you go that route, it seems that MIME-Type is irrelevant.

Good luck.



I did look at Google docs

I haven't had a chance to look at your code - it's tax day here :(

However, when I suggested Google it never occurred to me that you would try to integrate the Google spreadsheet into your page at the script level. I assumed that you would either give them a direct link (or links) and/or use IFRAME (or equivalent).


from my web page, I want to read that spreadsheet (not edit it, just read it) then do something with the data I've captured out of each row/cell in the spreadsheet.

OK. Let me put on my one-trick-pony shoes.

This is [more or less] easily done with XMLHttpRequest, as follows:
1. GET the desired page(s)
2. extract the desired information
3. plug the information into your page

For me (a complete beginner when I started a month ago) the only really tricky part was step 3. I ran into three traps:
1. browser-dependent properties (such as innerText or textContent) [which can be avoided]
2. data-dependent logic (you can't assign text to an element that doesn't exist [so either include such elements in your page with placeholder values or use createTextNode]
3. if there is a way to format text displayed in html elements using \uxxxx or similar, I didn't find it [use createElement('br') and equivalent instead]

I wrote this page http://home.comcast.net/~djmacmil/
which does what you want to do. It's my first effort - so it may be less than elegant - but it works exactly as I hoped it would.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.