|
<%
'---------------------------------------------------------------------------
'
' Project: UTE - (U)niversal ASP (T)able (E)ditor
'
' Module: UTE class - Export Functions
'
' Version: 2.0
'
' Comments: This module does the following things:
' 1. defines all functions being needed in
' export mode
'
'---------------------------------------------------------------------------
'
' (c) in 2000-2002 by Tom Wellige
' http://www.wellige.com mailto:tom@wellige.com
'
' This project is released under the "GNU General Public License (GPL)"
' http://www.gnu.org/licenses/gpl.html
'
' and is maintained on SourceForge at
' http://sourceforge.net/projects/ute-asp/
'
' and can also be found on CodeProject at
' http://www.codeproject.com/asp/ute.asp
'
'---------------------------------------------------------------------------
''--------------------------------------------------------------------------
'' Name: DigitStr
'' ========
''
'' Returns given number as string. String will be filled with leading
'' "0" if it's length is less then the given number of Digits
''
'' Parameter:
'' nNumber Number to be returned
'' nDigits Number of digits
''
'' return value:
'' string
''
''--------------------------------------------------------------------------
Private Function DigitStr ( nNumber, nDigits )
Dim sReturn
sReturn = CStr(nNumber)
while Len(sReturn) < nDigits
sReturn = "0" & sReturn
wend
DigitStr = sReturn
End Function
''--------------------------------------------------------------------------
'' Name: GetDateTimeString
'' =================
''
'' Returns string containg date and time: YYYY-MM-DD-HH-mm-SS
''
'' Parameter:
'' vDate Date to be returned as string
''
'' return value:
'' string
''
''--------------------------------------------------------------------------
Private Function GetDateTimeString ( vDate )
Dim sReturn
sReturn = DigitStr(Year(vDate), 4) & "-" & DigitStr(Month(vDate), 2) & "-" & DigitStr(Day(vDate), 2) & "-" & _
DigitStr(Hour(vDate), 2) & "-" & DigitStr(Minute(vDate), 2) & "-" & DigitStr(Second(vDate), 2)
GetDateTimeString = sReturn
End Function
''--------------------------------------------------------------------------
'' Name: ExportToFile
'' ============
''
'' Writes all data in current recordset to a comma separated text file.
''
'' Parameter:
'' none
''
'' return value:
'' none
''
''--------------------------------------------------------------------------
Private Sub ExportToFile ()
Dim i
Dim sLine
Dim sFileName
Dim sFilePath
Dim fso
Dim file
' set RecordSet to get all data
m_RS.PageSize = m_RS.RecordCount
m_RS.AbsolutePage = 1
m_RS.MoveFirst
' calculate Filename
sFileName = m_sExportFile
sFileName = Replace(sFileName, "%d", GetDateTimeString(now))
sFileName = Replace(sFileName, "%t", m_sTable)
sFileName = Replace(sFileName, "%s", CStr(Session.SessionID))
sFileName = m_sEXPORTDir & sFileName
sFilePath = Server.MapPath(sFileName)
' get FileSystem Object
Set fso = Server.CreateObject("Scripting.FileSystemObject")
' create File
Set file = fso.OpenTextFile(sFilePath, fsoForWriting, fsoCreateIfNotExist)
' write Header
sLine = ""
for i = 1 to UBound(m_PrimaryKeyFields)
sLine = sLine & DEF_EXPORT_VAL & m_PrimaryKeyFields(i) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
next
for i = 1 to UBound(m_StandardFields)
sLine = sLine & DEF_EXPORT_VAL & m_StandardFields(i) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
next
if sLine <> "" then
sLine = Left(sLine, Len(sLine)-1)
file.WriteLine(sLine)
end if
Do Until m_RS.EOF
sLine = ""
for i = 1 to UBound(m_PrimaryKeyFields)
sLine = sLine & DEF_EXPORT_VAL & m_RS(m_PrimaryKeyFields(i)) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
next
for i = 1 to UBound(m_StandardFields)
sLine = sLine & DEF_EXPORT_VAL & m_RS(m_StandardFields(i)) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
next
if sLine <> "" then
sLine = Left(sLine, Len(sLine)-1)
file.WriteLine(sLine)
end if
m_RS.MoveNext
Loop
' close File
file.Close
Set file = Nothing
Set fso = Nothing
' send File to User
Response.Redirect(sFileName)
End Sub
%>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Tom is in software development for about 15 years. He started with a SHARP MZ80k in Basic and Assembly Language. After collecting some experiance on an ATARI 1040ST he bought his very first IBM XT 286 (incl. 287!) and started to program in
Turbo Pascal. He became very familiar with
Borland's Turbo Vision and over the last years did a lot of development in C++ (MFC), Visual Basic, VB Script, ASP and SQL. He currently works as senior consultant for
Swyx Solutions GmbH, based in Dortmund, Germany.
His absolute favourite is
Guinness Sláinte!