Recent

Author Topic: fpspreadsheet and GridPrinter  (Read 371 times)

morknot

  • Jr. Member
  • **
  • Posts: 55
  • still learning
fpspreadsheet and GridPrinter
« on: September 07, 2025, 01:56:48 pm »
Making almost exclusive use of #wp's code, I have written an app which formats, displays and prints a worksheetgrid in landscape orientation without row numbering. There are many merged cells which print correctly and when the grid is saved as an xlsx file, it opens correctly in Excel (2007).

I came across #wp's GridPrinter component, the latest version that includes fpspreadsheetprintadapter, and thought I would try using it to cut out some of the coding.

When opened in #wp's gridprinter/examples/fpspreadsheet, my worksheetgrid also opens correctly. However when a Preview is generated, all the merged cell formatting is lost on all the pages that are created. I have not done a printout yet.

From a previous post I read that Gridprinter is designed to print on multiple pages. I'm guessing that the merged cell issue is due to my worksheet being designed to print on one A4 sheet of paper with narrow margins that are less than half the width/height of the Preview's.

Could this be the reason?

wp

  • Hero Member
  • *****
  • Posts: 13194
Re: fpspreadsheet and GridPrinter
« Reply #1 on: September 07, 2025, 02:18:01 pm »
You are saying that your spreadsheet prints correctly with your own event handlers attached to the gridprinter, but when you use the SpreadsheetPrintAdapter the merged cells are split? In this case the printer adapter would miss a detail somewhere...

It would help me if you'd post a sample project together with a spreadsheet file showing the issue.

morknot

  • Jr. Member
  • **
  • Posts: 55
  • still learning
Re: fpspreadsheet and GridPrinter
« Reply #2 on: September 07, 2025, 05:07:21 pm »
Thank you for your reply wp.

Sorry, I didn't explain myself very well. The successful format and printout project is derived from your 'printworksheet.zip' on forum posting https://forum.lazarus.freepascal.org/index.php/topic,42133.msg293487.html#msg293487, back in 2018, a long time ago! Your GridPrinter component was not used in my project.

Yes, when opening my spreadsheet file in your fpspreadsheet_demo project, all the merged cells are split back to the default column width. I haven't actually written a project using GridPrinter yet.

I have attached my spreadsheet file, test99.xlsx. If want to see the code that generated it, please let me know.

Ah!! It seems I cannot attach xlsx files. I have changed the extension to xml and hopefully you can change is back xlsx for it to work.

wp

  • Hero Member
  • *****
  • Posts: 13194
Re: fpspreadsheet and GridPrinter
« Reply #3 on: September 07, 2025, 08:07:34 pm »
Thanks for the sample file. I see the issue: Merging of cells is a concept unknown to TGridPrinter and thus not supported. Let me see if maybe a class can be derived from it which closer cooperates with TsWorksheetGrid.

 

TinyPortal © 2005-2018