Reading and setting cell format, stuck lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- zxandris · 2025-08-07 07:16 Hey there I'm using Lazarus 2.2.6 and frpsheet 2.0 and I'm a little confused and stuck.  I need to set the cell format and then read that later for a custom save. I found cellFmt := wsGrid.Worksheet.ReadCellFormat(); but the param list shows a colon between them and the docs I found on copilot seem to indicate that it should be row, col, format.  With my version in mind can any one help me at all this is really got me stuck.  I just don't understand the params there at all.  Or perhaps I'm going about that entirely the wrong way.  Again, I need to set the format, at least the font, size, bold, italic and underline and then I need to be able to read those at a later date. Please help Thanks, CJ ---------------------------------------------------------------------- wp · 2025-08-07 08:34 See attached mini project (needs package laz_fpspreadsheet in requirements). Quote from: zxandris on August 07, 2025, 09:16:01 ambut the param list shows a colon between them[...] This is Pascal. The arguments of functions are always separated by semicolons in their declaration. But when the function is called, you must use a comma. ---------------------------------------------------------------------- zxandris · 2025-08-07 09:13 Quote from: wp on August 07, 2025, 10:34:53 amSee attached mini project (needs package laz_fpspreadsheet in requirements). Quote from: zxandris on August 07, 2025, 09:16:01 ambut the param list shows a colon between them[...] This is Pascal. The arguments of functions are always separated by semicolons in their declaration. But when the function is called, you must use a comma. Okay I think i see what's going on there but how to I retrieve a cell to put into the variable rather than having to write it.  I did look at the param list on my grid but nothing leapt out at me.  Bear in mind I'm doing this visually and I want to offer buttons that add/remove formatting. If you'd help a poor confused soul I would be grateful CJ ---------------------------------------------------------------------- wp · 2025-08-07 09:53 Sorry there is not enough information so that I don't understand what you mean. Quote from: zxandris on August 07, 2025, 11:13:02 amhow to I retrieve a cell to put into the variable rather than having to write it. Maybe this: 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 var   cell: PCell;...  cell := worksheet.Findcell(row, column);  // Finds a cell, returns nil when there is no cell at row/column  Quote from: zxandris on August 07, 2025, 11:13:02 amI did look at the param list on my grid [...] Grid? Which kind of grid? A TStringGrid or a TsWorksheetGrid? In the latter there are lots of properties to access cell formatting, e.g. 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   sWorksheetGrid.CellFontName[col, row] := 'Arial';    // Note that in the grid column and row indices are exchanged compared to the worksheet.  // And indices begin at 1 (but at 0 in the worksheet) Quote from: zxandris on August 07, 2025, 11:13:02 amI want to offer buttons that add/remove formatting. When you use the fpspreadsheet visual controls then the easiest way to do this is by adding FPSpreadsheet actions to an actionList and/or adding TsCellComboboxes to the form. See https://wiki.lazarus.freepasc al.org/FPSpreadsheet_tutorial:_Writing_a_mini_spreadsheet_application# Formatting_of_cells, ---------------------------------------------------------------------- zxandris · 2025-08-07 11:27 I would imagine it's 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 cell := worksheet.Findcell(row, column); I will try that soon.  In short and it's a little odd.  I'm working with a very limited file format, and can't just attach a sheet file format into the file.  That doesn't work unfortunately.  So I'm essentially saving content myself which works and I can save the col and row sizes fine.  But I'm having issues with saving the formating.  Or even setting it.  Now I think with your help I can set it okay and read it but I will get back to you on that . It's a little odd and VERY slow and may well be a pipe dream.  I'm not joking how limited the file format is and I'm now regretting the decision to stick to the original format with this project.  But I'm stuck with it now and when I say limited I mean it's basically a compressed ini file, so yeah...that bad and that slow. But it means that I'm doing this from scratch, and its a visual application.  So I need to personally read/write the format on a cell, and I don't THINK I can just use the actions.  Though I will give that a go, but will still need to read the cell format.  I'm using a TsWorksheet grid, not a drawgrid, and version 2...I think in lazarus 2.2.6 which I am aware is rather old now.  But upgrading isn't possible at current. (Hopefully soon). So you can see this is perhaps more complicated than it could be but right now I am stuck with my limitations. Thanks for all the help so far, I feel like we're getting there! CJ