您的位置:首页 > 移动开发 > IOS开发

iOS 读取Excel 等文件

2014-09-04 12:07 911 查看
方法一:使用QuickLook.freamwork

    UIDocumentInteractionController *document = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:@"/Users/a502333921/Desktop/ブック2.xlsx"]];

    document.delegate = self;

    NSLog(@"%d",[document presentPreviewAnimated:YES]);

- (UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller
{

    return
self;
}
- (UIView*)documentInteractionControllerViewForPreview:(UIDocumentInteractionController*)controller
{

    return
self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController*)controller
{

    returnself.view.frame;
}

//点击预览窗口的“Done”(完成)按钮时调用

- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController*)_controller
{
}
此方法弹框显示文件  也可以通过其他软件打开文档

方法2:

    QLPreviewController *previewoCntroller = [[QLPreviewController alloc] init];

    previewoCntroller.dataSource = self;

    [self presentViewController:previewoCntroller animated:YES completion:nil];

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller
{
   return1;
}

- (id <QLPreviewItem>)previewController: (QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{

    return [NSURLfileURLWithPath:@"/Users/a502333921/Desktop/ブック2.xlsx"];
}

方法三
UIWebView

方法四:
通过DHxls框架 https://github.com/dhoerl/DHlibxls
问题:
当你加载Excel时候,可能会出现部分气泡中内容不显示等情况,请重新保存为xls格式文档!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  excel ios iphone