Hi all. This is my first post, so I'm kind of excited. I'm a 1-year VB.Net newbie, still trying to finish my first win app for my employer, which is patiently waiting. I'm using Visual Studio 2005 and 2.0 .Net framework. I'll eventually have a windows application for bunny suit users to enter fab data that can be saved onto a datamart server, then a Process Engineer can retrieve the data to transfer and crunch the numbers using Jump or another statistical package. But right now, my scenario is practicing with the Northwind.mdf. My main form includes a DataGridView, EXTRACT button, and a 3rd-party module (from Gemboxsoftware) that's supposed to export the DataGridView data into a generated CSV/XLS file. When I run my win app, and select the EXTRACT button, nothing happens. But I'm pretty sure I just have the syntax wrong or need more code: I'm trying to invoke (call) the module *ConvertVB* from within the Click event handler code for the Extract button.
From my main win app, here's the Extract button click event handler:
Private Sub btnExtractAKTDryETCH_Click(ByVal sender As System.Object, ByVal e As _
' NOTE: Added these Imports at top of code:
' Imports System.Drawing
' Imports System.IO
' Imports System.Data
' Imports System.Text
' Imports GemBox.Spreadsheet
System.EventArgs) Handles btnExtractAKTDryETCH.Click
'When EXTRACT button is clicked, call the *Module ConvertVB* to export _
'the DataGridView data into a generated .xls/.csv file
Dim ConvertVB As New ExcelFile
End Sub
From the referenced Gemboxsoftware module, here's the *ConvertVB* Sub Main code:
' NOTE: Added these Imports at top of code:
' Imports System.IO
' Imports GemBox.Spreadsheet
Module ConvertVB
' Module code is from Gembox.Spreadsheet 3.3
' [url]http://www.gemboxsoftware.com/GBSpreadsheet.htm[/url]
Sub Main(ByVal args() As String)
If args.Length <> 2 Then
Console.Write(vbNewLine + " ConvertVB[.exe] InputFile OutputFile" + vbNewLine)
Else
Dim ef As GemBox.Spreadsheet.ExcelFile = New GemBox.Spreadsheet.ExcelFile
Select Case Path.GetExtension(args(0)).ToUpper()
Case ".XLS"
ef.LoadXls(args(0))
Case ".CSV"
ef.LoadCsv(args(0), GemBox.Spreadsheet.CsvType.CommaDelimited)
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), GemBox.Spreadsheet.CsvType.CommaDelimited)
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