Read protect excel using aspnet

Discussion in 'ASP .Net' started by sweetpotatop@yahoo.com, Feb 23, 2007.

  1. Guest

    Hi,

    I wonder if it is possible to read the content of an excel spreadsheet
    through aspnet. The spreadsheet (workbook) is protected and it resides
    in a network drive.

    Please provide sample code if possible. Thanks in advance. Your help
    is greatly appreciated.
     
    , Feb 23, 2007
    #1
    1. Advertising

  2. Mark Rae Guest

    Mark Rae, Feb 23, 2007
    #2
    1. Advertising

  3. Guest

    What if it is not password protected, is it possible to read the
    sheets (more than 1) in the workbook and how can this be done?

    Thanks.

    On Feb 23, 9:10 am, "Mark Rae" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > Please provide sample code if possible.

    >
    > Unfortunately, the fact that the workbook has a password means that it can't
    > be opened via ADO.NET:http://support.microsoft.com/kb/211378/EN-US/
    >
    > Therefore, your only option is to use Aspose:http://www.aspose.com/Products/Aspose.Cells/Default.aspx
    >
    > Don't even think of trying to use Office automation:http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
     
    , Feb 23, 2007
    #3
  4. Mark Rae Guest

    Mark Rae, Feb 23, 2007
    #4
  5. Guest

    On Feb 23, 12:36 pm, "Mark Rae" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > What if it is not password protected, is it possible to read the
    > > sheets (more than 1) in the workbook and how can this be done?

    >
    > http://www.google.co.uk/search?sourceid=navclient&aq=t&ie=UTF-8&rls=G...



    Thanks for your advice, but I am getting the following error once
    objConn.Open is executed

    System.Data.OleDb.OleDbException: Unspecified error

    Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
    _
    & "Data Source=C:\test.xls" _
    & ";" & "Extended Properties=Excel 11.0;"

    ' Create the connection object by using the preceding
    connection string.
    Dim objConn As New OleDbConnection(sConnectionString)

    ' Open connection with the database.
    objConn.Open()

    Is it something to do with the Extended Properties? I have been trying
    8.0 to 11.0, but none of them work. The file is created through MS
    Excel 2003. Or something is missing on the machine?

    Please help. Your help is greatly appreciated.
     
    , Mar 7, 2007
    #5
  6. Mark Rae Guest

    <> wrote in message
    news:...

    > Thanks for your advice, but I am getting the following error once
    > objConn.Open is executed
    >
    > System.Data.OleDb.OleDbException: Unspecified error
    >
    > Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
    > _
    > & "Data Source=C:\test.xls" _
    > & ";" & "Extended Properties=Excel 11.0;"
    >
    > ' Create the connection object by using the preceding
    > connection string.
    > Dim objConn As New OleDbConnection(sConnectionString)
    >
    > ' Open connection with the database.
    > objConn.Open()
    >
    > Is it something to do with the Extended Properties?


    You need to catch the exception and then inspect the inner exception to find
    out what precisely is going wrong...

    Also, is text.xls actually present in the root directory of your
    webserver...?
     
    Mark Rae, Mar 7, 2007
    #6
  7. Guest

    On Mar 7, 4:07 am, "Mark Rae" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > Thanks for your advice, but I am getting the following error once
    > > objConn.Open is executed

    >
    > > System.Data.OleDb.OleDbException: Unspecified error

    >
    > > Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
    > > _
    > > & "Data Source=C:\test.xls" _
    > > & ";" & "Extended Properties=Excel11.0;"

    >
    > > ' Create the connection object by using the preceding
    > > connection string.
    > > Dim objConn As New OleDbConnection(sConnectionString)

    >
    > > ' Open connection with the database.
    > > objConn.Open()

    >
    > > Is it something to do with the Extended Properties?

    >
    > You need to catch the exception and then inspect the inner exception to find
    > out what precisely is going wrong...
    >
    > Also, is text.xls actually present in the root directory of your
    > webserver...?- Hide quoted text -
    >
    > - Show quoted text -



    No luck, unfortunately, I have moved the test.xls to the root
    directory of the web application (see below)

    Dim sConnectionString As String =
    "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=" &
    Server.MapPath("./test.xls") _
    & ";" & "Extended Properties=Excel
    11.0;"

    And I try to catch the exception but I am still getting "Unspecified
    error "
    Try
    objConn.Open()
    Catch ex As Exception
    Page.RegisterStartupScript("Cannot Open",
    "<script>window.alert('" & (ex.Message.ToString) & "' );</script>")
    Exit Sub
    End Try

    Please help. I really need to get this resolved. Many thanks.
     
    , Mar 7, 2007
    #7
  8. Mark Rae Guest

    <> wrote in message
    news:...

    > And I try to catch the exception but I am still getting "Unspecified
    > error "
    > Try
    > objConn.Open()
    > Catch ex As Exception
    > Page.RegisterStartupScript("Cannot Open",
    > "<script>window.alert('" & (ex.Message.ToString) & "' );</script>")
    > Exit Sub
    > End Try
    >
    > Please help. I really need to get this resolved. Many thanks.


    Like I said, you need to interrogate the InnerException property of the
    Exception object, not the Message property...
     
    Mark Rae, Mar 7, 2007
    #8
  9. Guest

    On Mar 7, 9:28 am, "Mark Rae" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > And I try to catch the exception but I am still getting "Unspecified
    > > error "
    > > Try
    > > objConn.Open()
    > > Catch ex As Exception
    > > Page.RegisterStartupScript("Cannot Open",
    > > "<script>window.alert('" & (ex.Message.ToString) & "' );</script>")
    > > Exit Sub
    > > End Try

    >
    > > Please help. I really need to get this resolved. Many thanks.

    >
    > Like I said, you need to interrogate the InnerException property of the
    > Exception object, not the Message property...



    I have something like this, but "InnerException Is Nothing", so I
    can't any message at all. Please help!!!

    Try
    objConn.Open()
    Catch ex As Exception
    'lblError.Text = ex.Message.ToString

    If Not (ex.InnerException Is Nothing) Then
    Page.RegisterStartupScript("Cannot Open",
    "<script>window.alert('" & (ex.InnerException.ToString) & "' );</
    script>")
    End If
    Exit Sub
    End Try
     
    , Mar 7, 2007
    #9
  10. Mark Rae Guest

    Mark Rae, Mar 7, 2007
    #10
  11. Guest

    On Mar 7, 11:00 am, "Mark Rae" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > I have something like this, but "InnerException Is Nothing", so I
    > > can't any message at all. Please help!!!

    >
    > In which case, I'm at a bit of a loss...
    >
    > This error is well enough documented on Google:http://www.google.co.uk/search?hl=en&rls=GGLG,GGLG:2006-28,GGLG...
    >
    > Has nothing there helped...?




    Perfect! It is working now -- the permission to the
    C:\Documents and Settings\MachineName\ASPNET\Local Settings\Temp
    folder

    Thanks a trillion.
     
    , Mar 7, 2007
    #11
  12. Mark Rae Guest

    <> wrote in message
    news:...

    > Perfect! It is working now -- the permission to the
    > C:\Documents and Settings\MachineName\ASPNET\Local Settings\Temp
    > folder
    >
    > Thanks a trillion.


    I think, in the end, all I did was tell you to do a Google search... :)

    For virtually every problem, that's the place to start...
     
    Mark Rae, Mar 7, 2007
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gary Nelson

    Upgrade from aspnet 1.1 to aspnet 2.0

    Gary Nelson, Oct 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    488
    Gary Nelson
    Oct 14, 2005
  2. =?Utf-8?B?bGFuZW0=?=
    Replies:
    0
    Views:
    563
    =?Utf-8?B?bGFuZW0=?=
    May 26, 2006
  3. Replies:
    7
    Views:
    652
    Juan T. Llibre
    Mar 23, 2007
  4. sajithkahawatta

    read a excel sheet using aspose.excel

    sajithkahawatta, Apr 19, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    550
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Apr 19, 2007
  5. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,512
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
Loading...

Share This Page