RemoveEmptyWorksheets lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- totya · 2016-12-31 20:50 Hi! Simple procedure... 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 RemoveEmptyWorksheets (const Workbook: TSWorkbook);var  ws: integer;  cell: PCell;  DataFound: boolean;begin  for ws:= Workbook.GetWorksheetCount-1 downto 0 do  begin    DataFound:= false;     for cell in Workbook.GetWorksheetByIndex(ws).Cells do    begin      if not(cell^.ContentType = (cctEmpty)) then      begin      DataFound:= true;        break;      end;    end;     if not(DataFound) then      if Workbook.GetWorksheetCount > 1 then      Workbook.RemoveWorksheet(Workbook.GetWorksheetByIndex(ws));  end;end; ps.: In Spready empty Cellvalues ContentType sometimes "cctEmpty", sometimes "(none)". ... and happy new year! ---------------------------------------------------------------------- wp · 2017-01-02 09:39 Done. In the new revision there's a TsWorksheet.IsEmpty and a TsWorkbook.RemoveAllEmptyWorksheets. A worksheet is considered to be empty if there are no cells or only cells with content type cctEmpty (i.e. only cells with formatting, but no data), and if there are no column and row records (specific col widths/row heights, or column/row formats). Quote from: totya on December 31, 2016, 09:50:21 pmIn Spready empty Cellvalues ContentType sometimes "cctEmpty", sometimes "(none)". Where does this happen? ---------------------------------------------------------------------- totya · 2017-01-02 19:01 Hi! Thank you! For example in this sample: http://forum.lazarus.freepascal.org/index. php/topic,35299.msg233081.html#msg233081 B1, C1 ccEmpty A2, A3, A4 and many cells are both (none) ---------------------------------------------------------------------- wp · 2017-01-02 21:03 You mean the display in the Inspector? The inspector labels a combination of row and column index to which NO TCell record exists as "(none)". For example, if you just create a new worksheet, none of the "cells" that you see in the grid has a cell record - they are no real cells, therefore, the label "none". If you call Worksheet.GetCellCount you would get the result 0 - no cells. On the other hand, if you pick one of these "(none)" cells and change its font color, for example, a cell record is written which stores the index to the format describing the new font. Visually this cell is empty like the others, but it does have cell record now. Since it does not contain any data the content type element of the cell record has the value cctEmpty. Calling Worksheet.GetCellCount would return 1. ---------------------------------------------------------------------- totya · 2017-01-03 16:31 Yes, I mean the inspector in Spready: Right side / Cell values / Content type. Thank you for these informations!