Procedure TXLSWorksheet.AutoWidthCol calculates column width using function TCanvas.TextWidth.
This function works for single lines only.
I suggest the next improvement for function TXLSWorksheet.AutoWidthCol:
Code: Select all
var
tw: integer;
r: TRect;
begin
.......
S := GetAsFmtString(ACol,FCells.IterCellRow);
if XF.Alignment.IsWrapText then
begin
ZeroMemory(@r, SizeOf(r));
DrawTextEx(Canvas.Handle, PChar(S), -1, r, DT_CALCRECT, nil);
if XF.Alignment.Rotation in [90,180,255] then // Vertical
tw := r.Height
else
tw := r.Width;
end
else
begin
if XF.Alignment.Rotation in [90,180,255] then // Vertical
tw := Canvas.TextHeight(S)
else
tw := Canvas.TextWidth(S);
end;
W := tw + TM.tmAveCharWidth + 5;
When XF.Alignment.Rotation = 255 even improved functions works pretty bad.
Ragards
Moisha.