转换XLS为XLSB编程方式? [英] Convert XLS to XLSB Programatically?

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

问题描述

我有一个需要XLS文件转换为XLSB客户。有没有人做到了这一点编程,(带或不带附加---没关系---只需要能够自动执行的话)?我正在寻找一种方式来自动完成这个。

I have a customer that needs to convert XLS files to XLSB. Has anyone done this programatically, (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,似乎它有一个方法来分析XLSB文件更快,更容易比XLS?我的工作,以提高我的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.

感谢。

推荐答案

好了,再有一个短格式verison:

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();

您将需要一个Excel的安装与.NET编程支持(默认情况下禁用安装!),参考MS Office的PIA组装为Excel从项目:

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:

参考:
<一href=\"http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open%28v=Office.11%29.aspx\">Workbooks.Open, <一href=\"http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.saveas%28v=VS.80%29.aspx\">workbook.SaveAs, <一href=\"http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlfileformat.aspx\">XlFileFormat.xlExcel12

这篇关于转换XLS为XLSB编程方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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