I want to share excel file with UIAtivityViewController or UIDocumentInteractionController
let documentsPath = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(self.stateMentType)
do {
_ = try data?.write(to: URL.init(fileURLWithPath: documentsPath), options: .atomicWrite)
}
catch {
print("Error in writing \(error)")
}
let documents = NSData(contentsOfFile: documentsPath)
if fileManager.fileExists(atPath: documentsPath) {
// let activityController = UIActivityViewController(activityItems: [documents!], applicationActivities: nil)
// self.present(activityController, animated: true, completion: nil)
let url = URL(fileURLWithPath: documentsPath)
let dc = UIDocumentInteractionController(url: url)
dc.uti = "public.data"
dc.presentOpenInMenu(from: self.view.bounds, in: self.view, animated: true)
// dc.presentOptionsMenu(from: self.view.bounds, in: self.view, animated: true)
}
I am using this code with UIDocumentInteractionController. I am also added some key in Info Tab.
When i share the excel file , sharing views is opened but file is not sharing. Please help me .