-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XLSXFile fails to open .xlsx file located on iPad ("XLSX file at \(file_path) is corrupted or does not exist") #160
Comments
Thank you for reporting this. Would you be able to confirm that files at this What does |
Thank you for the reply. I did as suggested and FileManager returns false,
even when I select the excel file with UIDocumentPicker. Do you have any
suggestions on what I need to do to resolve this? Thank you so much for
your help!
|
Unfortunately, no, I don't have suggestions as I don't have much experience with the file picker API. All I can say for now, it doesn't seem to be an issue with CoreXLSX, but rather an issue with the file picker API. Please let me know if your code shows otherwise. |
Max,
I figured it out. I had to provide access to the security scoped url that
UIDocumentPickerViewController returns after selecting the excel file. In
case others run into this same issue, this is how I resolved the issue by
providing access to the security scoped url. Thank you for your help!
```swift
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
let url = urls[0]
let filePath = url.path
guard url.startAccessingSecurityScopedResource() else { return }
defer { url.stopAccessingSecurityScopedResource() }
guard let file = XLSXFile(filepath: filePath) else {
fatalError("XLSX file at \(filePath) is corrupted or does not exist")
}
..........
}
```
|
Perfect, thanks for sharing the solution! |
Version
CoreXLSX 0.14.1
Description of the bug
XLSXFile fails to open .xlsx file located on iPad with the path "/private/var/mobile/Containers/Shared/AppGroup/F230537D-AA79-4A0A-AC47-08A1CA3C4BCA/File Provider Storage/workout.xlsx". Resulting in the error "XLSX file at (file_path) is corrupted or does not exist" when executing this code:
However, if the same .xlsx file is added to the app bundle, XLSXFile successfully opens the file with the path "/private/var/containers/Bundle/Application/25B45C3E-DF8D-4AB5-9E69-FF761A3DC48A/Phenix Fitt Workout.app/workout.xlsx" when executing the code:
Steps to reproduce
Run the below code with file_path = "/private/var/mobile/Containers/Shared/AppGroup/F230537D-AA79-4A0A-AC47-08A1CA3C4BCA/File Provider Storage/workout.xlsx":
Expected behavior
It is expected that XLSXFile will not crash when opening a .xlsx file that is located on the iPad.
File for reproduction
This issue occurs with any .xlsx file.
Additional context
The text was updated successfully, but these errors were encountered: