0

I am a Mac user and I am trying to develop an app for iPhone, which backs up the address book and send with an email. It sends the datas as .csv file.

When I open this .csv file in Mac Excel and in Windows Excel, it seems very different. forexample, the codes shown below all makes the difference...

When I do like that:

[stringToWrite appendFormat:@";"];

in Windows Excel.... it shows ok. I mean in Excel it shows like that;

name  (other cell) phone (other cell) mail
name2 (other cell) phone2(other cell) mail2

but in Mac Excel it looks like;

name;phone;mail (all in one cell)
name2;phone2;mail2(all in one cell)

When I do the code like that;

[stringToWrite appendFormat:@","]; 

in Mac Excel, it shows ok. I mean in Excel it shows like that;

name  (other cell) phone (other cell) mail
name2 (other cell) phone2(other cell) mail2

but in Windows Excel it looks like;

name,phone,mail (all in one cell)
name2,phone2,mail2(all in one cell)

Can anyone help please at that point?

Kara
  • 6,115
  • 16
  • 50
  • 57
mtlcck
  • 9
  • 2

1 Answers1

1

The default delimiter is setup differently for the Mac version and Windows version of Excel. (Little joke of Microsoft), but the workaround is to select in Excel how to import the values.

New Sheet -> Data -> Import Data, and then select which delimiter you want to use.

I think you should consider what kind of user you have (mostly Windows or Mac) and default to that.

  • thanks. In my code, i changed .csv file extension to .xls.. i mean, now the app creates an .xls file... and all the problems solved. i have now another problem... the problem is that; in an excel cell, i want to write my datas together.. i mean, one under another, not side by side.. forexample, a b..... they are in the same cell... which code or thing give this file format in XCODE? – mtlcck May 02 '12 at 14:48
  • If you're just changing the extension from .csv to .xls you cannot format the cells in any way. You should use some php module see [link]http://pear.php.net/package/Spreadsheet_Excel_Writer/ or [link]http://stackoverflow.com/questions/279917/format-text-in-excel-file-via-php – Luigi van der Pal May 07 '12 at 13:21