Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    salvare il contenuto di una pagina asp in word

    Ciao,
    sono tutta la sera che cerco ma senza risultati...qualcuno conosce uno script scritto in asp che mi permetta di esportare i dati di una pagina asp in word?

    Ciao Grazie

  2. #2
    Utente di HTML.it L'avatar di viki1967
    Registrato dal
    Feb 2003
    Messaggi
    1,757
    Un esempio da personalizzare:

    codice:
    
    <html>
    <title>Create Word on Server</title>
    <body bgcolor="#FFFFFF">
    <%
    ' Name of the access db being queried
    accessdb="state_info" 
    
    ' Connection string to the access db
    cn="DRIVER={Microsoft Access Driver (*.mdb)};"
    cn=cn & "DBQ=" & server.mappath(accessdb)
    
    ' Create a server recordset object
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    ' Query the states table from the state_info db
    sql = "select state,statename,capital,year,order from states " 
    
    ' Execute the sql
    rs.Open sql, cn
    
    ' Move to the first record
    rs.MoveFirst
    
    ' For net loop to create seven word documents from the record set
    ' change this to "do while not rs.eof" to output all the records
    ' and the corresponding next should be changed to loop also
    
    for documents= 1 to 7
    ' Creates a text file on the server with the state abbreviation 
    ' as the name for the ouput document 
    file_being_created= rs("state") & ".doc"
    
    ' create a file system object
    set fso = createobject("scripting.filesystemobject")
    
    ' create the text file - true will overwrite any previous files
    Set act = fso.CreateTextFile(server.mappath(file_being_created), true)
    
    ' Writes the db output to a .doc file in the same directory 
    act.WriteLine("<html><title>CodeAve.com(" & rs("statename") & " State Info)</title>")
    act.WriteLine("<body bgcolor='#FFFFFF'> " )
    act.WriteLine("State: " & rs("statename") & "
    " )
    act.WriteLine("Abbreviaton: " & rs("state") & "
    " )
    act.WriteLine("Capital: " & rs("capital") & "
    ")
    act.WriteLine("Entered the Union in "& rs("year") & "
    ")
    act.WriteLine("Number in order of entrance into the Union "& rs("order") & "
    ")
    act.WriteLine("Page created on: " & now ())
    act.WriteLine("</body></html>")
    
    ' close the object
    act.close
    
    ' Writes the links to the newly created pages in the browser
    response.write "" & rs("statename") & " (.doc) " & now() & "
    "
    
    ' move to the next record
    rs.movenext
    
    ' return to the top of the for - next loop
    ' change this to "loop" to output all the records
    ' and the corresponding for statement above should be changed also
    next
    %>
    </body>
    </html>
    A S P : tutto il resto è noia...
    L I N U X : forse mi "converto"...

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2007
    Messaggi
    1,171

    word

    ho provato la pagina ma mi da questo errore

    Autorizzazione negata

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    La cartella in cui crei il file deve avere i permessi di scrittura per lo IUSR_NOMEMACCHINA.

    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2007
    Messaggi
    1,171

    word

    E come devo dare i permessi?

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Usa la ricerca del forum, troverai le risposte a quasi tutte le domande.

    Roby

  7. #7
    Se vuoi, puoi seguire anche questa strada, che ti dovrebbe anche dare meno problemi.

    http://forum.html.it/forum/showthrea...readid=1261327
    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.