472,983 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

can we send data from html to excel sheet using java script

hi,
can we send data from html to excel sheet using java script
sandeep
Jul 6 '07 #1
4 8707
r035198x
13,262 8TB
hi,
can we send data from html to excel sheet using java script
sandeep
Moved to Javascript forum.
P.S Welcome to TSDN.
Jul 6 '07 #2
acoder
16,027 Expert Mod 8TB
hi,
can we send data from html to excel sheet using java script
sandeep
Not with standard javascript as far as I'm aware.

You could use AJAX to simulate client-side interactions or it could even be as simple as right-click and "Send to Excel" or something to that effect (without the need for any scripting).
Jul 6 '07 #3
Yes we can do whatever you are saying:

I am listing an example function where I am copying the html data in a div to the excel sheet. It is following copy-paste technique. But you can select and carry the data in a javascript variable and then save it cell-wise. Google out the rest yourself. You have got the clue.

Expand|Select|Wrap|Line Numbers
  1.  function fnSelect(objId)
  2. {
  3.    fnDeSelect();
  4.    if (document.selection) 
  5.    {
  6.       var range = document.body.createTextRange();
  7.       range.moveToElementText(document.getElementById(objId));
  8.       range.select();
  9.       range.execCommand("Copy");
  10.    }
  11.    else if (window.getSelection) 
  12.    {
  13.       var range = document.createRange();
  14.       range.selectNode(document.getElementById(objId));
  15.       window.getSelection().addRange(range);
  16.       range.execCommand("Copy");
  17.    }
  18. var eWApp = new ActiveXObject("Excel.Application")
  19. eWApp.Visible = true
  20. eWApp.Workbooks.Add()
  21. xlSheet = eWApp.ActiveSheet;
  22. xlSheet.Paste();
  23. fnDeSelect();
  24. }
  25.  
  26. function fnDeSelect() 
  27. {
  28.    if (document.selection)
  29.              document.selection.empty();
  30.    else if (window.getSelection)
  31.               window.getSelection().removeAllRanges();
  32. }
Jul 11 '07 #4
acoder
16,027 Expert Mod 8TB
Yes we can do whatever you are saying:

I am listing an example function where I am copying the html data in a div to the excel sheet. It is following copy-paste technique. But you can select and carry the data in a javascript variable and then save it cell-wise. Google out the rest yourself. You have got the clue.

Expand|Select|Wrap|Line Numbers
  1.  function fnSelect(objId)
  2. {
  3.    fnDeSelect();
  4.    if (document.selection) 
  5.    {
  6.       var range = document.body.createTextRange();
  7.       range.moveToElementText(document.getElementById(objId));
  8.       range.select();
  9.       range.execCommand("Copy");
  10.    }
  11.    else if (window.getSelection) 
  12.    {
  13.       var range = document.createRange();
  14.       range.selectNode(document.getElementById(objId));
  15.       window.getSelection().addRange(range);
  16.       range.execCommand("Copy");
  17.    }
  18. var eWApp = new ActiveXObject("Excel.Application")
  19. eWApp.Visible = true
  20. eWApp.Workbooks.Add()
  21. xlSheet = eWApp.ActiveSheet;
  22. xlSheet.Paste();
  23. fnDeSelect();
  24. }
  25.  
  26. function fnDeSelect() 
  27. {
  28.    if (document.selection)
  29.              document.selection.empty();
  30.    else if (window.getSelection)
  31.               window.getSelection().removeAllRanges();
  32. }
Welcome to TSDN!

Thanks for sharing your code.

Just to mention though, this is JScript, not Javascript. It uses ActiveX. It would work in IE, but not in any other browser.
Jul 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jean-Marie Delapierre | last post by:
Hi, I have two files in a directory. one called toto.txt with the following content : 1 2 3 4 5
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
11
by: Hi5 | last post by:
Hi, I am new to access I usedto work in Oracle and Mysql. I am after a way that enables me to populate a database I designed in access with lots of data which can be sorted in excel sheets, ...
13
by: UnaCoder | last post by:
Hi, I'm trying to use client side JavaScript from an HTML file to open and make changes to an Excel SpreadSheet using ADO w/ ODBC. What a pain it is to do this. Anyways, I am able to open the...
7
by: Vanessa | last post by:
hi Everyone, I have two questions on exporting data to Excel using ASP (w/o converting formatted excel file into web page and then plug in the dynamic data): 1. Can we export data into...
5
by: Rishika14 | last post by:
Hi, Somebody pls tell me how to export data from webpage to excel sheet using java script. rishika
1
by: ashok0866 | last post by:
I had created a macro to read data from an excel sheet and write the values to a text file. I had used "ActiveSheet.Range("GB" & k).Value" command to read the values from the excel. The issue...
3
by: balazee | last post by:
Hi, I’ve some data in an excel sheet which needs to be displayed in an html page as lists. For example, In the excel I’ve the below details like, the application name and the path where the...
5
by: tsanthoshk | last post by:
Hi All I am trying to read and modify input excel file. when i update the data in excel sheet already existing format is washing out. It mean if excel sheet contain colors those are not appearing...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.