?
Solved

How to detect an empty cells in Excel file using getRows method?

Posted on 2003-03-27
4
Medium Priority
?
307 Views
Last Modified: 2013-12-25
Hi. I have an annoying trouble trying to detect an empty cells in Excel file using getRows() method.
Here's the working code. It just reads an Excel file and then writes data directly to html page.
I just want to detect empty cell by value and write "EMPTY CELL" phrase instead of writing empty space.
But cell comparison to empty string ("") does not work -- :(

Can you help me to detect empty cells?

CODE: Please look for "HERE'S MY TROUBLE" string to see my trouble's area:

<%
     Set oConn = Server.CreateObject("ADODB.Connection")
     strConn = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=D:\Projects\goodsdata-6.xls;"
     oConn.Open strConn

     strCmd = "SELECT * from GoodsData" ' GoodsData is named set of cells in Excel worksheet
     Set oRS = Server.CreateObject("ADODB.Recordset")
     oRS.Open strCmd, oConn

     Dim cell
     cell = oRS.GetRows ()

     Response.Write ("<table bgcolor='#778899' border='1' cellpadding='4' cellspacing='0'><tr><td>")

     For rowNum = 0 To oRS.Fields.Count
          For colNum = 0 To 10
'HERE'S MY TROUBLE:
               If cell ( colNum, rowNum ) = "" Then
                    Response.write "EMPTY CELL </td><td>"              
               Else
                    Response.write cell( colNum, rowNum ) & "</td><td>"
               End If              
          Next
          Response.write ("</td></tr><tr><td>")
     Next

     Response.Write ("</td></tr></table><p>")
%>

Maybe, I go wrong way? Thanks in advance..
0
Comment
Question by:Rostichka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 27

Accepted Solution

by:
Dabas earned 100 total points
ID: 8220268
See if any of Excel's IS functions helps you.
I thought there was an IsEmpty somewhere but cannot find it in my Object Browser. But there are several other IS functions such as IsText and IsNumber. Maybe a combination of those two might help you out.

Dabas
0
 
LVL 3

Assisted Solution

by:WRNewman
WRNewman earned 100 total points
ID: 8220466
if cell(x,y).value > chr(0) then

Detects if there is a value in the cell
If there is nothing then it will be ASCII 0 ie  Null

This has worked for me more times than I can remember
0
 
LVL 4

Assisted Solution

by:P1
P1 earned 100 total points
ID: 8221249
First off, you have data in Recordset Format from an Excel spreadsheet and not Excel cell's data.

i.e.
Select Case rs.Fields.Item(j).Type
  Case adSmallInt         '2  
       If rs.Fields.Item(j).Value = 0 Then  
             
'You can aggregate simular types to make this easier.
'You two basic types, numbers and strings. BTW Dates are numbers.
'Just depends on the datatypes being imported.

Regards,  P1
0
 
LVL 1

Expert Comment

by:ayufans
ID: 9272371
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points split between Dabas, WRNewman and P1

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

ayufans
Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question