From ab4d71148c9a8b9df5c601741f6e5ffa58bbe317 Mon Sep 17 00:00:00 2001 From: Vladimir Samoylenko Date: Thu, 6 Dec 2018 20:37:40 +0200 Subject: [PATCH] Fixing issue #45 : Allow export/convert without header row Some minor fix. --- Table Tool/Document.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Table Tool/Document.m b/Table Tool/Document.m index bbc7a46..c966815 100644 --- a/Table Tool/Document.m +++ b/Table Tool/Document.m @@ -128,18 +128,18 @@ -(NSData*)dataWithCSVConfig:(CSVConfiguration*)config error:(NSError**)outError } NSArray *exportData = _data; - + if(self.csvConfig.firstRowAsHeader){ - NSMutableArray *headerRow = [[NSMutableArray alloc]init]; + NSMutableArray *headerRow = [[NSMutableArray alloc]init]; for(int i = 0; i < _maxColumnNumber; i++){ [headerRow addObject:@""]; } - for(NSTableColumn * col in self.tableView.tableColumns){ - [headerRow replaceObjectAtIndex:col.identifier.integerValue withObject:col.headerCell.stringValue]; - } - exportData = [@[headerRow] arrayByAddingObjectsFromArray:exportData]; - } - + for(NSTableColumn * col in self.tableView.tableColumns){ + [headerRow replaceObjectAtIndex:col.identifier.integerValue withObject:col.headerCell.stringValue]; + } + exportData = [@[headerRow] arrayByAddingObjectsFromArray:exportData]; + } + NSError *error; CSVWriter *writer = [[CSVWriter alloc] initWithDataArray:exportData columnsOrder:[self getColumnsOrder] configuration:config]; @@ -1126,6 +1126,7 @@ -(IBAction)exportFile:(id)sender { accessoryViewController = [[TTFormatViewController alloc] initWithNibName:@"TTFormatViewControllerAccessory" bundle:nil]; + self.csvConfig = statusBarFormatViewController.config; NSWindow *window = [[[self windowControllers] objectAtIndex: 0] window]; NSSavePanel *savePanel = [NSSavePanel savePanel]; @@ -1134,6 +1135,9 @@ -(IBAction)exportFile:(id)sender { [accessoryViewController selectFormatByConfig]; savePanel.allowedFileTypes = [NSArray arrayWithObject:@"csv"]; [savePanel beginSheetModalForWindow:window completionHandler:^(NSInteger result){ + + self.csvConfig = accessoryViewController.config; + if (result == NSFileHandlingPanelOKButton) { NSError *error = nil;