Skip to content
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

Cannot save TestJXLSiOS xls file to documents directory #4

Closed
pavankataria opened this issue Jun 22, 2014 · 5 comments
Closed

Cannot save TestJXLSiOS xls file to documents directory #4

pavankataria opened this issue Jun 22, 2014 · 5 comments

Comments

@pavankataria
Copy link

Looks like it will be a great library. I am trying to test the iOS sample project provided but it seems like the file does not save when I run the project.
I have tested on both the simulator and the device. I have even searched the documents directory and the file cannot be retrieved.

I have even double checked by testing programmatically whether the file exists or not.

int fud = [workBook writeToFile:filePath];
NSString* documentdir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSString *tileDirectory = [documentdir stringByAppendingPathComponent:filePath];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:tileDirectory];
if(fileExists){
NSLog(@"File does exist at filepath %@", tileDirectory);
}
else{
NSLog(@"File does not exit at filePath: %@", tileDirectory);
}
NSLog(@"OK - bye! fud=%d", fud);

This keeps returning false that the file is not found.

What can I do to find the saved file, or how can I save the excel file to a directory?

I am hoping someone here can identify the problem as soon as possible. Thank you

@JanX2
Copy link
Owner

JanX2 commented Jun 23, 2014

The iOS sample project is working for me without any issues.

Is it possible that the problem is that you expect the file to be saved somewhere other than filePath?

It’s defined thus:

NSString *filePath = @"/tmp/foo.xls";

@JanX2 JanX2 closed this as completed Nov 20, 2014
@cstokes
Copy link

cstokes commented May 28, 2015

I seem to be having this exact problem, I get slightly varying results depending on if I try with a device or simulator. On the simulator I don't appear to get any errors with the output:

OK - bye! fud=0

But still no file at filePath. On the device however, I always seem to get an error:

OK - bye! fud=-1

So obviously no file there. This is without changing any code from the sample project, it just doesn't seem to create the file. I'm not sure where to go from there, so any help would be appreciated! I'm using Xcode 6.3 and running on iOS 8.1 to 8.3.

Thanks!

@JanX2
Copy link
Owner

JanX2 commented May 28, 2015

I currently don’t have an iOS dev account. Is it possible that this is a sandboxing issue? Can you try modifying the sample to have it generate the file in a path that you are sure the app has access to?

@cstokes
Copy link

cstokes commented May 29, 2015

You were absolutely right! I don't know why I didn't think about trying the path that worked when saving the other document to test against it. I replaced:

NSString *filePath = @"/Documents/foo.xls";

with:

NSString* documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* fileName = @"foo.xls";
NSString* filePath = [documentDirectory stringByAppendingPathComponent:fileName];

and it worked like a charm first time. Thank you immensely for your help!

@JanX2
Copy link
Owner

JanX2 commented May 29, 2015

@cstokes glad I could help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants