473,382 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,382 developers and data experts.

Reading Tables Like Excel

iam_clint
1,208 Expert 1GB
Heres some code I wrote that may become useful to someone, I have seen many people wanting this type of code so here is my example.
Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="showval"><input type="text" id="search" value="A:1"><input type="button" value="Show Value" onclick="ReadCell(document.getElementById('search').value, 'ExcelView')"><br><br>
  2. <table border=1 id="ExcelView" name="ExcelView">
  3. <tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td><td>Cell 4</td></tr>
  4. <tr><td>Cell 5</td><td>Cell 6</td><td>Cell 7</td><td>Cell 8</td></tr>
  5. <tr><td>Cell 9</td><td>Cell 10</td><td>Cell 11</td><td>Cell 12</td></tr>
  6. </table>
  7. <script language="javascript">
  8. function ReadCell(val, tbl) {
  9.  val = val.toUpperCase();
  10.  var alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  11.  var table = document.getElementById(tbl);
  12.  var sVal = val.split(":");
  13.  var col = sVal[0];
  14.  if (isnumeric(col)) { alphaconv = col } else { var alphaconv = alphabet.indexOf(col); }
  15.  var row = sVal[1]-1;
  16.  var gval = "";
  17.  if (sVal.length==2 && isnumeric(alphaconv) && isnumeric(row)) { 
  18.   var rows = table.getElementsByTagName("TR");
  19.   if (row>=rows.length) { return false; } else { var cols = rows[row].getElementsByTagName("TD"); }
  20.   if (alphaconv>cols.length) { return false; } else { var gval = cols[alphaconv].innerHTML; }
  21.   if (gval!="") { document.getElementById("showval").value = gval; }
  22.  }
  23. }
  24.  
  25. function isnumeric(sText) {
  26.    var ValidChars = "0123456789";
  27.    var IsNumber=true;
  28.    var Char;
  29.    for (i = 0; i < sText.length && IsNumber == true; i++) 
  30.       { 
  31.       Char = sText.charAt(i); 
  32.       if (ValidChars.indexOf(Char) == -1) 
  33.          {
  34.          IsNumber = false;
  35.          }
  36.       }
  37.    return IsNumber;
  38. }
  39.  
  40. </script>
  41.  
May 14 '07 #1
2 7173
Thank you. It is very interesting script.
May 23 '07 #2
vee10
141 100+
Thanks . it really helped me .
Jul 31 '07 #3

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

Similar topics

4
by: Paolo | last post by:
Friends, I need help with some code to export different tables to a single spreadsheet in Excel. My excel file is named REPORT and the spreadsheet is named CLIENTS. I do have the code to export...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
4
by: Michael C# | last post by:
Hi all, I have a little program that uses OleDb to open and read an Excel spreadsheet from VB.NET. The problem I'm running into is it's not reading the column headers... The Excel worksheet...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
3
by: nikila | last post by:
Hi, I have to create excel pivot tables from vb.net. Already I am creating excel file using oledb connection. I want to use the same to create the excel pivot tables. Can anyone please help me...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
2
by: rwiegel | last post by:
I'm trying to read rows from an Excel file and display them in an ASP.NET DataGridview. I am using C# for the code file. I am using OleDb to read from the Excel file. The columns that contain...
1
by: Roy | last post by:
Hi all, Thanks for your replies.I have to develop an application which will read a .DAT file.There are several hundred records in this file.Also I get another excel file with adds and deletes....
1
by: =?Utf-8?B?U2hlZXMgQWJpZGk=?= | last post by:
I read an article on the link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306572 related to reading data from Excel using OLEDB The topic's heading is: How to query and display excel...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.