Programalama > ASP


Ort. 0
Puan ver:
<%@ Language=VBScript %>
<%
'sql: kısmına çift tırnak içinde direk sql stringi yaz
'cnnl: database bağlantısı
Function exporttoexcel(FileName,sql,cnnl)
dim iCols
dim i
set rs=server.CreateObject("ADODB.Recordset")
set rs=cnnl.Execute (sql)
iCols = rs.Fields.Count	
session("FileName")=cstr(FileName) 
set fso = createobject("scripting.filesystemobject")
Set folder = fso.GetFolder("c:\Inetpub\wwwroot\tekintranet\dokuman\excel")
Set act = folder.CreateTextFile(""&FileName& "" &".xls", true)
act.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
act.WriteLine "<head>"
act.WriteLine "<!--[if gte mso 9]><xml>"
act.WriteLine "<x:ExcelWorkbook>"
act.WriteLine "<x:ExcelWorksheets>"
act.WriteLine "<x:ExcelWorksheet>"
act.WriteLine "<x:Name>"& "Sheet1" &"</x:Name>"
act.WriteLine "<x:WorksheetOptions>"
act.WriteLine "<x:Print>"
act.WriteLine "<x:ValidPrinterInfo/>"
act.WriteLine "</x:Print>"
act.WriteLine "</x:WorksheetOptions>"
act.WriteLine "</x:ExcelWorksheet>"
act.WriteLine "</x:ExcelWorksheets>"
act.WriteLine "</x:ExcelWorkbook>"
act.WriteLine "</xml>"
act.WriteLine "<![endif]--> "
act.WriteLine "</head>"
act.WriteLine "<body>"
act.WriteLine "<table>"
act.WriteLine "<tr>"
	For i = 0 To iCols - 1
		act.WriteLine "<th>"
		act.WriteLine "<font face=Arial>"&cstr(rs.Fields.Item(i).Name&"</font>") 
		act.WriteLine "</th>"
	next
    act.WriteLine "</tr>"
	rs.MoveFirst 
	i=0
	do until rs.EOF 
	act.WriteLine "<tr>"
		For i = 0 To iCols - 1
		act.WriteLine "<td>"
		if rs.Fields.Item(i)<>"" then
		act.WriteLine "<font face=Arial>"&cstr(rs.Fields.Item(i))&"</font>"
		end if 
		act.WriteLine "</td>"
		next
	act.WriteLine "</tr>"
    rs.MoveNext 
    loop	
act.WriteLine "</table>"
act.WriteLine "</body>"
act.WriteLine "</html>"
' close the document 
act.close
rs.Close 
end function
%>


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2019 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.