开发者

How to create .CSV file with string and image in iPhone programmatically?

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 cas开发者_如何学Goe 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜