Aspose EXCEL and Windows Form (VB.NET)


Laurence -

Hope you are well. I have been struggling the last few days in getting Aspose.Excel to work in a Windows Form enviroment. I did the sample "Hello World" file and that works with out a problem, but I can not get it to pull data from a databae and then open the file.

Any help you can give would be greatly appreciated. I followed my logic that I do for ASP.Net and still had no luck getting it to work.

Thanks in Advance -


  1. Read data from your db and save to a datatable. Then you can use Cells. ImportDataTable method.

    2. Open the file with MS Excel:
    ProcessStartInfo psi = new ProcessStartInfo(file);


About 2, VB sample:

Dim psi as ProcessStartInfo = new ProcessStartInfo(file)


But is there anyway to use a designer file in windows forms? I need to popluate a template file that I already have built. Here is the code I was trying. Its in VB.

Also - It opens my file, and then it dumps all the data (9 rows) in Cell A1:A9 . There should be a total of about 20 columns and it only puts one row of data in A1 and then the second row in A2 etc...

Dim Excel1 As Excel = New Excel


Dim BS_CMD As New SqlCommand

Dim BS_Reader As SqlDataReader

Dim BS_DS As New DataSet

BS_CMD.CommandText = "[Region_Yes_Report]"

BS_CMD.CommandType = System.Data.CommandType.StoredProcedure

BS_CMD.Connection = Me.SqlConnection1

Dim BS_DA As New SqlDataAdapter(BS_CMD)



Catch ex As Exception


End Try

Dim DT As DataTable = BS_DS.Tables(0)


Dim Sheet As Worksheet = Excel1.Worksheets(0)

Sheet.Cells.ImportDataTable(DT, True, 0, 0)

Sheet.Name = "DataDump"

Excel1.Save("C:\\TestMe.xls", SaveType.Default)

Dim Xcel_Test As ProcessStartInfo = New ProcessStartInfo("C:\\testme.xls")


''''Dim Designerfile As String = "C:\\Reports\Chain_TotalUS.xls"


''''Dim DT As DataTable = BS_DS.Tables(0)

''''Dim Sheet As Worksheet = Excel1.Worksheets(3)

''''Sheet.Cells.ImportDataTable(DT, True, 0, 0)


''''Sheet.Name = "Data"


''''Excel1.Save("C:\\TestMe.xls", SaveType.Default)

''''Dim Jack As ProcessStartInfo = New ProcessStartInfo("C:\\testme.xls")


Sure you can open a designer file in a windows form application. You can use Excel.Open method after you initiate Excel object.