Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem displaying Excel data

Status
Not open for further replies.

emblewembl

Programmer
May 16, 2002
171
0
0
GB
Hi all, I am working on a site that is mainly built from ASP pages which read data from an Excel file. All has been going smoothly until the last page and we get a strange error. There are 3 fields which will not display at all although the page loads ok.


Connectiong to spreadsheet like so:
Code:
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'The Excel File Name
XLFile = "C:\Inetpub\[URL unfurl="true"]wwwroot\scgu\"&[/URL] strFileToLoad &""
		
If objFSO.FileExists(XLFile) Then

  FileFound = true
			
  ' create and open the objConnection to the database 
  Set objConn = Server.CreateObject("ADODB.Connection") 
  objConn.Open "DRIVER=Microsoft Excel Driver (*.xls);" _ 
			& "DBQ=" &   XLFile 

  Set objRs = objConn.Execute("Select * From  [wwwStart$]")     

Else
  FileFound = false
End If

Set objFSO=nothing

DIsplaying data like so:
Code:
If FileFound = true Then

  Do While not objRs.EOF

    Response.Write(&quot;<tr>&quot;) & vbCrLf
    Response.Write(&quot;<td bgcolor=&quot;&quot;#cccccc&quot;&quot; width=&quot;&quot;10%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;><b>&quot; & strMatchNum &&quot;</b></td>&quot;)
    Response.Write(&quot;<td width=&quot;&quot;20%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;>&quot; & strStartTime & &quot;</td>&quot;)
    Response.Write(&quot;<td width=&quot;&quot;20%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;>&quot; & strEndTime & &quot;</td>&quot;)
    Response.Write(&quot;<td width=&quot;&quot;20%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;>&quot; & objRs(&quot;Heading4&quot;) & &quot;</td>&quot;)
    Response.Write(&quot;<td width=&quot;&quot;20%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;>&quot; & objRs(&quot;Heading5&quot;) & &quot;</td>&quot;)
    Response.Write(&quot;<td width=&quot;&quot;10%&quot;&quot; valign=&quot;&quot;top&quot;&quot; class=&quot;&quot;&quot;& strClass &&quot;&quot;&quot;>&quot; & objRs(&quot;Heading6&quot;) & &quot;</td>&quot;)
    Response.Write(&quot;</tr>&quot;) & vbCrLf

    objRs.Movenext
    Loop
  End If

There are four rows, and the cells that don't display (or the system sees as empty) are first row, cells 1, 2 and 5.

Help!!! i love chocolate
 
The fact it displays some data means that your connection to the excel source is fine.
If I understand correctly, cells 1,2 and 5 contain strMatchNum, strStartTime and objRS(&quot;Heading5&quot;)... right?

From the code you supplied, we can't see what could be going wrong.

Where and how do you define the variables strMatchNum and strStartTime?
Does 'Heading5' contain any data in the excel sheet itself?

greetings
 
Hi Tomas,

Ok after the 'do while not'line and before the 'Response.Write(&quot;<tr....', I do this :
Code:
strMatchNum = objRs(&quot;Heading1&quot;)

 If strMatchNum = &quot;0&quot; Then
          strMatchNum = &quot;&quot;
  End If

  strStartTime = objRs(&quot;Heading2&quot;)

  If strStartTime = &quot;12:00:00 AM&quot; Then
    strStartTime = &quot;&quot;
  End If

  strEndTime = objRs(&quot;Heading3&quot;)

  If strEndTime = &quot;12:00:00 AM&quot; Then
    strEndTime = &quot;&quot;
  End If

  If i mod 2 = 0 Then
    strClass = &quot;redtextsm&quot;
  Else
    strClass = &quot;blacktextsm&quot;
  End If

I have put the page online so you can see the fields that aren't showing:


Hope that makes it clearer! i love chocolate
 
Ok it looks to me the missing fields from your excel sheet are either blank in the excel sheet or match the condition (for example when strMatchNum is &quot;0&quot; then it should display nothing)
can you send the excel sheet?

greetings
Tomas
 
Hi Tomas, the fields aren't blank - I built the page myself and yes I can send the file over to you but I'll need your email address!! Can you post it and I'll send it over.

Thanks! i love chocolate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top