Link to home
Start Free TrialLog in
Avatar of Rostichka
Rostichka

asked on

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

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..
ASKER CERTIFIED SOLUTION
Avatar of Dabas
Dabas
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ayufans
ayufans

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