I want to create a csv file which contains both string and image. I am able to give the input as a strings separated by commas. Ex
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *root = [documentsDir stringByAppendingPathComponent:@"products.csv"];
NSString *temp=@"jack,jil,jimmy,mike";
[temp writeToFile:root atomically:YES encoding:NSUTF8StringEncoding error:NULL];
In the above case it works fine. Now I need to add an image with the strings. I have the image as NSData. In this case how can I give the input to csv file.
I am also able to attach the image alone to a csv file as NSData. Ex
UIImage *img = [UIImage imageNamed:@"flower.png"];
NSData *dataObj = UIImageJPEGRepresentation(img, 1.0);
[dataObj writeToFile:root atomically:YES];
My expected output should contain both image and string if I open the csv file as Excel sheet.
CSV file can contain only textual data. And, textual data of meaningful size. You'd better produce Excel XML with all the rows, text data inside it, and stored image inside.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With