Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Excel Cell Into HTML Page 1

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hi HTML experts,

My company has production goals. For example the goal for 2004 is to produce 2,400,000 units.

Let's say this figure is in an Excel worksheet and is changed by the user as the actual goal changes throughout the year.

Is it possible to import the value (in this case 2,400,000) of a certain cell in a specified worksheet into my intranet page ?

Can it be done with just HTML ? (I know a little ASP and some JavaScript,VBScript but not an expert)

Thanks for any ideas. John

 
John,

It cannot be done purely with HTML alone.

You could use server-side code, and it sounds like you could also use client-side JavaScript to do the job, but in IE only.

Dan
 
Thanks Dan,

IE is the company standard for browsers so that's OK.
John
 
John,

This code should do the job:

Code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

	var myExcelApp = new ActiveXObject(&quot;Excel.Application&quot;);
	myExcelApp.Workbooks.Open('C:\\testfile2.xls');

	var mySheet = myExcelApp.Workbooks(1).Sheets(1);
	var myValue = mySheet.Cells(10, 4).value;
	myExcelApp.Quit();

//-->
</SCRIPT>
</HEAD>
<BODY>
	The value in cell D10 is <SCRIPT>document.write(myValue);</SCRIPT>
</BODY>
</HTML>

You'll need to replace 'C:\\testfile2.xls' with the correct path and filename of your Excel file.

I'm assuming the value is in cell D10 (10, 4), but you cna change this as necessary.

Hope this helps!

Dan
 
Thanks Dan ! This worked perfectly. It was easy to implement, which I like.

In IE 6, the user gets a warning &quot;An ActiveX control on this page may be unsafe... Do you want to allow this interaction?&quot; at the code that opens Excel. If they click YES, the javascript code retrieves the values. A NO click prompts to run Debug.

I dont know how big of a concern this message box will be in the workplace - I looked for a browser security option/setting related to running ActiveX controls but dont see any.

Do you have any advice on this?
Thanks for your tip. John



 
Look under:

Tools -> Internet Options -> Security -> Custom Level

Then you can change the ActiveX prompting levels there.

Hope this helps!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top