Recent

Author Topic: [SOLVED] Headers and PageBreak simultaneously  (Read 1248 times)

rca

  • Full Member
  • ***
  • Posts: 121
[SOLVED] Headers and PageBreak simultaneously
« on: July 26, 2025, 06:42:41 am »
I'm attaching a simple example of PageLayout.Headers with AddPageBreakToRow.

Basically, what I'm doing is:
Code: Pascal  [Select][+][-]
  1.   MyDir := ExtractFilePath(ParamStr(0));
  2.  
  3.   sWorksheetGrid1.Worksheet.PageLayout.HeaderMargin := 10;
  4.   sWorksheetGrid1.Worksheet.Pagelayout.TopMargin := 30;
  5.   sWorksheetGrid1.Worksheet.PageLayout.Headers[HEADER_FOOTER_INDEX_ALL] := '&CHeader test';
  6.  
  7.   sWorksheetGrid1.Cells[1,1] := 'Page 1';
  8.   sWorksheetGrid1.Cells[1,2] := 'Page 2';
  9.  
  10.   sWorksheetGrid1.Worksheet.AddPageBreakToRow(1);
  11.  
  12.   sWorksheetGrid1.Workbook.WriteToFile(MyDir + 'headertest.xlsx', sfOOXML, true);  
  13.  

After saving the "headertest.xlsx" file, when I try to open it with Excel, I get an error message about the file contents...

If I use AddPageBreakToRow or PageLayout.Headers separately, they work, but not simultaneously.

I appreciate any help you can give me.
« Last Edit: July 26, 2025, 01:59:16 pm by rca »

wp

  • Hero Member
  • *****
  • Posts: 13417
Re: Headers and PageBreak simultaneously
« Reply #1 on: July 26, 2025, 11:08:14 am »
It seems that the <rowBreaks> node must be after the <headerFooter> node in the xml file of the xlsx. Only Microsoft knows why...

Please update your FPSpreadsheet from the svn repository.

rca

  • Full Member
  • ***
  • Posts: 121
Re: [SOLVED] Headers and PageBreak simultaneously
« Reply #2 on: July 26, 2025, 01:59:38 pm »
@wp

I updated to the latest version and it works fine now.

Thank you so much for your help. Excellent work!

 

TinyPortal © 2005-2018