ShrinkToFit

Sep 26, 2009 at 1:11 AM

Impressive work - thanks for sharing!

Could you let me know how to use the NPOI.HSSF.Record.ExtendedFormatRecord.ShrinkToFit property? I can't find any way to be able to set it or apply it to a HSSFCell or HSSFCellStyle.

Dave

Sep 26, 2009 at 6:29 PM

I found a solution, it may have other consequences that I'm not aware of as I only started studying this project yesterday!

I've had to alter the NPOI.HSSF.UserModel.HSSFCellStyle class and add the following property implementation:

public bool ShrinkToFit
{
    get
    {
        return format.ShrinkToFit;
    }
    set
    {
        // Not sure if this line is necessary
        format.IsIndentNotParentAlignment = (true);
        format.ShrinkToFit = (value);
        /* Not sure of the consequences of changing the XFType,
         * but shrink to fit only works on XF_CELL */
        format.XFType = ExtendedFormatRecord.XF_CELL;
    }
}
Coordinator
Sep 27, 2009 at 1:45 PM

HSSFCellStyle should expose ShrinkToFit to users.

Coordinator
Sep 27, 2009 at 1:46 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.