Excel doesn't have such functionality built in. You can only disallow creating new sheets by protecting the workbook or with a VBA handler that reverses the operation immediately.
Protecting the workbook also disables other worksheet operations like moving, renaming and hiding/unhiding which may or may not be desirable.
OTOH, the VBA handler can be more intelligent than the one on the link:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
If ThisWorkbook.Worksheets.Count > <Maximum> Then
With Application
.ScreenUpdating = False
.DisplayAlerts = False
Sh.Delete
.DisplayAlerts = True
.ScreenUpdating = True
End With
End If
End Sub
Of course, this will have no effect if one edits the file with a 3rd-party package that doesn't run VBA, or disables macros in Excel.
To have macros, the workbook must be saved as .xlsm
, or Excel would give an error upon opening.
See Working with VBA Macros — XlsxWriter Documentation about Python implementation. openpyxl
cannot work with macros, only preserve them at most, and xlrd
looks like being designed to only read rather than edit. Alternatively, there's always Excel's own COM interface that pywin32
can use.