Export grid view data to excel

Hi,

We tried to export excel with grid view data (cell colored) in .Net. When we export to excel we are not getting the expected grid view with color result.

(We tried the "ImportGridView() with ImportTableOptions" to set color.)

Note: Here we have attached project files and image file.

Thanks

Renga

Hi,


Thanks for your posting and using Aspose.Cells.

MS-Excel has its own table styles, please use one of them. Aspose.Cells just imports data from grid view and not its formatting.

Please check the following sample code, its comments, sample excel file, output excel file as well as screenshot for your reference.


C#
//Load your source excel file

Workbook wb = new Workbook("sample.xlsx");

//Access first worksheet

Worksheet ws = wb.Worksheets[0];

//Add list object

ws.ListObjects.Add("A1", "D6", true);

//Access your list object

ListObject lo = ws.ListObjects[0];

lo.TableStyleType = TableStyleType.TableStyleMedium9;

//If you want table not just formatting then comment this line

lo.ConvertToRange();

//Save the workbook

wb.Save("output.xlsx");

Hi Shakeel Faiz,


Thanks for your assistance. We have to check.

Thanks.
Renga