1

I'm new here, hope this is the right area to post my problem, I'm trying to create an XLS file trough an ASP page, but when I try to download the Excel File the ASP page generate I'm getting the next error

The XML page cannot be displayed

Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

Invalid at the top level of the document. Error processing resource '_http:../victoria/FW91/BarrilesRandom/Escan...

Mov NumeroParte Planta Sloc1 Sloc2 Descuento UoM ^

Thing is this problem does not happen on all the computers of my local network, I mean, I download the file without problem on some computers, but getting the error on others, I though it might be the Excel version is installed on the computers(Using 2007 and 2010), but I I'm not sure, here's the code, hope you can help me. Greetings

%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

html xmlns="http://www.w3.org/1999/xhtml"

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8"

titleDocumento sin título/title

/head

body

Dim Conexion,SQL

set Conexion = Server.CreateObject("ADODB.Connection")

Conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & 

Server.MapPath("/database/Transferencias.mdb")

set rs = Conexion.execute("SELECT Mov,NumeroParte,Planta,Sloc1,Sloc2,Descuento,UoM FROM Transferencia")

    if rs.EOF then
        Response.Write("<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>")
        Response.Write("alert(""NO se ha escanneado ningun NP."");")
        Response.Write("</SCRIPT>")
        Response.Write("Ingrese datos al sistema")
    else
        Archivo = "Escanner.xls"
        PathXLS = Server.MapPath(Archivo)
        Set fso = Server.CreateObject("Scripting.FileSystemObject")
        Set Arch_Excel = fso.CreateTextFile(PathXLS, True)
        Fila = "Mov NumeroParte Planta  Sloc1   Sloc2   Descuento   UoM"
        Arch_Excel.writeline Fila

        'Inserta los datos del RecordSet en el Archivo de Excel
        Do while Not rs.EOF
            Fila = ""
            For each x in rs.fields
                Fila = Fila & x.value & chr(9)
            Next
            Arch_Excel.writeline Fila
            rs.MoveNext
        Loop

        Arch_Excel.Close
        Set Arch_Excel = Nothing
        Set fso = Nothing
        Response.Write("<table><a href="&Archivo&"><img border=0 width=""70"" height=""70"" src=""img\excel.jpg""></a>")
    end if
    SQL= "DELETE * FROM Transferencia"
    Conexion.Execute(SQL)
    SQL = "UPDATE Contador SET Contador = 0"
    Conexion.Execute(SQL)
    rs.Close
    Set rs = Nothing
    Conexion.Close
    Set Conexion = Nothing
%>

/body

/html
4

1 回答 1

0

尝试以表格格式写入文件,而不是制表符分隔。

Archivo = "Escanner.xls"
    PathXLS = Server.MapPath(Archivo)
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set Arch_Excel = fso.CreateTextFile(PathXLS, True)
    Fila = "<table><tr><td>Mov</td><td>NumeroParte</td><td>Planta</td><td>Sloc1</td><td>Sloc2</td><td>Descuento</td><td>UoM</td></tr>"
    Arch_Excel.writeline Fila

'Inserta los datos del RecordSet en el Archivo de Excel
Do while Not rs.EOF
    Fila = "<tr>"
    For each x in rs.fields
        Fila = Fila &"<td>" & x.value & "</td>"
    Next
    Fila = Fila &"</tr>"
    Arch_Excel.writeline Fila
    rs.MoveNext
Loop
Arch_Excel.writeline "</table>"
Arch_Excel.Close
Set Arch_Excel = Nothing
Set fso = Nothing
Response.Write("<table><a href="&Archivo&"><img border=0 width=""70"" height=""70"" src=""img\excel.jpg""></a>")
于 2012-11-29T06:51:20.820 回答