Sorry about that: what happens is that AddSheet(sheetcount: integer) isn't supposed to be a public method.
To add a simple sheet at the end, use
instead, but no
Or to add an arbitrary number of sheets anywhere, use xls.InsertAndCopySheets. In fact, if you look at the code for AddSheet it is:
/// Inserts an empty sheet at the end of the file. This is equivalent to calling InsertAndCopySheets(0, SheetCount + 1, 1).
/// If you need to insert more than one sheet, or insert it at the middle of existing sheets, use <see cref="InsertAndCopySheets(int, int, int)"/> instead.
procedure AddSheet; overload;
InsertAndCopySheets(0, SheetCount + 1, 1);
The idea about manipulating cells/sheets in FlexCel is (as explained in the docs), to have a minimum set of methods that can do everything, instead of millions of more specific methods. As they are little, it is easy to remember them and they don't pollute the XlsFile with thousands of extra methods.
Those methods are:
InsertAndCopyRange: Inserts or copies or InsertsAndCopies a range of cells, or a range of columns, or a range of rows from one sheet to other place of the sheet, to another sheet or to another workbook. That's why we don't have InsertRow, CopyRow, InsertColumn, InsertCellRange... etc, etc.
On that idea, "AddSheet" is really redundant, as it can be done with InsertAndCopySheets. But as it is not really intuitive, we've added a method to AddSheet anyway, which explains that you can call InsertAndCopySheet for more information.
Now, with this explained, let me tell you why we have this "AddSheet(integer)" method which shouldn't be public. Much of the FlexCel VCL code comes from .NET and it is automatically updated everytime we fix something or add new functionality. This is quite an interesting system on its own, which involves a hacked mono compiler, and which I should write a blog someday about it. It allows us for example to add SVG exporting this next week in FlexCel .NET 6.3, and have SVG exporting in VCL the same day (6.3 for VCL will take a little longer, but this is just because we need to add some VCL only functionality to it before release)
And in .NET, AddSheet(int) is an internal method:
Sadly, when we automatically convert this to delphi, we can't put it into an "internal" delclaration, because Delphi doesn't have that. So it must be exported as public.
Currently, there are some methods in the API which are internal in .NET but exposed in Delphi, because we have no choice. They aren't much, and normally have names that show they are internal, but in this case of AddSheet it can be confusing.
The way to know right now if a method is internal or not in Delphi is to press F1 and look at the docs. 100% of the public API is documented, so if you see "This method is for internal use.", then it is internal.
For the future, we have been toying in the last weeks with some other ways to hide those methods, which aren't much, but as in this case can be confusing. The easiest way would be to have the converted to convert them as "_AddSheet", so you know methods with an underscore are internal. but I am thinking also in using a class helper to completely hide those methods. We've just haven't got time to dedicate to this yet, FlexCel is a huge project (1600 units), I have to maintain it in VCL and .NET, and there is other more pressing stuff to do. (as we spoke about last week, for example adding tables support).
Again sorry about that, and in short, use AddSheet; or InsertAndCopySheets, don't use AddSheet(number).