ios - text wrap when creating .csv file with NSMutableArray -


i creating .csv file following code

-(nsstring *)datafilepath {

nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); documentsdirectory = [paths objectatindex:0]; return [documentsdirectory stringbyappendingpathcomponent:@"myfile.csv"]; 

}
-(void)createfile{

if (![[nsfilemanager defaultmanager] fileexistsatpath:[self datafilepath]]) {     [[nsfilemanager defaultmanager] createfileatpath: [self datafilepath] contents:nil attributes:nil];  }  (int i=0; i<[arr count]; i++) {       nsstring *_amnt = [[self.reversedarr objectatindex:i]  valueforkey:@"amount"];      writestring = [nsstring stringwithformat:@"%@,%@,%@", [[arr objectatindex:i] valueforkey:@"date"], [[arr objectatindex:i] valueforkey:@"particular", [nsstring stringwithformat:@"%@\n", _amnt]];       }     nsfilehandle *handle;     handle = [nsfilehandle filehandleforwritingatpath: [self datafilepath] ];     //say handle where's file fo write     [handle truncatefileatoffset:[handle seektoendoffile]];     //position handle cursor end of file     [handle writedata:[writestring datausingencoding:nsutf8stringencoding]]; 

}

i successful create csv file having problem when opening .csv file in excel sheet row having more characters , extending column width according characters need wrap text fixed column width , row height should extend. should task. can 1 give suggestion .

process each string going format parameters separately. check length. if greater required length, insert carriage returns (like loop , insert characters in range stringbyreplacingcharactersinrange:withstring: or nsmutablestring insertstring:atindex:).


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -