将excel2003转换为excel2007格式

本文介绍如何在SharePoint2010中将Excel2003文档转换为Excel2007格式,以便支持Web应用程序直接在浏览器中打开和查看。提供了具体的代码实现。

在sharepoint 2010 中,excel2007或excel 2010文档格式,支持web app 应用,能够在浏览器在线打开,查看,但excel 2003格式的文档只能用office客户端打开,为了让上传的文档能够直接支持web app,只能将上传的excel 2003文档转换成excel 2007 文档再上传。文档转换的code如下:

 

ExpandedBlockStart.gif代码
  //将excel2003转换成excel2007
                  MSExcel.Application excelApp = null;//提要   //word应用程序
                    MSExcel._Workbook excelDoc = null;    //word文档
                    Object nothing = Missing.Value;
                 excelApp 
= new MSExcel.ApplicationClass();

                 
string sourcePath = @"c:\excel2003.xls";      //原文件路径
                 excelDoc = excelApp.Workbooks.Open(sourcePath, nothing,
                         nothing, nothing, nothing, nothing,
                         nothing, nothing, nothing, nothing,
                         nothing, nothing, nothing, nothing,
                         nothing);
                   
                 
string targetPath =@"c:\excel2007.xlsx";//导出路径
                 object format = MSExcel.XlFileFormat.xlWorkbookDefault;//转换成新的格式

                    
//将新的exccel2007存到本地
                    excelApp.DisplayAlerts = false;//文档转换过程不要出现提示框
                    excelDoc.SaveAs(targetPath, format, nothing, nothing, nothing, nothing, MSExcel.XlSaveAsAccessMode.xlNoChange,
                               nothing, nothing, nothing, nothing, nothing);
                    excelDoc.Close(nothing, nothing, nothing);
                    excelApp.Quit();

 

 

转载于:https://www.cnblogs.com/chendianhong/archive/2010/07/27/1785843.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值