Sign In  Sign Up Live-Chat

Read-Only

Last post 08-30-2008, 7:00 AM by DavidH. 3 replies.
Sort Posts: Previous Next
  •  08-29-2008, 8:14 PM 141827

    Read-Only

    If I have an 2003 Excel document open in Excel, and open it with Aspose, it opens fine (I'm assuming in Read-Only).

    However, if I open a 2007 Excel document in Excel, and I try to use Aspose with it, I get:

    System.IO.IOException was unhandled
      Message="The process cannot access the file 'test.xlsm' because it is being used by another process."

    How do I force them to be opened as read-only?

     
  •  08-29-2008, 8:21 PM 141828 in reply to 141827

    Re: Read-Only

    Found a manual way to do it:

    Dim xl As New Aspose.Cells.Workbook()

    Dim fs As New IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)

    Dim sr As New IO.StreamReader(fs)

    xl.Open(sr.BaseStream, FileFormatType.Excel2007Xlsm)

    If there is an easier way to force read-only, please let me know.

    ------------------------------------------------------------

    On a completely different note: Is there a function I can use where I can pass in a filename and have it determine the FileFormatType I need to use?

     
  •  08-30-2008, 1:58 AM 141834 in reply to 141828

    Re: Read-Only

    Hi,

    Well, yes, Aspose.Cells for .NET can auto-detect FileFormatType, so if you don't provide the format type (e.g.., .xls, .xlt, .xlsx, .xlsm etc. ), it will determine the file format type automatically.

    e.g..,

    Dim xl As New Aspose.Cells.Workbook()

    Dim fs As New IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)

    Dim sr As New IO.StreamReader(fs)

    xl.Open(sr.BaseStream)

     

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  08-30-2008, 7:00 AM 141842 in reply to 141834

    Re: Read-Only

    Amjad Sahi:

    Hi,

    Well, yes, Aspose.Cells for .NET can auto-detect FileFormatType, so if you don't provide the format type (e.g.., .xls, .xlt, .xlsx, .xlsm etc. ), it will determine the file format type automatically.

    e.g..,

    Dim xl As New Aspose.Cells.Workbook()

    Dim fs As New IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)

    Dim sr As New IO.StreamReader(fs)

    xl.Open(sr.BaseStream)

     

    Thank you.

    Ah thanks.  Apparently if you use the LoadData function, instead of Open, it throws a fit about file format, so I thought it was the same for both.

     
View as RSS news feed in XML