Recent

Author Topic: How to clear/reset a worksheet?  (Read 1538 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
How to clear/reset a worksheet?
« on: October 24, 2020, 09:52:24 pm »
I need to clear the content and its format, but not delete the worksheet.
I use this:
Code: Pascal  [Select][+][-]
  1. myWSheet := wbs.Workbook.GetFirstWorksheet;
  2. ...
  3. myWSheet .Clear;
  4.  
But the height and width remain.

wp

  • Hero Member
  • *****
  • Posts: 11833
Re: How to clear/reset a worksheet?
« Reply #1 on: October 27, 2020, 10:30:23 am »
The worksheet of FPSpreadsheet is quasi-infinte, this means there is no such property as ColCount or RowCount that you may know from the string grid. (Of course, the practical limit is the largest value of the cardinal data type used for the row and column indices, and even tighter limits come into play when worksheets are written to file.) So, when you clear the worksheet, only the cells and their formats are removed.

When you display the worksheet in a TsWorksheetGrid, however, you have access to the AutoExpand property of the grid which gives you some control on how many rows and columns are displayed -- see my response to your other question (https://forum.lazarus.freepascal.org/index.php/topic,51918.msg381840.html).

 

TinyPortal © 2005-2018