Closed trailburner closed 8 years ago
Haven't tested it yet, but it seems you are trying to save a file present in the main bundle. Save your file in a cache folder from the sandbox, then send the saved copy by email, it should work.
@trailburner Did you manage to solve this issue? could you send the updated file?
@AmbroseSilveira nope I did not get time to look into it.... let me know if you can solve it maybe we can exchange notes
@trailburner I was working on similar kind of issue where i had to write in an excel file. My observation was,
The good news is i have solution for your problem:
problem: you are reading a file from bundle resource of the path which has only read access.
solution:So, you gotta make a copy of the excel file in document directory and then write onto it , preform the save operation and and send the file.
here a chunk of code that might help you:
let doc = NSSearchpathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let path = doc.appending("/filename.xlsx") let filemanager = Filemanager.default if !filemanager.fileExists(atPath:path) { let resourcePath = Bundle.main.path(forResource:"filename", ofType:"xlsx") do { try filemanager.copyItem(atPath:resourcePath!, toPath:path) } catch { print("error") } }
//now perform reading from document directory xlsx file and perform write and save operation and see. It should work unless formulas are not in picture.
So I'm using swift then I send the file through an email code but the changes are not commited I still see the excel file with no records inserted Am I doing something wrong or did I miss something?
Thanks