[英]Export data to csv format file in mac app
我是 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];
}
}
誰能幫我解決問題?
您應該查看 CHCSVParser: https : //github.com/davedelong/CHCSVParser希望有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.