1

I have an application which will download .xlsx, .pdf files from a given url. When downloaded will show a local notification. Upon clicking the notification , preview of the downloaded file should be shown. I can download and preview a pdf file, but when it comes to .xlsx file, I can't preview it. I used UIDocumentInteractionController and UIDocumentInteractionControllerDelegate to interact with the file's path to preview it.

func showFileWithPath(path: String)
{
    print(path)
    let isFileFound:Bool? = FileManager.default.fileExists(atPath: path)
    if isFileFound == true
    {
        let viewer = UIDocumentInteractionController(url: URL(fileURLWithPath: path))
        viewer.delegate = self
        viewer.presentPreview(animated: true)
    }
}

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController
{
    return self.navigationController!
}

This showFileWithPath(path: String) method will be called in UserNotification delegate method and the path of the file is passed as the parameter. This code is working fine for pdf files. But when it comes to .xlsx files, the preview is not showing any contents, just showing loading. The same case when tried with QuickLook Framework.

ifrit
  • 11
  • 4
  • Welcome to Stack Overflow! We'll need more information to properly help you: what have you tried so far (share your code!), what specifically is going wrong, and do you have a minimal working example of the issue? See [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask), the [Stack Overflow question checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) and [Creating a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Mark Ormesher Jan 28 '20 at 07:24

0 Answers0