473,411 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 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 8747
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.