That's the most awkward combination because as far as I know even the latest version cannot open a file by URL, you would need to copy the file to the client first then manipulate it.
First a function to copy files from server to client:
Code:
function saveRemoteFile(From, To)
{
var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0"); //Change to version 3 if necessary
oXmlHttp.open("GET", From, false);
oXmlHttp.send();
if (oXmlHttp.status == 200)
{
var oStream = new ActiveXObject("Adodb.Stream");
oStream.type = 1; //Binary
oStream.open();
oStream.write(oXmlHttp.responseBody);
oStream.saveToFile(To, 1 && 2); //Create if needed and overwrite if necessary
oStream.close();
}
else
{
throw new Error(oXmlHttp.statusText); //Needs improving
}
}
Now when web page needs Excel file you need to call
Code:
saveRemoteFile("http://myserver/myfolder/myfile.xls", "C:\\myfile.xls");
.
Now to work with file, let's display the value in cell A1 on first sheet in a div with the id of divOutput.
Code:
var oExcel = new ActiveXObject("Excel.Application");
var oWB = oExcel.workbooks.open("C:\\myfile.xls");
//oExcel.visible = true;
var oWS = oWB.worksheets(1);
document.getElementById("divOutput").innerText = oWS.Range("A1").value;
oExcel.quit();
--
Joe