TXLSXImages 是透過 TXLSXWorksheet.Images 暴露的工作表圖片集合,每個 TXLSXImage 則承載圖片位元組、格式、錨定幾何、裁切、圖片調整、填滿模式、旋轉,以及可安全編輯的已匯入 DrawingML
宣告
type
TXLSXImageFillMode = (xlsxImageFillStretch, xlsxImageFillTile);
TXLSXImage = class
procedure Assign(Source: TXLSXImage);
procedure Scale(APercent: Double; AKeepAspect: Boolean = True);
procedure ClearPreservedXml;
property Row, Col: Integer;
property WidthEMU, HeightEMU: Integer;
property WidthInch, HeightInch: Double;
property WidthCM, HeightCM: Double;
property WidthPt, HeightPt: Double;
property Format: TXLSXImageFormat;
property Data: AnsiString;
property AnchorType: TXLSXAnchorEditAs;
property CropLeft, CropTop, CropRight, CropBottom: Double;
property Transparency, Brightness, Contrast: Double;
property Rotation: Double;
property AltText: WideString;
property AltTextTitle: WideString;
property FillMode: TXLSXImageFillMode;
property HasPreservedXml: Boolean;
end;
TXLSXImages = class
function Add: TXLSXImage; overload;
function Add(Source: TXLSXImage): Integer; overload;
function FindAt(ARow, ACol: Integer): TXLSXImage;
function DeleteAt(ARow, ACol: Integer): Boolean;
function DeleteInRange(ARow1, ACol1, ARow2, ACol2: Integer): Integer;
property Items[Index: Integer]: TXLSXImage; default;
end;主要成員
| Row and Col | 以 1 為基底的左上角錨定儲存格 |
| WidthEMU and HeightEMU | 以 EMU(English Metric Units)表示的原生繪圖尺寸 |
| WidthInch, WidthCM and WidthPt | 便利的幾何檢視,更新時會同步改寫底層的 EMU 尺寸 |
| AnchorType | 選擇隨儲存格移動並調整大小、僅移動,或絕對定位的繪圖行為 |
| CropLeft, CropTop, CropRight and CropBottom | 來源圖片的裁切邊界,以 0 到 100 的百分比表示 |
| Transparency | 圖片整體透明度,範圍 0 到 100 百分比 |
| Brightness and Contrast | 亮度調整,範圍 -100 到 100 百分比 |
| Rotation | 順時針的圖形旋轉角度,限制在 -360 到 360 之間 |
| AltText | 圖片的無障礙替代文字,供螢幕閱讀器與輔助工具使用 |
| AltTextTitle | 圖片的無障礙標題 |
| FillMode | 將圖片拉伸一次,或以並排方式填滿整個圖形 |
| HasPreservedXml and ClearPreservedXml | 檢視或捨棄單一圖片可安全編輯的已匯入 DrawingML |
| FindAt | 找出錨定在指定 1 起始儲存格座標上的圖片 |
範例
var Image: TXLSXImage;
begin
Image := Sheet.Images.Add;
Image.Row := 2;
Image.Col := 4;
Image.Data := PngBytes;
Image.Format := xlsxImagePng;
Image.WidthCM := 6;
Image.AnchorType := xaOneCell;
Image.CropLeft := 12.5;
Image.Transparency := 20;
Image.Brightness := 10;
Image.Contrast := -5;
Image.FillMode := xlsxImageFillStretch;
Image.Rotation := 15;
end;
另請參閱