Problem with ImportDataGrid

Hi,

I am very new in this forum and in Aspose.Cells also. I am trying to export data from gridview to excel using Aspose.Cells API, but it shows some error due to DataGrid and GridView. I am using ASP.NET 2.0. what is the solution for this?

Thanks in advance

Mamun

Hi,

Thanks for considering Aspose.

Well, You may import data from DataGrid using Cells.ImportDataGrid() method.

Following is my code which works fine:

DataTable dataTable = new DataTable("Products");
dataTable.Columns.Add("Product ID", typeof(Int32));
dataTable.Columns.Add("Product Name", typeof(string));
dataTable.Columns.Add("Units In Stock", typeof(Int32));

DataRow dr = dataTable.NewRow();
dr[0] = 1;
dr[1] = "Aniseed Syrup";
dr[2] = 15;
dataTable.Rows.Add(dr);

dr = dataTable.NewRow();
dr[0] = 2;
dr[1] = "Boston Crab Meat";
dr[2] = 123;
dataTable.Rows.Add(dr);

DataGrid1.DataSource = dataTable;
DataGrid1.DataBind();


Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells["A1"].PutValue("Import a DataView");
sheet.Cells["A1"].Style.Font.IsBold = true;
sheet.Cells.ImportDataGrid(DataGrid1, 1, 0, false);
sheet.AutoFitColumns();
workbook.Save("testinggrid.xls", FileFormatType.Default, SaveType.OpenInExcel, Response);

Thank you.

Thanks for your reply.

I am using asp.net 2.0 GridView. Is there is any method to export data from GridView to Excel?

Thanks

Mamun

Hi Mamun,

We will implement this feature next week. Thanks for your patience.