Creating Excel (.xlsx) files in Cocoa

前端 未结 3 392
离开以前
离开以前 2020-12-05 11:09

I\'m writing a Cocoa application and I\'m trying to export to the Excel XML format (ISO/IEC 29500-1) which is basically a zip file with a bunch of XML files in it named with

3条回答
  •  情书的邮戳
    2020-12-05 11:51

    How about encapsulating HTML table in Excel file? I have checked that this works and I can open it with Excel.

    NSURL * documentsDirectory = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject;
    NSURL *file = [documentsDirectory URLByAppendingPathComponent:@"contacts.xls"];
    NSString* string = @"
    FOOBAR
    "; [string writeToFile:file.path atomically:YES encoding:NSUTF8StringEncoding error:nil];

提交回复
热议问题