读取word.ppt等

62 篇文章 0 订阅
方法一:集成OliveOffice文档处理库

将库和你的程序整合到一个APK,具体操作方法和库下载链接:http123://code.google.com/p/android-office-demo/downloads/list。

方法二:在程序中使用Intent直接打开OliveOffice支持的文件

1.        使用Intent发送指令直接打开OliveOffice支持的文件,需要在Intent中设置三类数据,分别为Intent的Action,文件的MIME Type类型,文件数据的URI。如果系统检测到没有安装OliveOffice的APK程序,则需要到www.olivephone.com/e.apk下载并安装。

2.        其中Action值设置为” com.olivephone.edit”

3.        MIME  Type值根据文件类型不同而不同,参见下表
Word03(*.doc)                application/vnd.ms-word
Word07(*.docx)                application/vnd.openxmlformats-officedocument.wordprocessingml.document
Excel03(*.xls)                        application/vnd.ms-excel
Excel07(*.xlsx)                  application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
PPT03(*.ppt)                   application/vnd.ms-powerpoint
PPT07(*.pptx)                 application/vnd.openxmlformats-officedocument.presentationml.presentation
TXT(*.txt)                                text/plain
HTML(*.html,*.htm)        text/html
MHT(*.mht)                     message/rfc822
CHM(*.chm)                    application/vnd.olivephone-chm
PDF(*.pdf)                        application/pdf
RTF(*.rtf)                                application/rtf
                                        application/x-rtf
                                        text/richtext

4.        设置文件URI,根据文件在Android文件系统中的路径创建URI,如Uri.fromFile(new File(filePath));

5.        使用代码示例(打开一个word03文件):

Intent intent = new Intent();
intent.setAction("com.olivephone.edit");
String fileMimeType = "application/vnd.ms-word";
intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/test.doc")), fileMimeType);
try{
activity.startActivity(intent);
} catch(ActivityNotFoundException e) {
        //检测到系统尚未安装OliveOffice的apk程序
        //请先到www.olivephone.com/e.apk下载并安装
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值