Recent

Author Topic: Howto read the Value of a cell with a name  (Read 4942 times)

John Landmesser

  • New Member
  • *
  • Posts: 31
Howto read the Value of a cell with a name
« on: September 18, 2012, 10:19:11 am »
i need to read the value of a cell in an excel sheet and i only now that this cell has a name.

With Delphi that would look this way:
KontrollsummeXLS := V.ActiveWorkbook.Sheets[1].Range['Kontrollsumme'].Value

Is that allready possible using fpSpreadSheet ?

EDIT:
Just learned that fpc 2.6.1 knows ActiveX, see
\lazarus\components\activex\README.txt

So i can use my Delphi code:

uses 
ActiveX,  ComObj, variants, windows;

var
  V : variant;
  KontrollsummeXLS : Currency;

  try
  {* laufende Excel Instanz verwenden, sonst neue Instanz starten *}
    v := GetActiveOLEObject('Excel.Application');
    //V.Visible := true;
    //ShowWindow(ExcelApp.Hwnd, SW_ShowMaximized);
  except
    try
      V := CreateOleObject('Excel.Application');
      //V.Visible := true;
    except
      raise EOleSysError.CreateFmt('Excel konnte nicht gestartet werden!',
        []);
    end;
  end;
  V.Workbooks.open('' + WideString(MyFName) + '');
    KontrollsummeXLS := V.ActiveWorkbook.Sheets[1].Range['Kontrollsumme'].Value;


« Last Edit: September 18, 2012, 12:55:28 pm by JohnML »

 

TinyPortal © 2005-2018