How do I open an Excel file while working with iphone simulator?
How do I open an Excel file while working with iphone simula开发者_如何转开发tor?
I am not sure, but you can try to use loadData: method of UIWebView with mimetype @"application/excel".
I think Morion is right that you can open an Excel file in a UIWebView, but that might not work in the Simulator, and I'm not sure how well you could programmatically extract the information you want to add to the ABAddressBook.
Perhaps you want to save the Excel file as a CSV file? Then you can include it as a resource in your application and parse the contents quite easily?
Or do you want the user to be able to specify an arbitrary Excel file?
There is a good tutorial available here which demonstrates how to open .pdf, .xls files in your application.
The main class you have to refer for this is QLPreviewController
. here
This is the Datasource Method you would have to call for that
- (id <QLPreviewItem>)previewController: (QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
// Break the path into it's components (filename and extension)
NSArray *fileComponents = [[arrayOfDocuments objectAtIndex: index] componentsSeparatedByString:@"."];
// Use the filename (index 0) and the extension (index 1) to get path
NSString *path = [[NSBundle mainBundle] pathForResource:[fileComponents objectAtIndex:0] ofType:[fileComponents objectAtIndex:1]];
return [NSURL fileURLWithPath:path];
}
Also someone would like to refer this SO question :iPhone - Opening word and excel file without using UIWebview.
精彩评论