| |
scaifs01
Posts: 10
Score: 0
Joined: 9/19/2001
From: United Kingdom
Status: offline
|
Ok I don't know if anyone can help me, but I can connect to and read from a sheet in my excel document. Though in the actual spreadsheet there is formatting such as colours in the background. : When my ASP page constructs itself it doesn't bring any of this formatting through, does any body know how to pull the formatting through, I could save as HTML in excel but that defeats the purpose of what I am trying to do. I'll paste my code below : thanks in advance for any help offered : <% : Const adOpenStatic = 3 : Const adLockPessimistic = 2 : Dim cnnExcel : Dim rstExcel : Dim I : Dim iCols : Set cnnExcel = Server.CreateObject("ADODB.Connection") : cnnExcel.Open "DBQ=" & Server.MapPath("xl_data.xls") & ";" & _ : "DRIVER={Microsoft Excel Driver (*.xls)};" : Set rstExcel = Server.CreateObject("ADODB.Recordset") : rstExcel.Open "SELECT * FROM TestData;", cnnExcel, _ : adOpenStatic, adLockPessimistic : iCols = rstExcel.Fields.Count : %> : <table border="1"> : <thead> : <% : For I = 0 To iCols - 1 : Response.Write "<th>" : Response.Write rstExcel.Fields.Item(I).Name : Response.Write "</th>" & vbCrLf : Next 'I : %> : </thead> : <% : rstExcel.MoveFirst : Do While Not rstExcel.EOF : Response.Write "<tr>" & vbCrLf : For I = 0 To iCols - 1 : Response.Write "<td>" : if isnull(rstExcel.Fields.Item(I).Value) then : response.write " </td>" & vbcrlf : else : Response.Write rstExcel.Fields.Item(I).Value : Response.Write "</td>" & vbCrLf : end if : Next 'I : Response.Write "</tr>" & vbCrLf : rstExcel.MoveNext : Loop : %> : </table> : <% : rstExcel.Close : Set rstExcel = Nothing : cnnExcel.Close : Set cnnExcel = Nothing : %>
|
|