Recent

Author Topic: fpspreadsheetgrid - Printing  (Read 3607 times)

seghele0

  • Full Member
  • ***
  • Posts: 173
fpspreadsheetgrid - Printing
« on: November 26, 2021, 01:48:35 pm »
Lazarus 2.0.10 + Windows 11.

Would like to print the 'sWorksheetGrid'.
The content of the 'xlsx' file has several pages.
Can someone help me with the necessary code?

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   Printers, PrintersDlgs,
  10.   fpstypes, fpspreadsheetctrls,fpspreadsheetgrid, fpsopendocument,
  11.   fpsutils, fpspreadsheet, fpsallformats;
  12. type
  13.   { TForm1 }
  14.   TForm1 = class(TForm)
  15.      ButtonLOADXLSX: TButton;
  16.      Button2: TButton;
  17.      ButtonPrintGO: TButton;
  18.      PrintDialog1: TPrintDialog;
  19.      sWorksheetGrid1: TsWorksheetGrid;
  20.      procedure ButtonLOADXLSXClick(Sender: TObject);
  21.      procedure Button2Click(Sender: TObject);
  22.      procedure ButtonPrintGOClick(Sender: TObject);
  23.   private
  24.     var Nameworksheet : String;
  25.   public
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.   MyDir : String;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. { TForm1 }
  37. procedure TForm1.Button2Click(Sender: TObject);
  38. begin
  39.   Close;
  40. end;
  41.  
  42. procedure TForm1.ButtonLOADXLSXClick(Sender: TObject);
  43. begin
  44.   Nameworksheet:= '1.xlsx';
  45.   sWorksheetGrid1.LoadFromSpreadsheetFile(Nameworksheet);
  46. end;
  47.  
  48. procedure TForm1.ButtonPrintGOClick(Sender: TObject);
  49. begin
  50.   if PrintDialog1.Execute then
  51.   begin
  52.     // ????????
  53.   end;
  54. end;
  55. end.                          

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: fpspreadsheetgrid - Printing
« Reply #1 on: November 26, 2021, 02:11:33 pm »
Printing of a worksheet is not supported by fpspreadsheet directly. Of course, you can print it like you would print a stringgrid (e. g. https://www.swissdelphicenter.ch/en/showcode.php?id=769). But note that this does not handle the special cases of all the cell formats, merged cells, embedded images, headers, footers, etc.

seghele0

  • Full Member
  • ***
  • Posts: 173
Re: fpspreadsheetgrid - Printing
« Reply #2 on: November 26, 2021, 02:31:58 pm »
I'll try it.
Thanks.

 

TinyPortal © 2005-2018