Recent

Author Topic: [SOLVED] FrozenRow/Col in TsWorksheet  (Read 1142 times)

totya

  • Hero Member
  • *****
  • Posts: 720
[SOLVED] FrozenRow/Col in TsWorksheet
« on: February 13, 2023, 12:25:45 pm »
Hi!

As I see sWorksheetGrid support the FrozenRow/Col. Mean these lines/cols do not move when user scrolls.

I'd like if the TsWorksheet support it too (mainly Excel).

Thank you!

« Last Edit: February 13, 2023, 01:50:48 pm by totya »

wp

  • Hero Member
  • *****
  • Posts: 12030
Re: FrozenRow/Col in TsWorksheet
« Reply #1 on: February 13, 2023, 01:25:29 pm »
Code: Pascal  [Select][+][-]
  1. program demo_frozen_rows_cols;
  2. uses
  3.   SysUtils,
  4.   FPSpreadsheet, fpsTypes, xlsxOOXML;
  5. var
  6.   wb: TsWorkbook;
  7.   ws: TsWorksheet;
  8.   r, c: Integer;
  9. begin
  10.   wb := TsWorkbook.Create;
  11.   try
  12.     ws := wb.AddWorksheet('Sheet1');
  13.  
  14.     // Fill worksheet with some data
  15.     for r := 0 to 100 do
  16.       for c := 0 to 10 do
  17.         ws.WriteText(r, c, Format('R%d C%d', [r, c]));
  18.  
  19.     // Prepare frozen columns and frozen rows
  20.     ws.LeftPaneWidth := 1;  // There should be 1 frozen column
  21.     ws.TopPaneHeight := 2;  // There should be 2 frozen rows
  22.     ws.Options := ws.Options + [soHasFrozenPanes];  // Activate this feature.
  23.  
  24.     // Save to file
  25.     wb.WriteToFile('test.xlsx', true);
  26.   finally
  27.     wb.Free;
  28.   end;
  29. end.

totya

  • Hero Member
  • *****
  • Posts: 720
Re: FrozenRow/Col in TsWorksheet
« Reply #2 on: February 13, 2023, 01:50:20 pm »
@wp Thank you for the answer, and for this sample demo! I tried it, it's working. :)

majid.ebru

  • Hero Member
  • *****
  • Posts: 508
Re: FrozenRow/Col in TsWorksheet
« Reply #3 on: January 03, 2024, 01:01:20 pm »
Code: Pascal  [Select][+][-]
  1. program demo_frozen_rows_cols;
  2. uses
  3.   SysUtils,
  4.   FPSpreadsheet, fpsTypes, xlsxOOXML;
  5. var
  6.   wb: TsWorkbook;
  7.   ws: TsWorksheet;
  8.   r, c: Integer;
  9. begin
  10.   wb := TsWorkbook.Create;
  11.   try
  12.     ws := wb.AddWorksheet('Sheet1');
  13.  
  14.     // Fill worksheet with some data
  15.     for r := 0 to 100 do
  16.       for c := 0 to 10 do
  17.         ws.WriteText(r, c, Format('R%d C%d', [r, c]));
  18.  
  19.     // Prepare frozen columns and frozen rows
  20.     ws.LeftPaneWidth := 1;  // There should be 1 frozen column
  21.     ws.TopPaneHeight := 2;  // There should be 2 frozen rows
  22.     ws.Options := ws.Options + [soHasFrozenPanes];  // Activate this feature.
  23.  
  24.     // Save to file
  25.     wb.WriteToFile('test.xlsx', true);
  26.   finally
  27.     wb.Free;
  28.   end;
  29. end.

@ws Thank you

 

TinyPortal © 2005-2018