Steynsk
asked on
How do I change the output file from xls to CSV?
Hi Experts,
We've got this well working script (see below) that produces an XLS file. But our results exeed the limitations of the XLS format. That's wy I'm trying to write my output to CSV.
Can this be done by changing our current code or do I need complete other methode to make this work? And what sould be changed to get this working?
All help welcome
-----current code-----------------
<!--#INCLUDE FILE="connect.asp"-->
<%
Server.ScriptTimeout = 600
Response.Buffer=true
'Declare some variables
dim RS, pid
Set RS = Server.CreateObject("ADODB .Recordset ")
pid = Request.QueryString("pid")
sql = "SELECT * FROM mytable WHERE id= " & pid & " order by datum"
RS.Open sql, CS
'This is the the code which tells the page to open Excel and give it the data to display
Response.ContentType = "application/vnd.ms-excel"
'You can give the spreadsheet a name at the point its produced
Response.AddHeader "Content-Disposition", "attachment; filename="& pid&".xls"
loopCounter = 0
%>
<!--
Note that I have formatted the output header here to a dark blue background and white text
this will be reflected in the spreadsheet when its produced and you could extend this to your own tastes of course.
-->
<table border="1" width="100%">
<tr>
<th bgcolor="#FFFFFF"><font size="2">patientnummer</fo nt></th>
<th bgcolor="#FFFFFF"><font size="2">datum/tijd</font> </th>
<th bgcolor="#FFFFFF"><font size="2">bed</font></th>
<th bgcolor="#FFFFFF"><font size="2">HF</font></th>
<th bgcolor="#FFFFFF"><font size="2">RESP</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2r</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2l</font></th>
<th bgcolor="#FFFFFF"><font size="2">tcpCO2</font></th >
<th bgcolor="#FFFFFF"><font size="2">tcpO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">etCO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDs</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDm</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDd</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPs</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPm</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPd</font></th>
<th bgcolor="#FFFFFF"><font size="2">rSO2_1</font></th >
<th bgcolor="#FFFFFF"><font size="2">rSO2_2</font></th >
<th bgcolor="#FFFFFF"><font size="2">rSO2_3</font></th >
<th bgcolor="#FFFFFF"><font size="2">rSO2_4</font></th >
<th bgcolor="#FFFFFF"><font size="2">Pols</font></th>
<th bgcolor="#FFFFFF"><font size="2">dSPO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">awRF</font></th>
</tr>
<%Do While Not RS.eof%>
<tr>
<td><font size="2"><%= RS("PID") %></font></td>
<td><font size="2"><%= RS("datum") %></font></td>
<td><font size="2"><%= RS("bed") %></font></td>
<td><font size="2"><%= RS("HF") %></font></td>
<td><font size="2"><%= RS("RESP") %></font></td>
<td><font size="2"><%= RS("SpO2") %></font></td>
<td><font size="2"><%= RS("SpO2r") %></font></td>
<td><font size="2"><%= RS("SpO2l") %></font></td>
<td><font size="2"><%= RS("tcpCO2") %></font></td>
<td><font size="2"><%= RS("tcpO2") %></font></td>
<td><font size="2"><%= RS("etCO2") %></font></td>
<td><font size="2"><%= RS("NIBDs") %></font></td>
<td><font size="2"><%= RS("NIBDm") %></font></td>
<td><font size="2"><%= RS("NIBDd") %></font></td>
<td><font size="2"><%= RS("ABPs") %></font></td>
<td><font size="2"><%= RS("ABPm") %></font></td>
<td><font size="2"><%= RS("ABPd") %></font></td>
<td><font size="2"><%= RS("rSO2_1") %></font></td>
<td><font size="2"><%= RS("rSO2_2") %></font></td>
<td><font size="2"><%= RS("rSO2_3") %></font></td>
<td><font size="2"><%= RS("rSO2_4") %></font></td>
<td><font size="2"><%= RS("Pols") %></font></td>
<td><font size="2"><%= RS("dSPO2") %></font></td>
<td><font size="2"><%= RS("awRF") %></font></td>
</tr>
<%
loopCounter = loopCounter + 1
if loopCounter = 1000 then
Response.Flush
loopCounter = 0
end if
RS.Movenext
Loop
%>
</table>
<%
RS.Close
CS.Close
Set CS = Nothing
Set RS = Nothing
%>
---------------------end of code--------------------
We've got this well working script (see below) that produces an XLS file. But our results exeed the limitations of the XLS format. That's wy I'm trying to write my output to CSV.
Can this be done by changing our current code or do I need complete other methode to make this work? And what sould be changed to get this working?
All help welcome
-----current code-----------------
<!--#INCLUDE FILE="connect.asp"-->
<%
Server.ScriptTimeout = 600
Response.Buffer=true
'Declare some variables
dim RS, pid
Set RS = Server.CreateObject("ADODB
pid = Request.QueryString("pid")
sql = "SELECT * FROM mytable WHERE id= " & pid & " order by datum"
RS.Open sql, CS
'This is the the code which tells the page to open Excel and give it the data to display
Response.ContentType = "application/vnd.ms-excel"
'You can give the spreadsheet a name at the point its produced
Response.AddHeader "Content-Disposition", "attachment; filename="& pid&".xls"
loopCounter = 0
%>
<!--
Note that I have formatted the output header here to a dark blue background and white text
this will be reflected in the spreadsheet when its produced and you could extend this to your own tastes of course.
-->
<table border="1" width="100%">
<tr>
<th bgcolor="#FFFFFF"><font size="2">patientnummer</fo
<th bgcolor="#FFFFFF"><font size="2">datum/tijd</font>
<th bgcolor="#FFFFFF"><font size="2">bed</font></th>
<th bgcolor="#FFFFFF"><font size="2">HF</font></th>
<th bgcolor="#FFFFFF"><font size="2">RESP</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2r</font></th>
<th bgcolor="#FFFFFF"><font size="2">SpO2l</font></th>
<th bgcolor="#FFFFFF"><font size="2">tcpCO2</font></th
<th bgcolor="#FFFFFF"><font size="2">tcpO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">etCO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDs</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDm</font></th>
<th bgcolor="#FFFFFF"><font size="2">NIBDd</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPs</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPm</font></th>
<th bgcolor="#FFFFFF"><font size="2">ABPd</font></th>
<th bgcolor="#FFFFFF"><font size="2">rSO2_1</font></th
<th bgcolor="#FFFFFF"><font size="2">rSO2_2</font></th
<th bgcolor="#FFFFFF"><font size="2">rSO2_3</font></th
<th bgcolor="#FFFFFF"><font size="2">rSO2_4</font></th
<th bgcolor="#FFFFFF"><font size="2">Pols</font></th>
<th bgcolor="#FFFFFF"><font size="2">dSPO2</font></th>
<th bgcolor="#FFFFFF"><font size="2">awRF</font></th>
</tr>
<%Do While Not RS.eof%>
<tr>
<td><font size="2"><%= RS("PID") %></font></td>
<td><font size="2"><%= RS("datum") %></font></td>
<td><font size="2"><%= RS("bed") %></font></td>
<td><font size="2"><%= RS("HF") %></font></td>
<td><font size="2"><%= RS("RESP") %></font></td>
<td><font size="2"><%= RS("SpO2") %></font></td>
<td><font size="2"><%= RS("SpO2r") %></font></td>
<td><font size="2"><%= RS("SpO2l") %></font></td>
<td><font size="2"><%= RS("tcpCO2") %></font></td>
<td><font size="2"><%= RS("tcpO2") %></font></td>
<td><font size="2"><%= RS("etCO2") %></font></td>
<td><font size="2"><%= RS("NIBDs") %></font></td>
<td><font size="2"><%= RS("NIBDm") %></font></td>
<td><font size="2"><%= RS("NIBDd") %></font></td>
<td><font size="2"><%= RS("ABPs") %></font></td>
<td><font size="2"><%= RS("ABPm") %></font></td>
<td><font size="2"><%= RS("ABPd") %></font></td>
<td><font size="2"><%= RS("rSO2_1") %></font></td>
<td><font size="2"><%= RS("rSO2_2") %></font></td>
<td><font size="2"><%= RS("rSO2_3") %></font></td>
<td><font size="2"><%= RS("rSO2_4") %></font></td>
<td><font size="2"><%= RS("Pols") %></font></td>
<td><font size="2"><%= RS("dSPO2") %></font></td>
<td><font size="2"><%= RS("awRF") %></font></td>
</tr>
<%
loopCounter = loopCounter + 1
if loopCounter = 1000 then
Response.Flush
loopCounter = 0
end if
RS.Movenext
Loop
%>
</table>
<%
RS.Close
CS.Close
Set CS = Nothing
Set RS = Nothing
%>
---------------------end of code--------------------
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER