0

#officewriter - Worksheet.PopulatedCells.AutoFitHeight(); not working.

Recently i have updated excel version from xls to xlsx, but now the above function is not working, giving below error.

Error : No cells have been populated in the Worksheet

Ramesh
  • 1

1 Answers1

0

Populated cells will look for cells with values in them and return an area that includes all the cells. If populated cells have no values then it will thrown an exception, however if that is the case there is nothing to autoFit.

One way to work around this would be to define the area to autofit (say the whole worksheet) and then call autofit. Then you don't have to rely on populated cells to determine the area.

Sam Plus Plus
  • 4,381
  • 2
  • 21
  • 43