Jump to content

Recommended Posts

Posted (edited)

Hi all!

 

Unfortunatley I am not an egghead. I am more a drop head but I am hoping someone can help me.

 

I am wanting away to allow people to fill in a simple excel form via the internet. The closes I hav come is Bad blue however their design is quite poor and very limitted. As this is a like a one of sheet but will be used quite often I am hoping to find a solution to this problem thru maybe some jave scripting or something.

Edited by qerra22
  • 10 months later...
  • 4 months later...
Guest go2prashant
Posted

Javascript cannot read or write files. You'll need to use server-side code for that.

 

You are wrong . It is possible to read/write data(anywhere to excel also) using Java Script. Below is thas ample code for this.

<html>

<script>

function mytest1() {

var Excel, Book; // Declare the variables

Excel = new ActiveXObject("Excel.Application"); // Create the Excel application object.

Excel.Visible = false; // Make Excel invisible.

Book = Excel.Workbooks.Add() // Create a new work book.

Book.ActiveSheet.Cells(1,1).Value = document.all.my_textarea1.value;

Book.SaveAs("C:/TEST.xls");

Excel.Quit(); // Close Excel with the Quit method on the Application object.

}

 

function mytest2() {

var Excel;

Excel = new ActiveXObject("Excel.Application");

Excel.Visible = false;

form1.my_textarea2.value = Excel.Workbooks.Open("C:/TEST.xls").ActiveSheet.Cells(1,1).Value;

Excel.Quit();

}

 

</script>

 

<body>

<form name="form1">

<input type=button onClick="mytest1();" value="Send Excel Data"><input type=text name="my_textarea1" size=70 value="enter ur data here">

<br><br>

<input type=button onClick="mytest2();" value="Get Excel Data"><input type=text name="my_textarea2" size=70 value="no data collected yet">

 

</form>

</body>

</html>

 

Thanks

Prashant

Posted

Just thought I would point out... I believe the above code would only work if the user is running Internet Explorer with activex enabled -- those visitors who can't run IE (different operating system: OSX, Linux) or prefer not to run IE (Firefox, Safari, Opera...) won't have access to this functionality and it won't work for them.

 

Frankly, I'm glad javascript can't read or write files -- it eliminates a potential security risk.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...