本文以C#及VB.NET代码为例展示如何将Excel工作簿转换为OFD和UOS格式。通过workbook.LoadFromFile(string fileName)方法加载Excel源文档后,然后调用方法workbook.SaveToFile(string fileName, FileFormat fileFormat)转换为目标文件格式即可。具体步骤和方法参考如下内容。
1. 程序环境
-
Visual Studio 2017
-
.net framework 4.6.1
-
Excel库:Spire.XLS for .NET
-
Excel测试文档:2013版(.xlsx格式)
2. 代码示例
2.1 Excel转OFD
C#
using Spire.Xls; namespace ExcelToOFD { class Program { static void Main(string[] args) { Workbook workbook = new Workbook(); workbook.LoadFromFile("test.xlsx"); workbook.SaveToFile("ToOFD.ofd", FileFormat.OFD); } } }
VB.NET
Imports Spire.Xls Namespace ExcelToOFD Class Program Private Shared Sub Main(args As String()) Dim workbook As New Workbook() workbook.LoadFromFile("test.xlsx") workbook.SaveToFile("ToOFD.ofd", FileFormat.OFD) End Sub End Class End Namespace
2.2 Excel转UOS
C#
using Spire.Xls; namespace ExcelToUOS { class Program { static void Main(string[] args) { Workbook workbook = new Workbook(); workbook.LoadFromFile("test.xlsx"); workbook.SaveToFile("ToUOS", FileFormat.UOS); } } }
VB.NET
Imports Spire.Xls Namespace ExcelToUOS Class Program Private Shared Sub Main(args As String()) Dim workbook As New Workbook() workbook.LoadFromFile("test.xlsx") workbook.SaveToFile("ToUOS", FileFormat.UOS) End Sub End Class End Namespace
—End—