Visualizzazione dei risultati da 1 a 5 su 5

Discussione: ContentType

  1. #1
    Utente di HTML.it L'avatar di seclimar
    Registrato dal
    Sep 2002
    Messaggi
    21,042

    ContentType

    In asp mi bastava fare ...

    response.ContentType="application/vnd.ms-excel"

    per apire la pagina con excel


    in asp .net ho provato a cambiare la proprietà ContentType del DOCUMENT
    e anche a fare nella Load del form... response.ContentType="application/vnd.ms-excel"

    ma non funziona.... qualche suggerimento ?

  2. #2
    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.Oledb" %>

    <script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
    Dim myDataset As New DataSet()

    ''You can also use the Excel ODBC driver I believe - didn''t try though
    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\exceltest.xls;" & _
    "Extended Properties=""Excel 8.0;"""

    ''You must use the $ after the object you reference in the spreadsheet
    Dim myData As New OledbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
    myData.TableMappings.Add("Table", "ExcelTest")
    myData.Fill(myDataset)

    DataGrid1.DataSource = myDataset.Tables(0).DefaultView
    DataGrid1.DataBind()
    End Sub
    </script>

    <html>
    <head></head>
    <body>


    <asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p>
    <aspataGrid id=DataGrid1 runat="server"/>\
    </body>
    </html>

  3. #3
    Utente di HTML.it L'avatar di seclimar
    Registrato dal
    Sep 2002
    Messaggi
    21,042
    non hai capito la domanda...
    cmq...no problem..
    ho gia' risolto..

  4. #4
    ehehhehehe

    come? potresti postare la soluzione?

  5. #5
    Utente di HTML.it L'avatar di seclimar
    Registrato dal
    Sep 2002
    Messaggi
    21,042
    Per redirigerla verso Excel si cambia semplicemente il content type della pagina.

    Seguendo questi due documenti Microsoft si risolvono i problemi di Content Type (con ASP non c'era bisogno):
    http://support.microsoft.com/default...en-us%3B317719
    e
    http://support.microsoft.com/default...en-us%3B318756
    che riassumendo, consigliano di fare i seguenti 3 passi:
    · modificare il Content Type con quello dell’applicazione da usare
    · svuotare il Charset (Response.Charset = "")
    · mettere il EnableViewState della pagina a False

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 © 2025 vBulletin Solutions, Inc. All rights reserved.