问题
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