【问题标题】:Export data to csv format file in mac app在mac app中将数据导出为csv格式文件
【发布时间】:2012-11-20 12:16:33
【问题描述】:

我是 Mac 应用开发的新手。

我在 nstableview 中有一组数据,我需要以编程方式将这些数据保存为 .cs 格式。

-(IBAction)exportInvoice:(id)sender
{
    AppDelegate *appDelegate = [NSApp delegate];
     NSString *tempStr = [NSString stringWithFormat:@"%@", [OrderModel getInitialOrderBITToDisplay:[appDelegate getDBPath]]];
    NSArray* commaSeparatedObjects = [tempStr componentsSeparatedByString:@","];
    //NSString *commaSeparatedObjects = [tempStr componentsJoinedByString:@","];
    NSLog(@"%@",commaSeparatedObjects);

    NSSavePanel *pdfSavingDialog = [NSSavePanel savePanel];

    [pdfSavingDialog setRequiredFileType:@"csv"];

    if ( [pdfSavingDialog runModalForDirectory:nil file:nil] == NSOKButton ) {
       // NSData *dataForPDF = [self exportPdfData];
        NSData *dataForPDF = [NSKeyedArchiver archivedDataWithRootObject:commaSeparatedObjects];
        NSLog(@"%@",dataForPDF);
        [dataForPDF writeToFile:[pdfSavingDialog filename] atomically:NO];

    }
}

谁能帮我解决这个问题?

【问题讨论】:

    标签: objective-c macos csv nssavepanel


    【解决方案1】:

    您应该查看 CHCSVParser:https://github.com/davedelong/CHCSVParser 希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-20
      • 2018-09-04
      • 2011-11-01
      • 1970-01-01
      相关资源
      最近更新 更多