I am using the following code in asp to create an excel spreadsheet. Does anyone know how I would create a second worksheet in the file?
set fso = createobject("scripting.filesystemobject"
if fso.FileExists(server.mappath(g_fileName)) then
''response.write ("found"
else
Set objConn = Server.CreateObject( "ADODB.Connection" )
Set objCmd = Server.CreateObject( "ADODB.Command" )
Set objRS = Server.CreateObject( "ADODB.Recordset" )
objConn.Open Application("connectString"
Set objCmd.ActiveConnection = objConn
objCmd.CommandTimeout = 300
with objCmd
.commandText = "br_sp_threeDayReport"
.CommandType = &H0004
End With
set objrs = objcmd.execute()
recCount = 0
do while not objrs.eof
if lcase(objrs("created"
) <> "null" then
if lastName <> "" then
if lastName <> objrs("lastName"
then strOut = strOut & "<tr></tr>" '<
end if
recCount = recCount + 1
lastName = objrs("lastName"
end if
strOut = strOut & objrs(0)
objrs.movenext
loop
if recCount > 0 then ' <'records found'
Set act = fso.CreateTextFile(server.mappath(g_filename), true)
with act
.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com
ffice:excel"">"
.WriteLine "<head>"
.WriteLine "<!--[if gte mso 9]><xml>"
.WriteLine "<x:ExcelWorkbook>"
.WriteLine "<x:ExcelWorksheets>"
.WriteLine "<x:ExcelWorksheet>"
.WriteLine "<x:Name>Items Over 3 Days Old</x:Name>"
.WriteLine "<x:WorksheetOptions>"
.WriteLine "<x
ageSetup>"
.WriteLine "<x:Header>BRTT Active Requests Over 3 Days Old</x:Header>"
.WriteLine "</x
ageSetup>"
.WriteLine "<x
rint>"
.WriteLine "<x:ValidPrinterInfo/>"
.WriteLine "</x
rint>"
.WriteLine "</x:WorksheetOptions>"
.WriteLine "</x:ExcelWorksheet>"
.WriteLine "</x:ExcelWorksheets>"
.WriteLine "</x:ExcelWorkbook>"
.WriteLine "</xml>"
.WriteLine "<![endif]--> "
.WriteLine "</head>"
'The next line writes an HTML table which displays perfectly in excel
.WriteLine strOut
end with
act.close
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
set fso = createobject("scripting.filesystemobject"
if fso.FileExists(server.mappath(g_fileName)) then
''response.write ("found"
else
Set objConn = Server.CreateObject( "ADODB.Connection" )
Set objCmd = Server.CreateObject( "ADODB.Command" )
Set objRS = Server.CreateObject( "ADODB.Recordset" )
objConn.Open Application("connectString"
Set objCmd.ActiveConnection = objConn
objCmd.CommandTimeout = 300
with objCmd
.commandText = "br_sp_threeDayReport"
.CommandType = &H0004
End With
set objrs = objcmd.execute()
recCount = 0
do while not objrs.eof
if lcase(objrs("created"
if lastName <> "" then
if lastName <> objrs("lastName"
end if
recCount = recCount + 1
lastName = objrs("lastName"
end if
strOut = strOut & objrs(0)
objrs.movenext
loop
if recCount > 0 then ' <'records found'
Set act = fso.CreateTextFile(server.mappath(g_filename), true)
with act
.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com
.WriteLine "<head>"
.WriteLine "<!--[if gte mso 9]><xml>"
.WriteLine "<x:ExcelWorkbook>"
.WriteLine "<x:ExcelWorksheets>"
.WriteLine "<x:ExcelWorksheet>"
.WriteLine "<x:Name>Items Over 3 Days Old</x:Name>"
.WriteLine "<x:WorksheetOptions>"
.WriteLine "<x
.WriteLine "<x:Header>BRTT Active Requests Over 3 Days Old</x:Header>"
.WriteLine "</x
.WriteLine "<x
.WriteLine "<x:ValidPrinterInfo/>"
.WriteLine "</x
.WriteLine "</x:WorksheetOptions>"
.WriteLine "</x:ExcelWorksheet>"
.WriteLine "</x:ExcelWorksheets>"
.WriteLine "</x:ExcelWorkbook>"
.WriteLine "</xml>"
.WriteLine "<![endif]--> "
.WriteLine "</head>"
'The next line writes an HTML table which displays perfectly in excel
.WriteLine strOut
end with
act.close
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook