Free Support Forum - aspose.com

AutoFitRows UnHides hidden rows

Good day


When I hide rows with:

Aspose.Cells.Worksheet ws = wb.Worksheets[0];

ws.Cells.HideRow(iC);

and export via:

Aspose.Cells.Rendering.ImageOrPrintOptions iopo = new Aspose.Cells.Rendering.ImageOrPrintOptions();

Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(ws, iopo);

the export is fine, with the hidden row not shown.

But if I autofit the rows with:

Aspose.Cells.AutoFitterOptions autofit = new Aspose.Cells.AutoFitterOptions(); autofit.AutoFitMergedCells = true; ws.AutoFitRows(autofit);


before the export, the hidden rows are shown again.

The AutoFit resets the visible setting on the rows.

Hi,


Please try the below source code for your scenario. Also attached to my reply is the input and output files for your reference. Feel free to write back. Thank you

C# Sample Code:

Workbook book = new Workbook(“C:\temp\book1.xlsx”);

Worksheet sheet = book.Worksheets[0];

sheet.Cells.HideRow(1);

AutoFitterOptions options = new AutoFitterOptions();

options.AutoFitMergedCells = true;

options.IgnoreHidden = true;

sheet.AutoFitRows(options);

book.Save(“C:\temp\out.xlsx”);

Perfect, thanks.