title: How to write array data into excel file (CSV) in objective c
body: <p>I am trying to write the array data into excel (actually it is a CSV, but it is opened in excel). I used the following code to do that:</p>
  
  <pre><code>NSMutableArray *list;
      list = [[NSMutableArray alloc] init];
  
  NSString *string = [list componentsJoinedByString:@","];
  
  NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"yourFileName.csv"];
  [data writeToFile:appFile atomically:YES];
  </code></pre>
  
  <p>It works fine, but the problem is I have 20 objects in my 'list' array and all those 20 objects are written in side by side cells. What I want is to write the first 4 objects in one line and then move to the new line and again write the next 4 objects in that line till all the objects in the list array are completed.</p>
  
  <p>Can anyone help me with this issue?</p>