2

I want to convert a database table into a csv file in Iphone. I want to attach the csv file in mail, so it can be viewed in excel sheet in a table form. How can I achieve it?

0

2 Answers 2

3

you should have a look at CHCSVParser made by Dave Delong. Ignore the name, it's a writer, too.

It's working great; until you want to support the german (and others) csv format, which uses semicolons

Sign up to request clarification or add additional context in comments.

2 Comments

How to give input to the CHCSV Writter?
Create a NSArray (for the rows) of NSArrays (for the columns) and then you can use the NSArray category method writeToCSVFile:atomically: from NSArray+CHCSVAdditions.h. But there are other ways, please refer to the readme of CHCSVParser
1

Hey I Found Simple Code ::

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); 
        NSString *documentsDir = [paths objectAtIndex:0];
        NSString *root = [documentsDir stringByAppendingPathComponent:@"customers.csv"];

        NSString *temp;

        temp = [NSString stringWithFormat:@"%@", [arrCustomersName objectAtIndex:0]];

        for (int i = 1; i < [arrCustomersName count]; i++) {

            temp = [temp stringByAppendingFormat:@", %@", [arrCustomersName objectAtIndex:i]];
        }

        [temp writeToFile:root atomically:YES encoding:NSUTF8StringEncoding error:NULL];

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.