Why 'RegisterSpreadFormat' does not get called? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- VTwin · 2015-03-09 19:39 I must be doing something stupid, but I can't figure out what. The example program "opendocwrite" works fine, but when I use similar code: Code: [Select]   wb := TsWorkbook.Create;    ws := wb.AddWorksheet('Sheet1');   ...    wb.WriteToFile(path, sfOpenDocument);    wb.Free; the extension (ods in this case) is found valid, but GsSpreadFormats has not been initialized and is empty, so it throws an exception in CreateSpreadWriter. RegisterSpreadFormat never gets called to initialize GsSpreadFormats, but, in the example program it is called before the program runs. I don't get it. In the example program's Call Stack RegisterSpreadFormat is called from _XLSBIFF2_init, which is called from fpc_initializeunits. My program, even with the same code, never gets there. Is there a project setting that I missed? I'd appreciate any insight on how to fix this. Thanks! Cheers, VTwin ---------------------------------------------------------------------- wp · 2015-03-09 21:12 You must "use" the reader/writer units of the formats that you want to process. E.g if you want to read Excel2 files you add "xlsbiff2" to the uses clause, and this registers the corresponding format. Or "use" "fpsallformats" to get access to all file formats supported, just as the name says. See http://wiki.lazarus.freepascal.org/FPSpreadsheet#Units. ---------------------------------------------------------------------- VTwin · 2015-03-09 23:57 wp, Thank you so much!! That, of course, solved it. I'm sorry for being a dunderhead. I couldn't get past the fact that it compiled without a problem. I've been working hard at Free Pascal / Lazarus for a few years now, but still have much to learn. I very much appreciate the wisdom you and others here are so kind to offer. Cheers, VTwin ---------------------------------------------------------------------- wp · 2015-03-10 00:12 I see in your signature that you work with OSX. I would appreciate if you could report here any problems that you have with fpspreadsheet. The library is not tested under this OS since I don't have access to it.