Page 1 of 1

Problem "ShrinkToFit" with a column

Posted: Mon Dec 07, 2015 10:23 am
by Noemie
Hi everybody,

We are using TXLSReadWriteII5 component to extract data to xlsx universal format.

I got a problem with the "ShrinkToFit" procedure for a column property. This returns an exception and wont work. I use it successfully with a row.

Here is a mini-sample where I reproduced the error :

Code: Select all

Try
        XLSReadWriteII51.Clear(1);

        //Create the empty file
        XLSReadWriteII51.Filename:=MyFileName;
        XLSReadWriteII51.Write;

        XLSReadWriteII51[0].Name:='EXPORT';

        XLSReadWriteII51[0].AsString[0,0]:='TEST SHRINK_TO_FIT';
        XLSReadWriteII51[0].Cell[0,0].Rotation:=90;

        //This line works correctly
        XLSReadWriteII51[0].Rows[0].ShrinkToFit:=True;

        //This line returns the following exception :
        {Le projet Project1.exe a provoqué une classe d'exception EAccessViolation
         avec le message 'Violation d'accès à l'adresse 006A1890 dans le module
         'Project1.exe'. Lecture de l'adresse 0000001C'.
         Processus stoppé. Utilisez Pas-à-pas ou Exécuter pour continuer.
        }
        XLSReadWriteII51[0].Columns[0].ShrinkToFit:=True;
        XLSReadWriteII51.Write;
Except
End;
Do I have to change something to make it work?
Does anything else exist to make the columns width fit the content?

Thanks a lot.

Noémie

Re: Problem "ShrinkToFit" with a column

Posted: Wed Dec 09, 2015 7:47 am
by Noemie
For those who might be insterrested. I solved my problem with this function :

Code: Select all

XLSReadWriteII51[0].AutoWidthCol(Col_);
Cheers

Noémie