Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Table Tool/Document.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand Down