We needed to do something similar (in fact with much more fully formed spreadsheet features, and some other complexities). We researched various strategies, and found, amongst other things:
1) Open source package like OpenOffice and GNumerics (built with Gtk3)implement these features. They either do not use Gtk explicitly, or they seem do so with "raw Gtk" rather than providing an explicit "sheet widget". We abandoned this strategy as far too expensive, and in the case of GNumerics, we found their coding style far too complex/difficult for our meagre brains.
2) andlabs is on the right track, based on what we ended up building. We rely to a large extent on GtkExtra. Which can certainly provide (out of box) most of the features you require. A few of the many possible comments to give you an idea include:
a) GtkExtra has a widget called GtkSheet which is a basic "grid/spreadsheet", but comes also with "testgtksheet.c/.exe", which is most of what you want "out of the box".
b) You will need to write your own code for Cut/Copy/Paste (CCP) of "Ranges", since the "out of the box" GtkExtra code can only CCP the string contents of a single cell across applications (i.e. via GtkClipboard
), as per the images below showing a Range CCP from Excel to our app (the "shorter pop up" is the "out of the box" CCP, while the other is our custom ver).
Also, we, as yet, have not been able to figure out how to CCP "full cell contents" (i.e. formulas, colours, etc) across apps (e.g. between GtkExtra and Excel, or OpenOffice, etc., see also SO posting Gtk clipboard spreadsheet value vs formula (Windows)). However, strings/values are fairly straight forward.
UPDATE: Subsequently we proved one approach to CCP'ing the "full Cell/Range" objects (i.e. formulas, properties, etc.) as discussed here (Gtk clipboard spreadsheet value vs formula (Windows))
Of course, such CCP "within the app" is all quite simple in our case since the entire app is based on arrays, rather than objects (the array basis is far more appropriate for our complex computational issues), and there is no clipboard required "internally" for, but we let the user choose whether to map to/from the clipboard or use other means.
You did not state your OS, and there are some difference with GtkClipboard
on Windows vs. Linux etc.
c) There may be many "default" settings in the GtkExtra "out of the box" elements that you may or may not like. In our case, we had to re-write considerable code to have things like Cell/Range etc Selection/Navigation perform in a manner more consistent with our needs and "standard spreadsheet protocols".
d) We also re-wrote much code for "modules" such as "pop menu's" etc, as, again, our needs went beyond the GtkExtra default/"out of the box" etc elements, though your requirements may not need too much of such.
e) If your spreadsheet also needs to be able to handle formulas, you will need to obtain or write a parser/calculator. Depending on your needs this can range from quite easy to extremely involved. In our case we do huge computational analysis with complex mathematics, so we had to go the "expensive" route, though your requirements may not need such.
f) Similar comments apply if wish to add features/"modules" such as plotting etc, though GtkExtra does come various additional widgets to provide "decent bits" for some of that, though your requirements may not need such.
However, to interface (any) plotting/graphics in a traditional spreadsheet manner, or for that matter if you just need "multi area" range CCP, then you will need to do some non-trivial coding.
g) It is not clear from your OP if you also need to read/write the sheets to/from files (e.g. in addition to CCP), and if so, what file formats. Again, depending on your needs this can be relatively easy to quite difficult. GtkExtra does not provide much support for general spreadsheet IO in terms of the many spreadsheet formats (xls, xlsx, ods, csv, sylk, etc etc), although they do provide fairly decent widgets to get you started with "File widgets", "font/grid" widgets, etc. (see images below, our app is called "ARTEx").




h) Although there are various places on the web that speak of GtkExtra with Gtk3, we found that it was better (at least for our needs) to stick with Gtk2 (which is the "official" basis for GtkExtra), and then you will also need to take some care with various other packages (e.g. if you use Glade, then you need to get quite an old version of Glade that supports Gtk2, etc.).
i) We did find some sub-programs and circumstances that crash Gtk/GtkExtra, and had to re-write some of the Gtk/GtkExtra source.
Incidentally, the images are for an app written in Fortran (which is hands down the best tool for complex/large computational matters) and use ISO binding/interface to the C based Gtk bits, running on Windows (built with MingW and creating Gtk etc dll's), so there is quite a bit you can do with Gtk/GtkExtra.