[英]Unable to open my excelSheet in MS-Excel iOS app from my iOS app via url scheme
Actually I am following this document to open my excel sheet in iOS MS_EXCEL app from my app via url scheme. 实际上,我正在遵循此文档以通过URL方案从我的应用程序在iOS MS_EXCEL应用程序中打开我的Excel工作表。 By using its documentation I open EXCEL app successfully.
通过使用其文档,我成功打开了EXCEL应用程序。 But I am totally unable to open my excel sheet .
但是我完全无法打开我的Excel工作表。 Every time EXCEL app gives me error showing in this image
每次EXCEL应用程序给我该图像中显示的错误
I am passing my saved file url to Excel app. 我将保存的文件URL传递给Excel应用程序。 I have checked the saved file path by iExplorer.
我已经通过iExplorer检查了保存的文件路径。 That file is perfectly opened .
该文件已完美打开。 But in Excel app, its really giving me headache.
但是在Excel应用程序中,它确实让我头疼。
Please help me out that where am I making Mistake. 请帮我弄清楚我在哪里犯错。 Here my code snippet
这是我的代码段
static NSString * encodeByAddingPercentEscapes(NSString *input) {
NSString *encodedValue =
(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)input,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8));
return encodedValue;
} }
-(NSURL*)excelUrlStringForFile:(NSString*)urlFile WithContext:(NSString*)strContext
{
NSURL *result =[NSURL URLWithString:[[NSString stringWithFormat:@"ms-excel:ofe|u|%@|p|%@|c|%@",encodeByAddingPercentEscapes(urlFile),urlScheme,strContext] stringByAddingPercentEscapesUsingEncoding:4]];
return result;
}
Here If I am not using 'encoding string by NSUTF8StringEncoding
' this above NSURL
object result
is set to nil. 如果我不使用“通过
NSUTF8StringEncoding
编码字符串”,则上述NSURL
对象result
将设置为nil。 So I must have to use encoding. 因此,我必须使用编码。
NSURL *openExcelURL = [self excelUrlStringForFile:filePath WithContext:str_fileName];
if([[UIApplication sharedApplication] canOpenURL:openExcelURL])
{
[[UIApplication sharedApplication] openURL:openExcelURL];
}
I am in the same situation, I'm trying to open local files from other application, looking into the website where you have seen the excel URL Scheme I found this text. 我处在相同的情况下,我正在尝试从其他应用程序打开本地文件,查看进入您看到我找到此文本的excel URL Scheme的网站。 It looks like you cannot open local files using this method, it is very strange but only it makes reference to OneDrive and SharePoint files... =S
看来您无法使用此方法打开本地文件,这很奇怪,但是只有它引用了OneDrive和SharePoint文件... = S
If someone knows something about this issue would be very useful to us 如果有人对这个问题有所了解,对我们将非常有用
You can enable users who are running Office on an iOS device to open and edit files stored in SharePoint or OneDrive from any application, and then quickly return them to the original application when they're done editing the file.
您可以使在iOS设备上运行Office的用户能够从任何应用程序打开和编辑SharePoint或OneDrive中存储的文件,然后在完成文件编辑后将其快速返回到原始应用程序。 To do this, you pass files to Office via protocol handlers, and you make sure that Office is invoked in a way that Office can understand.
为此,您通过协议处理程序将文件传递给Office,并确保以Office可以理解的方式调用Office。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.