Recent

Author Topic: [Solved] Excel sheet position  (Read 1241 times)

Jero

  • New member
  • *
  • Posts: 5
[Solved] Excel sheet position
« on: December 30, 2018, 05:57:04 pm »
Hello,
When I open (with Excel) a sheet created with fpspreadsheet,
Excel display the end of the sheet (empty cell)

Is there a way to open the sheet directly on the first cells?

Thanks for your help. ::)
« Last Edit: January 05, 2019, 03:24:04 am by Jero »

wp

  • Hero Member
  • *****
  • Posts: 5652
Re: Excel sheet position
« Reply #1 on: December 30, 2018, 07:41:52 pm »
I don't know how you write the file, but fpspreadsheet by default does not move the active cell. The workbook created by the following code is opened by Excel on the first cell of the first sheet:
Code: Pascal  [Select]
  1. program Project1;
  2.  
  3. uses
  4.   fpspreadsheet, fpstypes, fpsallformats;
  5.  
  6. var
  7.   b: TsWorkbook;
  8.   sh: TsWorksheet;
  9. begin
  10.   b := TsWorkbook.Create;
  11.   try
  12.     sh := b.AddWorksheet('Page 1');
  13.     sh.WriteNumber(0, 0, 1.0);
  14.     sh.WriteUTF8Text(1, 3, 'abc');
  15.  
  16.     sh := b.AddWorksheet('Page 2');
  17.     sh.WriteNumber (1, 1, 2.0);
  18.     sh.WriteFormula(2, 1, '=B2*2');
  19.     sh.WriteFormula(3, 1, '=Sum(B1:B3)');
  20.  
  21.     b.WriteToFile('test.xls', sfExcel8, true);
  22.   finally
  23.     b.Free;
  24.   end;
  25.  
  26. end.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Jero

  • New member
  • *
  • Posts: 5
Re: Excel sheet position
« Reply #2 on: December 31, 2018, 07:30:41 am »
Strange, a new installation of fpspreadsheet and it's OK! :-[
Thank's