Upgrading to v24 from v20 - imageOrPrintOptions.IsCellAutoFit is Obsolete in v24?

Hi,

We are trying to upgrade “aspose.cells” from v20 to v24 and found that “IsCellAutoFit” property is obsolete and we have to use the “AutoFitRows/Columns(AutoFitterOptions)” function. But my question is earlier, we were simply setting the “IsCellAutoFit” to true, but now the “AutoFitterOptions” object has so many properties and we are not sure, what is the “exact equivalent” that we need to set to maintain our earlier implementation.

Below is our old code:

>  public static ImageOrPrintOptions GetImageOrPrintOptionsSettings(Worksheet sourceWorksheet)
>         {
>             ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();>           
>             imageOrPrintOptions.IsCellAutoFit = true;
>             return imageOrPrintOptions;
>         }

Here is our new code:

>  public static ImageOrPrintOptions GetImageOrPrintOptionsSettings(Worksheet sourceWorksheet)
>         {
>             ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();>           
>             //imageOrPrintOptions.IsCellAutoFit = true; // Cannot use Obsolete now,
>             AutoFitterOptions autoFitterOptions = new AutoFitterOptions(); *//How do we construct object to match with previous implemenation of "isCellAutoFit = true"?*
>              sourceWorksheet.AutoFitColumns(autoFitterOptions);
>              sourceWorksheet.AutoFitRows(autoFitterOptions);
>             return imageOrPrintOptions;
>         }

Please let us know, How do we update our new code to construct “AutoFitterOptions” object so that it matches with our existing implementation of “IsCellAutoFit = true”?

Regards,
Prathap

@PrathapSV,

You are already doing good. If you want to include merge cells to be auto-fitted as well, you may try to set relevant attribute of AutoFitterOptions:

ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();           
AutoFitterOptions autoFitterOptions = new AutoFitterOptions(); 
autoFitterOptions.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine;
sourceWorksheet.AutoFitColumns(autoFitterOptions);
sourceWorksheet.AutoFitRows(autoFitterOptions);

If you find any issue/difference kindly do provide your sample files (please zip the files prior attaching) and sample code to demonstrate the issue, we will check it soon.