473,686 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Tables Like Excel

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();
  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. }
  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. }
  40. </script>
May 14 '07 #1
2 7194
1 New Member
Thank you. It is very interesting script.
May 23 '07 #2
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

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.
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;...
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
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.
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
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
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...
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...
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...
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...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
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...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.