How to create .CSV file with string and image in iphone programatically?
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(NSDocumentDire ctory , 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. Please help me out. Thanks.
|