GithubHelp home page GithubHelp logo

Comments (8)

MaxDesiatov avatar MaxDesiatov commented on July 17, 2024

Could you also share more details about this behavior? What do you mean by "file is not read"? Is an error thrown in the code that you're catching? Does it trigger any of the fatalError or print conditions? Have you stepped through the code with the debugger to pinpoint the exact line at fault?

from corexlsx.

tburnt avatar tburnt commented on July 17, 2024

Could you also share more details about this behavior? What do you mean by "file is not read"? Is an error thrown in the code that you're catching? Does it trigger any of the fatalError or print conditions? Have you stepped through the code with the debugger to pinpoint the exact line at fault?

it triggers fatalError before I added startAccessingSecurityScopedResource
fatalError("excel file is corrupted")
when I added it as the solution from #160 it triggers the print statement
print("failed accessing security scope")

from corexlsx.

MaxDesiatov avatar MaxDesiatov commented on July 17, 2024

In your code from the description, you're assigning a path URL passed by the document picker as let filepath = url.path and never using it again, then you're trying to read from a new directory looked up by NSSearchPathForDirectoriesInDomains. I'm not sure I understand how a document picker is relevant here if you're not reading anything from a path provided by it.

from corexlsx.

tburnt avatar tburnt commented on July 17, 2024

Originally this is what I did

                    let url = urls[0]
                    let filePath = url.path
                   
                    guard url.startAccessingSecurityScopedResource() else {
                        print("failed accessing security scope")
                        return
                        
                    }
                    defer { url.stopAccessingSecurityScopedResource() }
                    
                    guard let file = XLSXFile(filepath: filePath) else {
                        fatalError("XLSX file at \(filePath) is corrupted or does not exist")
                    }

However it did not work so the next thing I tried was copy it to NSSearchPathForDirectoriesInDomains

The aim of the code is to pick an excel file from the document picker and read it but I had no luck in getting it to work

from corexlsx.

MaxDesiatov avatar MaxDesiatov commented on July 17, 2024

And in this original code, which exact line was bailing out, url.startAccessingSecurityScopedResource() or XLSXFile(filepath: filePath)?

from corexlsx.

tburnt avatar tburnt commented on July 17, 2024

url.startAccessingSecurityScopedResource()

from corexlsx.

MaxDesiatov avatar MaxDesiatov commented on July 17, 2024

Have you tried following this SO page? https://stackoverflow.com/questions/41144992/startaccessingsecurityscopedresource-return-always-false

According to it, startAccessingSecurityScopedResource may return false when the file is not secured, but it may still be readable.

from corexlsx.

MaxDesiatov avatar MaxDesiatov commented on July 17, 2024

Hi @tburnt, is this issue still reproducible for you?

from corexlsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.