Page 1 of 1

Setting a column's charwidth isn't accurate

Posted: Fri Jul 06, 2007 12:48 pm
by robhoney
Hello,

I'm trying to produce some reports with specific column widths needed. The problem is that whenever I specify a CharWidth the end result is something a bit less than the CharWidth I specified. I've tried setting width instead (256 * charwidth) but that didn't work either.

Is there a way I can specifiy a specific CharWidth?

Regards

Rob H
(Kilclare Software)

Posted: Fri Jul 06, 2007 9:56 pm
by larsa
Hello

The character width used here is an excel character width, that not is the same as normal character width given by api functions, such as LOGFONT. You have to try until you get the width that you want.


Lars Arvidsson

Column widths

Posted: Thu Jul 12, 2007 12:12 pm
by Joe Griffin
I had this problem and found it better to use PixelWidth, so I wrote the following function:

function xlsPixelWidth(CharWidth: Double): Integer;
begin
// Returns an adjusted width for a work-around in xlsReadWrite
Result := Trunc(7 * CharWidth) + 5;
end;

Then I simply use (for example)

Columns[0].PixelWidth := xlsPixelWidth(6);

Hope that helps