Excel读写方案XLSReadWriteII使用技巧总结

XLSReadWriteII是一个读写Excel的组件。他的一般已用只要按照Demo操作基本都能实现,只要不是非常复杂的应用,XLSReadWriteII还是能够胜任的。

最近被派了一个写入图库的应用,图库是Gallery2图库,本身支持自定义字段功能,原始文件是一个排版完整的Excel表格,程序的目标是读取Excel表格的文字图片信息,写入Gallery2或者是生成一个SQL语句,直接插入到Gallery2的MySQL数据库。只要把自定义的信息和图片名称对应起来就好。

XLSReadWriteII使用MSOPictures来存储图片对象,使用Sheet.DrawingObjects.Pictures来对图片布局,因此就有可能存在这样的情况,DrawingObjects.Count和MSOPictures.Count不相等。

这是因为Sheet.DrawingObjects.Pictures对象存储的只是对DrawingObjects的一个引用。因此需要解决的问题是:已知行号和列号,如何在得到图片在MSOPictures中的索引或者对应值。

Function GetID(row: integer): integer;
var
i: integer;
begin
result := 0;
for i := 0 to XLSReadWriteII21.Sheet[sheet].DrawingObjects.Pictures.Count – 1 do
begin
if XLSReadWriteII21.Sheet[sheet].DrawingObjects.Pictures[i].Row1 = row then
result := XLSReadWriteII21.Sheet[sheet].DrawingObjects.Pictures[i].PictureId;
end;
end;

转自: https://blog.csdn.net/zengcong2013/article/details/18714493

http://www.axolot.com/BB3/viewforum.php?f=9&sid=c7c940e6e3b9bfd05aed4c6d06ae485f

原文地址:https://www.cnblogs.com/railgunman/p/10596502.html