Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


getting excel cell formats with ASP

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,535
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> getting excel cell formats with ASP
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 getting excel cell formats with ASP - 12/17/2001 4:16:28 AM   
  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
: %>
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> getting excel cell formats with ASP Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts