How do I set the Print Ranges? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- alexs75 · 2016-02-12 08:59 Hi. How do I set the print area on the page? I need to do so here - https://help.libreoffice.org/Calc/Edit_Print_Ranges ---------------------------------------------------------------------- wp · 2016-02-12 09:48 Hey, you guys are doing much more with fpspreadsheet than ever was intended... Print ranges are not (yet?) implemented in fpspreadsheet. ---------------------------------------------------------------------- alexs75 · 2016-02-12 10:12 A good library. And I want to make it even better.  I will wait. ---------------------------------------------------------------------- vesyolyi · 2016-02-12 10:59 Hi, I need this function too! ---------------------------------------------------------------------- rvk · 2016-02-12 11:04 FYI. The print-range is just a text-part of the table definition. Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                      So until (or even if) this option is implemented you could unzip your .ods file and change the context.xml yourself (adding the table:print-ranges). A simple property in fpspreadsheet would, of course, be much easier ---------------------------------------------------------------------- wp · 2016-02-12 14:14 I am involved in some TAChart stuff at the moment and do not want to focus at fpspreadsheet print ranges at the moment. But if somebody could give me a hint on where the print ranges are defined in ods, xlsx and xls (!) I'd be willing to add them. Or a patch would even be better, of course... ---------------------------------------------------------------------- rvk · 2016-02-12 14:31 For the fpsopendocument.pas it's here: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TsSpreadOpenDocWriter.WriteWorksheet(AStream: TStream;  ASheetIndex: Integer);begin  FWorksheet := FWorkbook.GetWorksheetByIndex(ASheetIndex);   // Header  AppendToStream(AStream, Format(    '', [    FWorkSheet.Name, ASheetIndex+1  ]));   // columns  WriteColumns(AStream, FWorkSheet);   // rows and cells  // The cells need to be written in order, row by row, cell by cell  if (boVirtualMode in Workbook.Options) then  begin    if Assigned(Workbook.OnWriteCellData) then      WriteVirtualCells(AStream, FWorksheet)  end else    WriteRowsAndCells(AStream, FWorksheet);   // Footer  AppendToStream(AStream,    '');end;Like I showed in the previous post the print-range is an attribute of table:table. Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                     (So adding  table:print-ranges="Sheet1.A2:Sheet1.C2" to the table:table part) This is a per worksheet-setting so a PrintRange-property as string could be added where the user could put A2:C2 as range, or something. I haven't tested if the worksheet-name needs to be in there but OpenOffice does save it there. Also... in OpenOffice it's possible to define multiple ranges. Not sure yet how that is presented in the content.xml. Edit: Multiple ranges are separated by a space in the content.xml. So Ranges could be a TStringList or something. Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i I haven't dismembered xlsx yet to see where it's defined there. ---------------------------------------------------------------------- wp · 2016-02-13 17:50 In r4496, fpspreadsheet has basic support for print ranges and repeated header rows/columns for printing. Writing is implemented for xlsx and ods, no reading yet. There are the related new worksheet methods: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   type TsWorksheet = class    ...    // Print ranges    function AddPrintRange(ARow1, ACol1, ARow2, ACol2: Cardinal): Integer; overload;    function AddPrintRange(const ARange: TsCellRange): Integer; overload;    function GetPrintRange(AIndex: Integer): TsCellRange;    function NumPrintRanges: Integer;    procedure RemovePrintRange(AIndex: Integer);     procedure SetRepeatedPrintCols(AFirstCol: Cardinal; ALastCol: Cardinal = UNASSIGNED_ROW_COL_INDEX);    procedure SetRepeatedPrintRows(AFirstRow: Cardinal; ALastRow: Cardinal = UNASSIGNED_ROW_COL_INDEX);    ...  end; Note that the visual spreadsheet controls still do not support any printing, so far. [UPDATE] Now writing also to BIFF5 and BIFF8 xls formats. And reading of print ranges from ODS. ---------------------------------------------------------------------- alexs75 · 2016-02-15 08:52 for ods not work  in  content.xml: from fpspreadsheet: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i from LibreOffice5: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ---------------------------------------------------------------------- rvk · 2016-02-15 09:15 When using spaces in a tabname the tabname needs to be quoted in the print-range. Example: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ---------------------------------------------------------------------- wp · 2016-02-15 21:14 Should be fixed in the new revision which also implements reading of print ranges and repeated print cols/rows for xlsx. ---------------------------------------------------------------------- alexs75 · 2016-02-16 07:01 Work normal. Big thx. ---------------------------------------------------------------------- wp · 2016-03-04 23:47 See my note http://forum.lazarus.freepascal.org/index.php/topic,28223. msg204389.html#msg204389 for recent changes related to the print ranges.