You've already forked lazarus-ccr
fpspreadsheet: Finalize image and headerfooter_image demos. Update readme in other demos folder.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4547 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -19,23 +19,23 @@ const
|
||||
image3 = '../../images/components/TSCELLEDIT.png';
|
||||
|
||||
begin
|
||||
Writeln('Starting program "demo_write_headerfooter_images"...');
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
MyWorkbook.Options := [boFileStream];
|
||||
|
||||
try
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 1');
|
||||
MyWorksheet.WriteText(0, 0, 'The header of this sheet contains an image');
|
||||
MyWorksheet.Pagelayout.TopMargin := 30;
|
||||
MyWorksheet.PageLayout.HeaderMargin := 10; //25;
|
||||
MyWorksheet.PageLayout.HeaderMargin := 10;
|
||||
MyWorksheet.Pagelayout.TopMargin := 30; // the header is 20 mm high
|
||||
MyWorksheet.PageLayout.Headers[HEADER_FOOTER_INDEX_ALL] := '&CHeader with image!';
|
||||
// MyWorksheet.PageLayout.AddHeaderImage(HEADER_FOOTER_INDEX_ALL, hfsLeft, image1);
|
||||
MyWorksheet.PageLayout.AddHeaderImage(HEADER_FOOTER_INDEX_ALL, hfsLeft, image1);
|
||||
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 2');
|
||||
MyWorksheet.WriteText(0, 0, 'The footer of this sheet contains an image');
|
||||
MyWorksheet.PageLayout.Footers[HEADER_FOOTER_INDEX_ALL] := '&CFooter with image!';
|
||||
// MyWorksheet.PageLayout.AddFooterImage(HEADER_FOOTER_INDEX_ALL, hfsRight, image2);
|
||||
MyWorksheet.PageLayout.AddFooterImage(HEADER_FOOTER_INDEX_ALL, hfsRight, image2);
|
||||
|
||||
// Save the spreadsheet to a file
|
||||
// Save the spreadsheet to files
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
MyWorkbook.WriteToFile(MyDir + 'hfimg.xlsx', sfOOXML, true);
|
||||
MyWorkbook.WriteToFile(MyDir + 'hfimg.ods', sfOpenDocument, true);
|
||||
@ -44,10 +44,17 @@ begin
|
||||
// MyWorkbook.WriteToFile(MyDir + 'hfimg2.xls', sfExcel2, true);
|
||||
|
||||
if MyWorkbook.ErrorMsg <> '' then
|
||||
begin
|
||||
WriteLn(MyWorkbook.ErrorMsg);
|
||||
end;
|
||||
|
||||
WriteLn('Finished.');
|
||||
WriteLn('Please open the files "hfimg.*" in your spreadsheet program.');
|
||||
{$ifdef WINDOWS}
|
||||
WriteLn('Press ENTER to close this program...');
|
||||
ReadLn;
|
||||
{$endif}
|
||||
|
||||
finally
|
||||
MyWorkbook.Free;
|
||||
end;
|
||||
end.
|
||||
|
||||
|
@ -19,25 +19,23 @@ const
|
||||
image3 = '../../images/components/TSCELLEDIT.png';
|
||||
|
||||
begin
|
||||
Writeln('Starting program "demo_write_images"...');
|
||||
|
||||
// Create the spreadsheet
|
||||
MyWorkbook := TsWorkbook.Create;
|
||||
MyWorkbook.Options := [boFileStream];
|
||||
|
||||
try
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 1');
|
||||
MyWorksheet.DefaultRowHeight := 1.2;
|
||||
MyWorksheet.WriteText(0, 0, 'There are images in cells A3 and B3'); //
|
||||
MyWorksheet.WriteImage(2, 0, image1, 1.0, 1.0, 2.0, 2.0);
|
||||
// These images are offset by 1mm in both directions from the top/left cell edge
|
||||
MyWorksheet.WriteImage(2, 0, image1, 1.0, 1.0, 2.0, 2.0); // This image is magnified by factor 2
|
||||
MyWorksheet.WriteImage(2, 1, image2, 1.0, 1.0);
|
||||
{
|
||||
|
||||
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 2');
|
||||
MyWorksheet.WriteText(0, 0, 'There is an image in cell B3');
|
||||
MyWorksheet.WriteImage(2, 1, image3);
|
||||
// MyWorksheet.WriteImage(0, 2, 'D:\Prog_Lazarus\svn\lazarus-ccr\components\fpspreadsheet\examples\read_write\ooxmldemo\laz_open.png');
|
||||
// MyWorksheet.WriteHyperlink(0, 0, 'http://www.chip.de');
|
||||
// MyWorksheet.PageLayout.AddHeaderImage(1, hfsLeft, 'D:\Prog_Lazarus\svn\lazarus-ccr\components\fpspreadsheet\examples\read_write\ooxmldemo\laz_open.png');
|
||||
// MyWorksheet.PageLayout.Headers[1] := '<his is a header&R&G';
|
||||
}
|
||||
// Save the spreadsheet to a file
|
||||
|
||||
// Save the spreadsheet to files
|
||||
MyDir := ExtractFilePath(ParamStr(0));
|
||||
MyWorkbook.WriteToFile(MyDir + 'img.xlsx', sfOOXML, true);
|
||||
MyWorkbook.WriteToFile(MyDir + 'img.ods', sfOpenDocument, true);
|
||||
@ -46,10 +44,17 @@ begin
|
||||
// MyWorkbook.WriteToFile(MyDir + 'img2.xls', sfExcel2, true);
|
||||
|
||||
if MyWorkbook.ErrorMsg <> '' then
|
||||
begin
|
||||
WriteLn(MyWorkbook.ErrorMsg);
|
||||
end;
|
||||
|
||||
WriteLn('Finished.');
|
||||
WriteLn('Please open the files "img.*" in your spreadsheet program.');
|
||||
{$ifdef WINDOWS}
|
||||
WriteLn('Press ENTER to close this program...');
|
||||
ReadLn;
|
||||
{$ENDIF}
|
||||
|
||||
finally
|
||||
MyWorkbook.Free;
|
||||
end;
|
||||
end.
|
||||
|
||||
|
@ -21,3 +21,7 @@ This folder contains various demo applications:
|
||||
- demo_write_formatting: shows some simple cell formatting
|
||||
|
||||
- demo_write_formula: shows some rpn formulas
|
||||
|
||||
- demo_write_images: adds images to worksheets
|
||||
|
||||
- demo_write_headerfooter_images: adds images to worksheet headers and footers
|
||||
|
@ -5919,7 +5919,7 @@ function TsSpreadOpenDocWriter.WritePageLayoutAsXMLString(AStyleName: String;
|
||||
AHeaderImageStr := IfThen((hdrImg = '') or (hdrImgPos = ''), '', Format(
|
||||
'<style:background-image xlink:href="Pictures/%s" '+
|
||||
'xlink:type="simple" xlink:actuate="onLoad" '+
|
||||
'style:position="top %s" style:repeat="no-repeat" />',
|
||||
'style:position="center %s" style:repeat="no-repeat" />',
|
||||
[hdrImg, hdrImgPos] ));
|
||||
|
||||
AFooterImageStr := IfThen((ftrImg = '') or (ftrImgPos = ''), '', Format(
|
||||
|
Reference in New Issue
Block a user