0

How do I open an Excel file while working with iphone simulator?

RageZ
  • 26,800
  • 12
  • 67
  • 76
priya
  • 3
  • 2
  • you click start -> all programs -> Microsoft Office -> Excel, if you are on windows. would you give a little more details ? – RageZ Nov 18 '09 at 04:43
  • 1
    @RageZ; the iphone-simulator is a mac-only program, and I'm assuming the question relates to opening the file *inside* the simulator... – Stobor Nov 18 '09 at 04:45
  • ha sorry forgot the iphone SDK is only on Mac! – RageZ Nov 18 '09 at 04:46
  • @Stobor: yeah we can assume it is inside the simulator but would have been better if it was stated plus I suppose the simulator would have network access and XCode or there some tools to actually browse the virtual filesystem. – RageZ Nov 18 '09 at 04:48
  • i working on an iPhone application in which we have to create an application which will xtract data from xls files and add it into address buk of iphone.I m new to iphone simulator...plzzz Helppp – priya Nov 18 '09 at 06:37

3 Answers3

0

I am not sure, but you can try to use loadData: method of UIWebView with mimetype @"application/excel".

Morion
  • 10,495
  • 1
  • 24
  • 33
0

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?

Dan J
  • 25,433
  • 17
  • 100
  • 173
0

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.

Community
  • 1
  • 1
rohan-patel
  • 5,772
  • 5
  • 45
  • 68