Recent

Author Topic: need refresh imported odbc data  (Read 3902 times)

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
need refresh imported odbc data
« on: July 16, 2018, 03:11:28 pm »
I have an Excel spreadsheet that uses ODBC to import data from MS-Access database.

In Excel, I can refresh the worksheet to pick up the latest changes that I have made to the Access database.

I'm not sure how to do the same with lazarus spreadsheet component, can anyone advise, is there a "refresh external data" method available, or maybe I need to change flags in the Excel file or lazarus components?

wp

  • Hero Member
  • *****
  • Posts: 11831
Re: need refresh imported odbc data
« Reply #1 on: July 16, 2018, 05:53:57 pm »
Even if you are thinking of FPSpreadsheet: there is no "lazarus spreadsheet component". Do you mean the TsWorksheetGrid? In this case you must re-read the data from the Excel file, there is no "refresh" command.

Thaddy

  • Hero Member
  • *****
  • Posts: 14167
  • Probably until I exterminate Putin.
Re: need refresh imported odbc data
« Reply #2 on: July 16, 2018, 06:42:24 pm »
Even if you are thinking of FPSpreadsheet: there is no "lazarus spreadsheet component". Do you mean the TsWorksheetGrid? In this case you must re-read the data from the Excel file, there is no "refresh" command.
That's actually what excel does... 8-)
Specialize a type, not a var.

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
Re: need refresh imported odbc data
« Reply #3 on: July 17, 2018, 12:11:05 am »
Yes it is TsWorksheetGrid I was meaning, sorry for not being clearer..

If I open/close TsWorksheetGrid it doesn't bring in any changes made to an external datasource, as an example, I have an xlsx workbook that gets its data from an MS-Access database (I only use this as an experiment).

When I change data in my MS-Access database the changes don't appear in TsWorksheetGrid but I can get it to refresh when I open the same xlsx file using OLE and forcing the RefreshAll() method.


wp

  • Hero Member
  • *****
  • Posts: 11831
Re: need refresh imported odbc data
« Reply #4 on: July 17, 2018, 10:41:41 am »
When you open the file in Excel does it contain the changes main in the Access file? FPSpreadsheet can only show what is in the xlsx file; it does not query any data from external sources.

Thaddy

  • Hero Member
  • *****
  • Posts: 14167
  • Probably until I exterminate Putin.
Re: need refresh imported odbc data
« Reply #5 on: July 17, 2018, 03:05:52 pm »
Yes it is TsWorksheetGrid I was meaning, sorry for not being clearer..

If I open/close TsWorksheetGrid it doesn't bring in any changes made to an external datasource, as an example, I have an xlsx workbook that gets its data from an MS-Access database (I only use this as an experiment).

When I change data in my MS-Access database the changes don't appear in TsWorksheetGrid but I can get it to refresh when I open the same xlsx file using OLE and forcing the RefreshAll() method.
That sounds to me as the expected behavior. Don't confuse the Excel refresh menu item with its underlying code,which is similar/identical to RefreshAll(): It re-fetches all data.
« Last Edit: July 17, 2018, 03:09:28 pm by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018