Issues with grouping on Cells.NET

Guys, I’m having a scenario where I want to group things in the following way on a designer worksheet so later I can generate a PDF.


Fruit
Banana
Orange
Apple
Cars
Mazda
Honda
Toyota


What is the easiest way to accomplish this using cells and designer worksheet, whatever code I come up with it prints?

Fruit
Cars
Banana
Orange
Apple
Mazda
Honda
Toyota

Hi Felipe,

Thanks for your posting and using Aspose.Cells.

If you are using Smart Markers to populate your data, then you can use the smart marker attribute group:normal.

For example,

&=Data.Item(group:normal,skip:1) &=Data.SubItem

will populate the data in a normal group and add 1 extra row after each grouping.

The output will look like as shown in the screenshot. Please see the following code, I have attached the source.xlsx file used in this code and output xlsx file generated by it for your reference.

C#


Workbook workbook = new Workbook(“source.xlsx”);


Worksheet worksheet = workbook.Worksheets[1];


DataTable dataTable = worksheet.Cells.ExportDataTable(0, 0, 7, 2, true);

dataTable.TableName = “Data”;


WorkbookDesigner designer = new WorkbookDesigner(workbook);

designer.SetDataSource(dataTable);


designer.Process();


designer.Workbook.Save(“output.xlsx”);