ConvertVB
|
|
Imports System.IO
Imports GemBox.Spreadsheet
Module ConvertVB
Sub Main(ByVal args() As String)
' TODO: If using GemBox.Spreadsheet Professional, put your serial key below.
' Otherwise, if you are using GemBox.Spreadsheet Free, comment out the
' following line (Free version doesn't have SetLicense method).
' SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE")
If args.Length <> 2 Then
Console.Write(vbNewLine + " ConvertVB[.exe] InputFile OutputFile" + vbNewLine)
Else
Dim ef As ExcelFile = New ExcelFile
Select Case Path.GetExtension(args(0)).ToUpper()
Case ".XLS"
ef.LoadXls(args(0))
Case ".CSV"
ef.LoadCsv(args(0), CsvType.CommaDelimited)
Case ".XLSX"
ef.LoadXlsx(args(0), XlsxOptions.None)
Case Else
Throw New Exception("You must specify input file name with a valid extension (.XLS, .CSV or .XLSX).")
End Select
Select Case Path.GetExtension(args(1)).ToUpper()
Case ".XLS"
ef.SaveXls(args(1))
Case ".CSV"
ef.SaveCsv(args(1), CsvType.CommaDelimited)
Case ".XLSX"
ef.SaveXlsx(args(1))
Case Else
Throw New Exception("You must specify output file name with a valid extension (.XLS, .CSV or .XLSX).")
End Select
Console.WriteLine(vbNewLine + " " + args(0) + " converted to " + args(1))
End If
End Sub
End Module
| |
|
|
Excel VB.NET Component
|