[SOLVED] MyWorkbook.GetWorksheetByIndex fails. lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- Hopestation · 2011-09-28 12:10 I have a workbook with 3 blank worksheets. I have used the following code:   N := MyWorkbook.GetWorksheetCount;   MyWorkbook.GetWorksheetByIndex(N - 1);   MyWorksheet.WriteNumber(0, 0, 1.0);// A1   MyWorksheet.WriteNumber(0, 1, 2.0);// B1   MyWorksheet.WriteNumber(0, 2, 3.0);// C1   MyWorksheet.WriteNumber(0, 3, 4.0);// D1   MyWorksheet.WriteUTF8Text(4, 3, IntToStr(N)); // D5   // Save the spreadsheet to a file   MyWorkbook.WriteToFile(InputFilename, sfExcel8, True); N, written to cell D5 = 3, but all the data is written to sheet 1. Why is this? ---------------------------------------------------------------------- Blaazen · 2011-09-28 12:41 I never worked with FFPSpreadSheet, but isn't "GetWorkSheetByIndex" a function ? Try: Code: [Select]MyWorksheet := MyWorkbook.GetWorksheetByIndex(N - 1); It is also on wiki, here: http://wiki.lazarus.freepascal.org/FPSpreads heet#Iterating_through_all_Worksheets ---------------------------------------------------------------------- Hopestation · 2011-09-28 13:08 Thanks, that worked. Another question. I can add a named worksheet but I can't find a way of getting the worksheet name from an existing spreadsheet. Is this possible? ---------------------------------------------------------------------- fabienwang · 2011-09-28 13:13 Quote from: Hopestation on September 28, 2011, 03:08:17 pmThanks, that worked. Another question. I can add a named worksheet but I can't find a way of getting the worksheet name from an existing spreadsheet. Is this possible? Name is a public attribute of class TsWorksheet. So you can use MyWorkSheet.Name. See line 189 of the class here: http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/f pspreadsheet/fpspreadsheet.pas?revision=2028&view=markup ---------------------------------------------------------------------- Hopestation · 2011-09-28 14:55 Thanks. I missed that. Now yet another question. My master spreadsheet contains graphics, cells with borders, merged cells, formatted dates and varying column widths. After loading and saving:-     The graphics disappear.     The borders dissappear.     The merged cells are no longer merged.     The dates become numbers which I cannot correct using Format cell, because this option no longer works in the     spreadsheet.     All column widths are the same. Can fpspreadsheet handle these features? ---------------------------------------------------------------------- felipemdc · 2011-09-28 15:57 Quote from: Hopestation on September 28, 2011, 04:55:49 pmAfter loading and saving:-     The graphics disappear.     The borders dissappear.     The merged cells are no longer merged.     The dates become numbers which I cannot correct using Format cell, because this option no longer works in the     spreadsheet.     All column widths are the same. Can fpspreadsheet handle these features? borders are supported only on writing, the rest lacks both read and write support. You have various options now: 1> Send a patch fixing the issues 2> Post a bounty for the issues. I could fix everything for the price of a Flexcel license for example 3> Post a bug report, then I will take a look when I have time, although it is a lot of features that you want, so not much chance of actually making to the top of my ToDo. I could consider implementing 1 or 2 items. or 4> Buy a copy of TMS FlexCel Studio for Lazarus and use this component instead of fpspreadsheet: http://www.tmssoftware.com/site/flexcel.asp ---------------------------------------------------------------------- Hopestation · 2011-10-09 10:07 I have given up on FPSpreadSheet and am trying Thierry Coq's SpreadsheetInterface. This seems to do everything that I need and its Open Source!