Friday, August 14, 2020

#1 2009-09-28 03:41:52 pm

Registered: 2009-09-28
Posts: 2

ScriptingBridge iWork 09 Numbers set backgroundColor

Hello List,

this is my first post and thats my problem with scriptingBridge. I try to build a time time schedule with iCal and Numbers. the workflow should be, to insert the working time into iCal. at the end of the month I will calculate with Numbers the overall working time from the different projects. so for, i can read all the data from iCal an put them via ScriptingBridge into Numbers.

The problem is, to set the backgroundColor of a cell to the calendar color. that is all what i have so far. this is an example with an green example color


   NSArray *nameArray = [NSArray arrayWithObjects:@"Peter", @"Paul" , @"Maria" , nil];
   NumbersApplication *numbersApp = [SBApplication applicationWithBundleIdentifier:@""];
   NSURL *numbersURL = [[NSBundle mainBundle ] URLForResource:@"pixelwg" withExtension:@"numbers"];
   NumbersDocument *document = [numbersApp open:numbersURL];
   NumbersSheet *sheet = [[[document sheets] lastObject] get];
   NumbersTable *table = [[sheet tables] objectWithName:@"stundenTable"];
   NumbersColumn *colKunde =    [[table columns] objectWithName:@"Kunde"];

   for(int index = 0 ; index < [nameArray count] ; index++)
       //write into cell
       [[[colKunde cells]objectAtIndex:index +1] setValue: [nameArray objectAtIndex:index]];
       //reference to the backgroundcolor
       id color = [[[colKunde cells] objectAtIndex:1] backgroundColor];
       //how can i set the backgroundcolor?????? it doesn't work
       [[[colKunde cells] objectAtIndex:1] setBackgroundColor:[NSColor greenColor]];
       NSLog(@"Color: %@" , color); // her logs the red color from the Numbers document
       index < ([nameArray count]-1) ? [colKunde addRowBelow]: nil;

You can download this complete demoproject
here .Anyone with suggestions????

thanks wrongspot

Filed under: numbers, ScriptingBridge



#2 2009-09-30 12:55:53 am

Registered: 2009-09-28
Posts: 2

Re: ScriptingBridge iWork 09 Numbers set backgroundColor

So what I discovered is, with that AppleScript you can change the color of my demoscene.


tell application "Numbers"
   set yourTable to the first table of sheet 1 of document 1
   tell yourTable
       set the rangeStart to the name of cell 2 of column 2
       set the rangeEnd to the name of last cell of last column
       tell range (rangeStart & ":" & rangeEnd) to set background color of every cell whose value is false to {0, 0, 0}
   end tell
end tell

The line with rangestart and rangeEnd could be similar like that in Objective C


NSString *rangeStart = [[[colKunde cells]objectAtIndex:index +1] name];

but how can I translate the line "tell range (rangeStart & ":" & rangeEnd) to set background color of every cell" in Objective C ???

Filed under: numbers



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)