WinForms Example

Do you have winforms examples for the aspose.excel and is it possible to put the grid in the form ?

Scott

Dear Scott,

Thanks for your consideration.

Do you have winforms examples for the aspose.excel?

Although Aspose.Excel.Demos are written for Web forms, for Aspose.Excel itself, there is no difference to use it in Windows forms or Web forms.

Of course, we have noticed that it is not the best for you to customize Aspose.Excel.Demos either in Windows forms or Web forms as it is implemented with ADO.Net design time features which are only available in Visual Studio .Net for Web forms.

In next release, Aspose.Excel.Demos will be rewritten without ADO.Net design time support so it will be fairly esay for you to customize it either in your Windows forms or Web forms.

Thanks for your patience in advance.

is it possible to put the grid in the form?

I’m not sure what you really want to do so could you please elaborate your needs?

I need the ability to take a data table and display it in a spreadsheet with a lot of formating. The idea of have a spreadsheet template and slamming the data into it and then display and or saving it in excel is what I need to do. I like your approach and it would save me a lot of time and programming if your grid could be displayed in winforms.

Scott

Dear Scott,

Thanks for your reply.

Aspose.Excel absolutely allows you to that using Cells.ImportDataTable Method.

By the way the demos included in the latest release have been rewritten I believe it can help you out quickly. Please download it.

@sgtodd,
We recommend you to use the Worksheet.Cells.ImportDataTable as shown in the following sample code:

// Instantiating a Workbook object            
Workbook workbook = new Workbook();

// Obtaining the reference of the worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Instantiating a "Products" DataTable object
DataTable dataTable = new DataTable("Products");

// Adding columns to the DataTable object
dataTable.Columns.Add("Product ID", typeof(Int32));
dataTable.Columns.Add("Product Name", typeof(string));
dataTable.Columns.Add("Units In Stock", typeof(Int32));

// Creating an empty row in the DataTable object
DataRow dr = dataTable.NewRow();

// Adding data to the row
dr[0] = 1;
dr[1] = "Aniseed Syrup";
dr[2] = 15;

// Adding filled row to the DataTable object
dataTable.Rows.Add(dr);

// Creating another empty row in the DataTable object
dr = dataTable.NewRow();

// Adding data to the row
dr[0] = 2;
dr[1] = "Boston Crab Meat";
dr[2] = 123;

// Adding filled row to the DataTable object
dataTable.Rows.Add(dr);

// Importing the contents of DataTable to the worksheet starting from "A1" cell,
// Where true specifies that the column names of the DataTable would be added to
// The worksheet as a header row
worksheet.Cells.ImportDataTable(dataTable, true, "A1");

// Saving the Excel file
workbook.Save(dataDir + "DataImport.out.xls");

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.