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

//将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();
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();
分类:
Office
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2009-07-27 如何控制列表视图栏位的宽度?