簡體   English   中英

將NSImage導出到Excel工作表

[英]Export NSImage to Excel Sheet

如何在Excel Sheet中導出NSImage?

當我嘗試執行以下操作時,Microsoft Excel應用程序無法讀取內容。

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];

誰能建議我如何導出在Excel工作表中轉換為NSImage的視圖?

當您writeToFile:automatically:調用writeToFile:automatically:它會將tiff保存在該路徑中,而不將其添加到xlsx中。 您需要知道什么是xlsx格式,然后決定如何將文件寫入其中。

這可能會有所幫助:

在Cocoa中創建Excel(.xlsx)文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM