TXLSXImages 是由 TXLSXWorksheet.Images 暴露的工作表图像集合;每个 TXLSXImage 携带图像字节、格式、锚点几何、裁剪、图像调整、填充模式、旋转以及可安全编辑的导入 DrawingML
Declarations
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 | 以 English Metric Units(EMU)表示的原始绘图尺寸 |
| 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;
另请参阅