XLSReadWriteII4: Add same picture in multiple sheets
XLSReadWriteII4: Add same picture in multiple sheets
Hi Lars,
I am facing a problem while adding same picture in multiple sheets. The picture is displayed only in first sheet, and next sheet onwards it is not displayed. What might be the reason? Is it possible to add same picture in multiple sheets? My source code is given below.
XLS.MSOPictures.Add.Filename := 'C:\ODF_Logo.PNG';
with XLS.Sheets[0].DrawingObjects.Pictures.Add do begin
PictureName := XLS.MSOPictures[0].Filename;
Col1 := seColumn.Value;
Row1 := seRow.Value;
Col2 := seColumn.Value + 3;
Row2 := seRow.Value + 8;
end;
with XLS.Sheets[1].DrawingObjects.Pictures.Add do begin
PictureName := XLS.MSOPictures[0].Filename;
Col1 := seColumn.Value;
Row1 := seRow.Value;
Col2 := seColumn.Value + 3;
Row2 := seRow.Value + 8;
end;
Please reply...........
I am facing a problem while adding same picture in multiple sheets. The picture is displayed only in first sheet, and next sheet onwards it is not displayed. What might be the reason? Is it possible to add same picture in multiple sheets? My source code is given below.
XLS.MSOPictures.Add.Filename := 'C:\ODF_Logo.PNG';
with XLS.Sheets[0].DrawingObjects.Pictures.Add do begin
PictureName := XLS.MSOPictures[0].Filename;
Col1 := seColumn.Value;
Row1 := seRow.Value;
Col2 := seColumn.Value + 3;
Row2 := seRow.Value + 8;
end;
with XLS.Sheets[1].DrawingObjects.Pictures.Add do begin
PictureName := XLS.MSOPictures[0].Filename;
Col1 := seColumn.Value;
Row1 := seRow.Value;
Col2 := seColumn.Value + 3;
Row2 := seRow.Value + 8;
end;
Please reply...........
Re: XLSReadWriteII4: Add same picture in multiple sheets
Dear All,
Somebody please help me by answering to above question. Its seems production support of Axolot is not good. It seems I made a bad decision by purchasing XLSReadWriteII4.
Somebody please help me by answering to above question. Its seems production support of Axolot is not good. It seems I made a bad decision by purchasing XLSReadWriteII4.
Re: XLSReadWriteII4: Add same picture in multiple sheets
Don't know if this is still any use to you, but: the trick is to give the picture a different name for each sheet. You may wish to use a timestamp, or simply add a serial number; personally, I just add the sheet number to the filename.
-
- Posts: 8
- Joined: Sun Jun 20, 2004 1:40 pm
- Location: New Zealand
- Contact:
Re: XLSReadWriteII4: Add same picture in multiple sheets
Changing the PictureName didn't work for me (it gave an error that the name was invalid).
However, I managed to work around the problem by using LoadFromFile for the TMSOPicture and then setting PictureId of the TDrwPicture, instead of setting the PictureName. To value of PictureId needs to be the same as TMSOPicture.Count *after* the TMSOPicture has been added (ie. index+1).
I hope this helps!
However, I managed to work around the problem by using LoadFromFile for the TMSOPicture and then setting PictureId of the TDrwPicture, instead of setting the PictureName. To value of PictureId needs to be the same as TMSOPicture.Count *after* the TMSOPicture has been added (ie. index+1).
I hope this helps!
Re: XLSReadWriteII4: Add same picture in multiple sheets
I beg your pardon: perhaps I wasn't terribly clear in my earlier post. I recommended changing, not PictureName, but the picture's filename. This multiplies the number of picture files, of course; but these renamed files will normally be in a temp directory, or can be controlled programmatically.
-
- Posts: 8
- Joined: Sun Jun 20, 2004 1:40 pm
- Location: New Zealand
- Contact:
Re: XLSReadWriteII4: Add same picture in multiple sheets
I understand. In my case they are logo files, which are stored in one place only - so having multiple copies of the files doesn't work in this case.
Re: XLSReadWriteII4: Add same picture in multiple sheets
I need help with this as well. And I see there is no answer yet.
-
- Posts: 8
- Joined: Sun Jun 20, 2004 1:40 pm
- Location: New Zealand
- Contact:
Re: XLSReadWriteII4: Add same picture in multiple sheets
Here's my work-around (with all error handling and other non-essential lines removed). Development was in C++Builder, but hopefully people can convert to Delphi, if required.
Code: Select all
TXLSReadWriteII4* xls = new TXLSReadWriteII4(NULL);
xls->Filename = fn;
xls->Version = xvExcel97;
if(!xls->Sheets->Count)
xls->Sheets->Add();
TSheet* xlSht = xls->Sheets->Items[0];
TMSOPicture* msoPict = xls->MSOPictures->Add();
int picID = xls->MSOPictures->Count;
msoPict->LoadFromFile(ExtractFilePath(Application->ExeName) + "logo.jpg");
TDrwPicture* drwPict = xlSht->DrawingObjects->Pictures->Add();
drwPict->PictureId = picID;
drwPict->Col1 = 1;
drwPict->Row1 = 1;
drwPict->Col1Offset = 0.08;
drwPict->Row1Offset = 0.05;
drwPict->Col2 = 1;
drwPict->Row2 = 2;
drwPict->Col2Offset = 0.92;
drwPict->Row2Offset = 0.95;
xls->Write();
Re: XLSReadWriteII4: Add same picture in multiple sheets
Now if some one can convert that to Either Delphi code or Visual Basic code....
Re: XLSReadWriteII4: Add same picture in multiple sheets
I deleted the VB code since I can not verify it's workability, but one could easily create a VB Code from the Delphi code a lot easier then from the C++ code;
After using the online C++ to VB converter, it was easier to convert to Delphi from the VB code.
http://converter.telerik.com <------ tries to convert C++ to VB and vice-versa.
After using the online C++ to VB converter, it was easier to convert to Delphi from the VB code.
http://converter.telerik.com <------ tries to convert C++ to VB and vice-versa.
Last edited by Mojoala on Thu Jan 24, 2013 10:01 pm, edited 3 times in total.
Re: XLSReadWriteII4: Add same picture in multiple sheets
Hello
Did your VB code run well?
Did your VB code run well?
Lars Arvidsson, Axolot Data
Re: XLSReadWriteII4: Add same picture in multiple sheets
And here is the Delphi Code
FYI: Logo is a Global function elsewhere which returns the entire path and file name
FYI: Logo is a Global function elsewhere which returns the entire path and file name
Code: Select all
procedure LoadTheLogoNew(var aXLS: TXLSReadWriteII4; c1, r1, c2, r2, ts : Integer);
var xlSht : TSheet;
msoPict : TMSOPicture;
picID : integer;
drwPict : TDrwPicture;
begin
if UpperCase(ExtractFileExt(Logo)) = '.BMP' then
begin
if FileSizeFromFileName(Logo) >= 32000 then Exit;
end;
aXLS.Filename := Logo;
xlSht := axls.Sheets.Items[ts];
msoPict := aXLS.MSOPictures.Add;
msoPict.LoadFromFile(Logo);
drwPict := xlSht.DrawingObjects.Pictures.Add;
drwPict.PictureId := ts + 1;
drwPict.Col1 := c1;
drwPict.Row1 := r1;
drwPict.Col1Offset := 0.08
drwPict.Row1Offset := 0.05
drwPict.Col2 := c2;
drwPict.Row2 := r2;
drwPict.Col2Offset := 0.92
drwPict.Row2Offset := 0.95
end;
Last edited by Mojoala on Thu Jan 24, 2013 10:54 pm, edited 1 time in total.
Re: XLSReadWriteII4: Add same picture in multiple sheets
I did not try the VB code. It was from an online translator.
Now the Delphi Code does work and I will be using it.
thanks!
Now the Delphi Code does work and I will be using it.
thanks!
Last edited by Mojoala on Thu Jan 24, 2013 9:59 pm, edited 1 time in total.
-
- Posts: 8
- Joined: Sun Jun 20, 2004 1:40 pm
- Location: New Zealand
- Contact:
Re: XLSReadWriteII4: Add same picture in multiple sheets
Yes, the C++ code did exactly what I needed it to do.