开发者

reading excel sheet with url in Iphone sdk

I am Having a problem here.I am downloading the excel sheet using Url and have to displaying it in the web view here my problem is the Excel sheet is not displaying. I written the code as:

NSString *str = @"";
str = [str stringByAppendingString:
                @"http://databases.about.com/library/samples/address.xls"];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
[webView loadData:data MIMEType:@"application/xls" textEncodingName:@"UTF-8"
                          baseURL:[NSURL开发者_如何学编程 URLWithString:@"http://google.com"]];
[contentView addSubview:webView];

Thank you, Monish.


Are you able to view it using Safari on the phone or does it say "unsupported format"?

Try another file that works in Safari and then try in UIWebView.

Also see this: http://developer.apple.com/iphone/library/qa/qa2008/qa1630.html

First make sure you are able to view the xls in Safari then try code like this:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [NSURL URLWithString:@"http://www.yourwebsite.com/good.xls"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜