以编程方式将XLS转换为XLSB? [英] Convert XLS to XLSB Programmatically?

查看:128
本文介绍了以编程方式将XLS转换为XLSB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户需要将XLS文件转换为XLSB.是否有人以编程方式完成此操作((带有或不带有附加组件-没关系--仅需要能够使其自动化)?我正在寻找一种自动化的方法.

I have a customer that needs to convert XLS files to XLSB. Has anyone done this programmatically, (with or without an add-on --- doesn't matter --- just need to be able to automate it)? I'm looking for a way to automate this.

作为旁注,客户之所以要问这个问题,是因为他们使用Sharepoint,而且似乎有一种比XLS更快,更轻松地分析XLSB文件的方法?我正在努力提高我的Sharepoint知识,但与此同时,我正在尝试找到此XLSB问题的答案.

As a side note, the customer is asking about this because they use Sharepoint, and it seems it has a way to analyze XLSB files quicker and easier than XLS? I'm working to improve my Sharepoint knowledge, but in the meantime, I'm trying to find an answer to this XLSB issue.

推荐答案

那么,还有一个简短的格式版本:

Well, then there is a short format verison:

using Microsoft.Office.Interop.Excel;

// init excel
Application excelApplication = new Application();

// ...

// open book in any format
Workbook workbook = excelApplication.Workbooks.Open("1.xls", XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

// save in XlFileFormat.xlExcel12 format which is XLSB
workbook.SaveAs("1.xlsb", XlFileFormat.xlExcel12, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

// close workbook
workbook.Close(false, Type.Missing, Type.Missing);

// ...

// shutdown excel
excelApplication.Quit();

您将需要具有.NET编程支持的Excel安装(默认情况下在安装程序中禁用!),并从您的项目中引用Excel的MS Office PIA程序集:

You will need a Excel installation with .NET programming support (disabled by default in installer!) and reference MS Office PIA assembly for Excel from your project:

参考: 工作簿.Open workbook.SaveAs 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆