0

How can export an NSImage in excel Sheet?

When i try doing the below, The Microsoft Excel Application is unable to read the content.

NSBitmapImageRep *imageRep = [self.displayView bitmapImageRepForCachingDisplayInRect:[self.displayView bounds]];
[imageRep setSize:self.displayView.frame.size];
                [self.displayView cacheDisplayInRect:[self.displayView bounds] toBitmapImageRep:imageRep];
NSImage *image1 = [[NSImage alloc] initWithSize:NSMakeSize(imageRep.pixelsWide, imageRep.pixelsHigh)];
[image1 addRepresentation:imageRep]; 
[[image1 TIFFRepresentation]
 writeToFile:@"AbsolutePath/ExportImageTest.xlsx"atomically:YES];

Can any one Suggest me how can i export a view converted to NSImage in excel sheet?

Abdul Naveed
  • 567
  • 2
  • 9
  • A TIFF is not an Excel spreadsheet. Why do you believe writing a TIFF with an .xlsx will turn it into one? – Brad Larson Oct 09 '14 at 14:49
  • Yep you are right Brad, But can you help me in getting this done using NSImage on excel sheet, Is there a way to do this? – Abdul Naveed Oct 10 '14 at 09:36

1 Answers1

1

When you call writeToFile:automatically: it saves tiff at that path, does not add it to xlsx. You need to know what is the xlsx format and then decide how to write the file into it.

This may help:

Creating Excel (.xlsx) files in Cocoa

Community
  • 1
  • 1
Krzysztof
  • 1,441
  • 11
  • 22