Skip to content

Instantly share code, notes, and snippets.

@patcullen
Created May 27, 2014 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patcullen/f2ec6470d05708cbc53e to your computer and use it in GitHub Desktop.
Save patcullen/f2ec6470d05708cbc53e to your computer and use it in GitHub Desktop.
An example of connecting to an Excel file in ASP (using JScript)
<%@ Language=JScript %>
<!--#include file="excel.asp" --><%/* https://gist.githubusercontent.com/patcullen/096a79ca8000b367537e/raw/7a806439bdf388335f2403ba89d8f51f039fb6a8/excel.asp */%>
<!--#include file="json.asp" --><%/* https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js */%>
<%
excelFile = "c:/temp/unlocodes.xlsx"
sql = "SELECT [ISO 3166-1], [Country Name] FROM [Sheet1$]"
excel.open(excelFile).query(sql, {}, function(codes) {
Response.write(
JSON.stringify(codes.asArray())
);
excel.close();
});
%>
@billymigz22
Copy link

billymigz22 commented Sep 30, 2019

why is it json.asp when the file is json2.js
it's confusing.

@patcullen
Copy link
Author

In classic ASP only dot-asp files can be included as scripts. So After downloading json2.js, rename it to a dot-asp extension. The contents shouldn't need to be changed. Perhaps adding an ASP-script opening and closing braces. Haven't touched ASP in a few years myself, so can't quite remember. Good luck.

@billymigz22
Copy link

Thank you for replying, it still did not work I've just followed your algorithm and all is good. thanks again.

@sowmyanarayangowda
Copy link

i am getting error '80004005' , can you please help
Thank you

@patcullen
Copy link
Author

I Google'd that and the first few results related to filesystem or OS permissions related to the source of data. I'd suggest you Google it yourself and work through the first page of results. That's usually what I do. I haven't touched the ASP environment in almost 6 years, so can't give much better advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment