Ungrouping all rows not working

Hi


I’m trying to ungroup anything in the spreadsheet before saving as PDF using:

ws.Cells.UngroupColumns(ws.Cells.MinColumn, ws.Cells.MaxColumn);
ws.Cells.UngroupRows(ws.Cells.MinRow, ws.Cells.MaxRow);

Attached is the spreadsheet I’m using and the resultant PDF, further down in my code I autofit the columns and you can see from the PDF the still grouped and hidden data has stretched the columns but not shown the data.

Any help appreciated.

Cheers

Simon

Hi,

Thanks for your posting and using Aspose.Cells.

Please use the Cells.ShowGroupDetail() method for your needs. Please see the following sample code and its generated output pdf for your reference. Let us know your feedback.

C#

Workbook wb = new Workbook(“grouped_example.xlsx”);

Worksheet ws = wb.Worksheets[0];

ws.Cells.ShowGroupDetail(true, 1);

int maxRow = ws.Cells.MaxRow;

ws.Cells.UngroupRows(0, maxRow);

PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;

wb.Save(“output.pdf”, opts);

Hi


Thanks. That worked for the original file I attached but doesn’t work for the file I had to run it on, I’ve managed to remove all sensitive information from the file and still replicate the issue.

So if you see the test.zip attachment that has a file in that the above doesn’t seem to work for.

Thanks

Simon

Hi,

Thanks for your feedback and using Aspose.Cells.

You need to adjust the index of Cells.ShowGroupDetail(true, index) method. When I used index 4, it worked fine. I have attached the output pdf generated with this code for a reference.

Please try the following code. I have highlighted the changes in red color.

C#

Workbook wb = new Workbook(“test.xlsx”);

Worksheet ws = wb.Worksheets[0];

ws.Cells.ShowGroupDetail(true, 4);

int maxRow = ws.Cells.MaxRow;

ws.Cells.UngroupRows(0, maxRow);

PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;

wb.Save(“output.pdf”, opts);