FPSPreadsheet doesn't read/write files lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- yellowbit · 2012-11-29 20:44 I've tried to use an example from this link: http://wiki.freepascal.org/FPSpreadsheet#Excel_5_example It's very simple code, but I get this message: QuoteTried to write a spreadsheet using an unsupported format. Every format causes this error. I think the file path is OK. What can be wrong? Does it require the MS Office installed (I have only Libre Office) ? ---------------------------------------------------------------------- BigChimp · 2012-11-30 07:21 Quote from: yellowbit on November 29, 2012, 09:44:09 pmWhat can be wrong? Does it require the MS Office installed (I have only Libre Office) ? 1. You don't show any code so I don't know what can be wrong. No permissions to the directory/file? Wrong filename? Please include code. See my signature for more tips on how to ask questions. 2. No you don't need MS Office, Libre Office or anything else (except the requirements mentioned on the fpspreadsheet wiki page. ---------------------------------------------------------------------- yellowbit · 2012-11-30 15:22 Quote from: BigChimp on November 30, 2012, 08:21:59 amYou don't show any code so I don't know what can be wrong.My code is almost the same as shown under the link in the first post (added OpenFileDialog to get the file name). I'm sure the file path is valid and I'm running as the administrator. Code: [Select]{ excel5demo.dpr Demonstrates how to write an Excel 5.x file using the fpspreadsheet library You can change the output format by changing the OUTPUT_FORMAT constant AUTHORS: Felipe Monteiro de Carvalho } program excel5demo; {$mode delphi}{$H+} uses   Classes, SysUtils, fpspreadsheet, fpsallformats, fpspreadsheet_pkg; const OUTPUT_FORMAT = sfExcel5; var   MyWorkbook: TsWorkbook;   MyWorksheet: TsWorksheet;   MyFormula: TsRPNFormula;   MyDir: string; begin   // Initialization   MyDir := ExtractFilePath(ParamStr(0));   // Create the spreadsheet   MyWorkbook := TsWorkbook.Create;   MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');   // Write some number cells   MyWorksheet.WriteNumber(0, 0, 1.0);   MyWorksheet.WriteNumber(0, 1, 2.0);   MyWorksheet.WriteNumber(0, 2, 3.0);   MyWorksheet.WriteNumber(0, 3, 4.0);   // Write the formula E1 = A1 + B1   // or, in RPN: A1, B1, +   SetLength(MyFormula, 3);   MyFormula[0].ElementKind:=fekCell; {A1}   MyFormula[0].Col := 0;   MyFormula[0].Row := 0;   MyFormula[1].ElementKind:=fekCell; {B1}   MyFormula[1].Col := 1;   MyFormula[1].Row := 0;   MyFormula[2].ElementKind:=fekAdd;;  {+}   MyWorksheet.WriteRPNFormula(0, 4, MyFormula);   // Creates a new worksheet   MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet 2');   // Write some string cells   MyWorksheet.WriteUTF8Text(0, 0, 'First');   MyWorksheet.WriteUTF8Text(0, 1, 'Second');   MyWorksheet.WriteUTF8Text(0, 2, 'Third');   MyWorksheet.WriteUTF8Text(0, 3, 'Fourth');   // Save the spreadsheet to a file   MyWorkbook.WriteToFile(MyDir + 'test' + STR_EXCEL_EXTENSION, OUTPUT_FORMAT);   MyWorkbook.Free; end. ---------------------------------------------------------------------- paweld · 2012-11-30 18:33 lazarus 1.0.2, fpc 2.6.0, win 7 x64, fpspreadsheet from svn ---------------------------------------------------------------------- BigChimp · 2012-12-01 10:39 Thanks paweld Was just about to upload my own version when I saw you had uploaded the attachment. The example code posted by yellowbit works fine for me with fpspreadsheet svn (and FPC 2.6.1) as long as I comment out the fpspreadsheet_pkg unit as that doesn't seem to exist (or I'm to stupid to find it - in any case, it works without the unit) ---------------------------------------------------------------------- yellowbit · 2012-12-01 20:03 Thanks, paweld! I've found the problem. It was missing "fpsallformats" in the "uses" section. The program was compiled without errors, so I haven't noticed this missing word. Pozdrowienia z Krakowa