473,606 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Tables Like Excel

iam_clint
1,208 Recognized Expert Top Contributor
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 7189
java1cprog
1 New Member
Thank you. It is very interesting script.
May 23 '07 #2
vee10
141 New Member
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
14765
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 a single table to Excel but have problems with multimple tables. Thanks.
1
4673
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 written the driver prg in c#. The code opens the file, but it is not writting the values from text file into excel file. I can not figure out the problem here. This is my code: StreamReader dataFileReader = null; FileInfo file = null;...
4
2609
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 looks has the following columns: Data Description / Source / 1990 / 1991 / 1992 / etc. It's set up as a pivot-table (at least I think so... not too familiar with Excel Pivot Tables), based on the first two columns. Anyway, when I run the
5
8932
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 headers). I used ODBC in my VB.NET program to read that spreadsheet into a dataset, to make it easy to manipulate. The code I use to read it is as the bottom of this posting.
3
8482
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 on this. It is very urgent. Please reply immediately Thanks for the help!!!! nikila
9
22485
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 namespaces and classes should I use and how? -- dba123
1
9768
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 having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping to export two Tables (or queries...not sure which to use - they both seem to have the same data) in...
2
5609
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 text load into the grid fine, but the columns that contain just numbers don't show up at all. I tried converting the text of the cells to an integer first, but I get an error for converting from a type DBNull. Anybody who has any help at all, I...
1
2178
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. There are records in this Excel file with matches in the DAT file.Whereever the records are marked "deleted" in the excel file,I have to find the similar records on the DAT file and delete those records.The records marked "add" in the excel file...
1
10399
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 data by using ASP.NET, ADO.NET, and Visual C# .NET I am trying with the same code in Visual Studio 2005 in ASP.NET application. The code i am using is: protected void Page_Load(object sender, EventArgs e) { String connectionString...
0
7978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8126
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8317
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5987
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.