When exporting Access to Excel within my ASP code the resulting data in the Excel sheet all have an apostrophe (') in front of them. Does anybody know how to resolve this issue? Many thanks.
See Code below:
[...leading code not included...]
Dim fs, file
Set fs=Server.CreateObject("Scripting.FileSystemObject"
file = path & "\downloads\travel.xls"
fs.CopyFile path & "\templates\extract.xls", file, true
Set oConn = Server.CreateObject("ADODB.Connection"
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & file & ";Extended Properties=""Excel 8.0;HDR=NO;"""
n=0
SQLstmt = "SELECT *FROM tblAlias WHERE Client_ID =" & ID
Set rs = conn.Execute(SQLstmt)
DO WHILE NOT RS.EOF
IF n=0 THEN
strAlias = rs ("AliasName"
n = n + 1
ELSE
strAlias = strAlias & "," & rs("AliasName"
n = n + 1
END IF
RS.Movenext
LOOP
RS.CLOSE
Set SQLstmt = nothing
arrAlias = Split(strAlias, ",", -1, 1)
For I = LBound(arrAlias) To UBound(arrAlias)
SQLstmt = "SELECT * FROM tblMAXReport WHERE Company LIKE '" & arrAlias(I) & "' ORDER BY Passenger, Departure, FlightNum"
Set rs = conn.Execute(SQLstmt)
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset"
oRS.Open "Select * from Items", oConn, 1, 3 'adOpenKeyset, adLockOptimistic
DO WHILE NOT rs.EOF
oRS.AddNew
oRS.Fields(0) = rs ("Company"
oRS.Fields(1) = rs ("Passenger"
oRS.Fields(2) = rs ("Invoice"
oRS.Fields(3) = rs ("Airline"
oRS.Fields(4) = rs ("FlightNum"
oRS.Fields(5) = rs ("Departure"
oRS.Fields(6) = rs ("DptCity"
oRS.Fields(7) = rs ("DptCountry"
oRS.Fields(8) = rs ("Arrival"
oRS.Fields(9) = rs ("ArrCity"
oRS.Fields(10) = rs ("ArrCountry"
oRS.Update
RS.MoveNext
Loop
rs.CLose
NEXT 'I
See Code below:
[...leading code not included...]
Dim fs, file
Set fs=Server.CreateObject("Scripting.FileSystemObject"
file = path & "\downloads\travel.xls"
fs.CopyFile path & "\templates\extract.xls", file, true
Set oConn = Server.CreateObject("ADODB.Connection"
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & file & ";Extended Properties=""Excel 8.0;HDR=NO;"""
n=0
SQLstmt = "SELECT *FROM tblAlias WHERE Client_ID =" & ID
Set rs = conn.Execute(SQLstmt)
DO WHILE NOT RS.EOF
IF n=0 THEN
strAlias = rs ("AliasName"
n = n + 1
ELSE
strAlias = strAlias & "," & rs("AliasName"
n = n + 1
END IF
RS.Movenext
LOOP
RS.CLOSE
Set SQLstmt = nothing
arrAlias = Split(strAlias, ",", -1, 1)
For I = LBound(arrAlias) To UBound(arrAlias)
SQLstmt = "SELECT * FROM tblMAXReport WHERE Company LIKE '" & arrAlias(I) & "' ORDER BY Passenger, Departure, FlightNum"
Set rs = conn.Execute(SQLstmt)
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset"
oRS.Open "Select * from Items", oConn, 1, 3 'adOpenKeyset, adLockOptimistic
DO WHILE NOT rs.EOF
oRS.AddNew
oRS.Fields(0) = rs ("Company"
oRS.Fields(1) = rs ("Passenger"
oRS.Fields(2) = rs ("Invoice"
oRS.Fields(3) = rs ("Airline"
oRS.Fields(4) = rs ("FlightNum"
oRS.Fields(5) = rs ("Departure"
oRS.Fields(6) = rs ("DptCity"
oRS.Fields(7) = rs ("DptCountry"
oRS.Fields(8) = rs ("Arrival"
oRS.Fields(9) = rs ("ArrCity"
oRS.Fields(10) = rs ("ArrCountry"
oRS.Update
RS.MoveNext
Loop
rs.CLose
NEXT 'I