How to open .xlsx file on UIWebView in iPhone?

烈酒焚心 提交于 2019-12-11 14:17:04

问题


Is it possible to open the .xlsx file on UIWebView. I can't open .xlsx file on UIWebView. I got the following error message when I open the .xlsx file.

Unable to Read Document. An error occurred while reading the document.

I didn't face any issue when I open remaining file types like .xls, .doc, .txt and .pdf.


回答1:


.xlsx cannot be opened in UIWebView, you can use .xls - it will work fine.




回答2:


You can open .xlsx

[webView loadData:urlData MIMEType:@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" textEncodingName:@"utf-8" baseURL:nil];

Swift

webView.load(urlData, mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", textEncodingName: "utf-8", baseURL: nil)


来源:https://stackoverflow.com/questions/11139284/how-to-open-xlsx-file-on-uiwebview-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!