Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-12

googleapi google spreadsheet

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

lcy

I'm trying to fiqure out how to use google spreadsheet with lazarus. It seems that the calendar sample project
(\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After installing the googleapi and the synapse component the calendar sample compiles with success. But if I run the app lazarus it stops in application.inc at the end of the "procedure
TApplication.ProcessAsyncCallQueue" method. With the stable version Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. Can someone help?

Kind regards,
jus

Reply by email

Michael Van Canneyt
to lcy
lcy wrote 10 lines
I'm trying to fiqure out how to use google spreadsheet with lazarus. It seems that the calendar sample project (\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After installing the googleapi and the synapse component the calendar sample compiles with success. But if I run the app lazarus it stops in application.inc at the end of the "procedure TApplication.ProcessAsyncCallQueue" method. With the stable version Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. Can someone help?

I just did some fixes in google api so it will work with latest trunk, but they have nothing to do with TApplication.ProcessAsyncCallQueue.

The google components work independent of the ProcessAsyncCallQueue procedure.

Michael.

Reply by email

Dave Connolly
to Michael Van Canneyt

Thanks for fixing the google API.

Michael Van Canneyt wrote 26 lines
On Wed, 4 Dec 2019, lcy wrote: > I'm trying to fiqure out how to use google spreadsheet with lazarus. It > seems that the calendar sample project > (\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk > version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After > installing the googleapi and the synapse component the calendar sample > compiles with success. But if I run the app lazarus it stops in > application.inc at the end of the "procedure > TApplication.ProcessAsyncCallQueue" method. With the stable version > Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. > Can someone help? I just did some fixes in google api so it will work with latest trunk, but they have nothing to do with TApplication.ProcessAsyncCallQueue. The google components work independent of the ProcessAsyncCallQueue procedure. Michael. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Michael Van Canneyt
to Dave Connolly

It was long overdue. :(

I intend to merge the streaming of the rest apis with the fpjsonrtti to be more robust, but this will take some time...

Dave Connolly wrote 32 lines
Thanks for fixing the google API. On Fri, 6 Dec 2019 at 11:32, Michael Van Canneyt wrote: > > > On Wed, 4 Dec 2019, lcy wrote: > >> I'm trying to fiqure out how to use google spreadsheet with lazarus. It >> seems that the calendar sample project >> (\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk >> version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After >> installing the googleapi and the synapse component the calendar sample >> compiles with success. But if I run the app lazarus it stops in >> application.inc at the end of the "procedure >> TApplication.ProcessAsyncCallQueue" method. With the stable version >> Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. >> Can someone help? > > I just did some fixes in google api so it will work with latest trunk, but > they have nothing to do with TApplication.ProcessAsyncCallQueue. > > The google components work independent of the ProcessAsyncCallQueue > procedure. > > Michael. > _______________________________________________ > fpc-pascal maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal >

Reply by email

lcy
to Michael Van Canneyt: I just did some fixes in google api so it will work with latest trunk, but they have…

Hi Michael, thank you for fixing!

I'm still had some problems to use your googlesheets.pp the google spreadsheet. As posted in the Lazarus forum:
https://forum.lazarus.freepascal.org/index.php/topic,47612.msg341608.html#ms g341608

I use the calendar demo project
(\lazarus\components\googleapis\demo\calendar) as a starting point and modified it for google spreadsheet.
----------------------------------------------------- { TMainForm }

procedure TMainForm.FormCreate(Sender: TObject);
begin
  // Register resources.
  TSheetsAPI.RegisterAPIResources;
  // Set up google client.
  FClient:=TGoogleClient.Create(Self);
{$IFDEF USESYNAPSE}
  FClient.WebClient:=TSynapseWebClient.Create(Self);
{$ELSE}
  FClient.WebClient:=TFPHTTPWebClient.Create(Self);
{$ENDIF}
  FClient.WebClient.RequestSigner:=FClient.AuthHandler;
  FClient.WebClient.LogFile:='requests.log';
  FClient.AuthHandler.WebClient:=FClient.WebClient;
  FClient.AuthHandler.Config.AccessType:=atOffLine;
  // We want to enter a code.
  ;
  FSheetsAPI:=TSheetsAPI.Create(Self);
  FSheetsAPI.GoogleClient:=FClient;
  // Load configuration
  LoadAuthConfig;
end;
procedure TMainForm.BFetchCalendarsClick(Sender: TObject);
var
  Resource : TSpreadsheetsValuesResource;
  EN : String;
  i:integer;
  RangeData: TValueRange;
begin
  SaveRefreshToken;
  RangeData:=Nil;
  Resource:=Nil;
  Resource := FSheetsAPI.CreateSpreadsheetsValuesResource;
  try
    if assigned(Resource) then
    begin
      Memo1.Lines.Add('resources assigned');
      RangeData:= Resource.Get('****your spread sheet
id****','Tabellenblatt1!A1:B3');
    end;
  finally
    FreeAndNil(Resource);
  end;
end;
-----------------------------------------------------

If I press the "Fetch" button the following exception is raised in the old restbase.pp version (with the your new restbase.pp is another exception): ----------------------------------------------------- [Debugger Exception Notification]
Project GoogleSpreadSheet raised exception class 'ERESTAPI' with message: TValueRange: unsupported array element type : tkDynArray -----------------------------------------------------

The good news is that google really sends the requested cells (in my case above A1:B3) back as a json string. The json string from google in my case looks like:

----------------------------------------------------- {
"range": "Tabellenblatt1!A1:B3",
"majorDimension": "ROWS",
"values": [
[
"quantity",
"product"
],
[
"1",
"product 1"
],
[
"2",
"product 2"
]
]
}
-----------------------------------------------------

But the problem is that the json values cannot be saved to the TValueRange object (from googlesheets.pp) because an exception is raised. After some debugging it seems that the "procedure TBaseObject.SetArrayElements" method in restbase.pp cannot handle the tkdynarray type. I guess the TBaseObject.SetArrayElements can only handle 1 dimensional arrays but not multidimensional arrays. My problem currently is that I didn't really understand how the TValueRange can hold a multidimensional array ( in this case is an 2 dimensional array). How can it be filled with data.

Kind regards,
jus

Earlier message 28 lines
-----Original Message----- From: Michael Van Canneyt Sent: Freitag, 6. Dezember 2019 12:32 To: ; FPC-Pascal users discussions Subject: Re: [fpc-pascal] googleapi google spreadsheet On Wed, 4 Dec 2019, lcy wrote: > I'm trying to fiqure out how to use google spreadsheet with lazarus. It > seems that the calendar sample project > (\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk > version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After > installing the googleapi and the synapse component the calendar sample > compiles with success. But if I run the app lazarus it stops in > application.inc at the end of the "procedure > TApplication.ProcessAsyncCallQueue" method. With the stable version > Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. > Can someone help? I just did some fixes in google api so it will work with latest trunk, but they have nothing to do with TApplication.ProcessAsyncCallQueue. The google components work independent of the ProcessAsyncCallQueue procedure. Michael.

Reply by email

Michael Van Canneyt
to lcy

Hello,

As far as I know 2 dimensional arrays should be possible, but I would need to check.

Can you please send me your complete test program ?

Michael.

lcy wrote 137 lines
Hi Michael, thank you for fixing! I'm still had some problems to use your googlesheets.pp the google spreadsheet. As posted in the Lazarus forum: https://forum.lazarus.freepascal.org/index.php/topic,47612.msg341608.html#ms g341608 I use the calendar demo project (\lazarus\components\googleapis\demo\calendar) as a starting point and modified it for google spreadsheet. ----------------------------------------------------- { TMainForm } procedure TMainForm.FormCreate(Sender: TObject); begin // Register resources. TSheetsAPI.RegisterAPIResources; // Set up google client. FClient:=TGoogleClient.Create(Self); {$IFDEF USESYNAPSE} FClient.WebClient:=TSynapseWebClient.Create(Self); {$ELSE} FClient.WebClient:=TFPHTTPWebClient.Create(Self); {$ENDIF} FClient.WebClient.RequestSigner:=FClient.AuthHandler; FClient.WebClient.LogFile:='requests.log'; FClient.AuthHandler.WebClient:=FClient.WebClient; FClient.AuthHandler.Config.AccessType:=atOffLine; // We want to enter a code. ; FSheetsAPI:=TSheetsAPI.Create(Self); FSheetsAPI.GoogleClient:=FClient; // Load configuration LoadAuthConfig; end; procedure TMainForm.BFetchCalendarsClick(Sender: TObject); var Resource : TSpreadsheetsValuesResource; EN : String; i:integer; RangeData: TValueRange; begin SaveRefreshToken; RangeData:=Nil; Resource:=Nil; Resource := FSheetsAPI.CreateSpreadsheetsValuesResource; try if assigned(Resource) then begin Memo1.Lines.Add('resources assigned'); RangeData:= Resource.Get('****your spread sheet id****','Tabellenblatt1!A1:B3'); end; finally FreeAndNil(Resource); end; end; ----------------------------------------------------- If I press the "Fetch" button the following exception is raised in the old restbase.pp version (with the your new restbase.pp is another exception): ----------------------------------------------------- [Debugger Exception Notification] Project GoogleSpreadSheet raised exception class 'ERESTAPI' with message: TValueRange: unsupported array element type : tkDynArray ----------------------------------------------------- The good news is that google really sends the requested cells (in my case above A1:B3) back as a json string. The json string from google in my case looks like: ----------------------------------------------------- { "range": "Tabellenblatt1!A1:B3", "majorDimension": "ROWS", "values": [ [ "quantity", "product" ], [ "1", "product 1" ], [ "2", "product 2" ] ] } ----------------------------------------------------- But the problem is that the json values cannot be saved to the TValueRange object (from googlesheets.pp) because an exception is raised. After some debugging it seems that the "procedure TBaseObject.SetArrayElements" method in restbase.pp cannot handle the tkdynarray type. I guess the TBaseObject.SetArrayElements can only handle 1 dimensional arrays but not multidimensional arrays. My problem currently is that I didn't really understand how the TValueRange can hold a multidimensional array ( in this case is an 2 dimensional array). How can it be filled with data. Kind regards, jus -----Original Message----- From: Michael Van Canneyt Sent: Freitag, 6. Dezember 2019 12:32 To: ; FPC-Pascal users discussions Subject: Re: [fpc-pascal] googleapi google spreadsheet On Wed, 4 Dec 2019, lcy wrote: > I'm trying to fiqure out how to use google spreadsheet with lazarus. It > seems that the calendar sample project > (\lazarus\components\googleapis\demo\calendar) doesn't work in the trunk > version Laz(2.1.0)+FPC(3.3.1) created with fpcupdeluxe anymore. After > installing the googleapi and the synapse component the calendar sample > compiles with success. But if I run the app lazarus it stops in > application.inc at the end of the "procedure > TApplication.ProcessAsyncCallQueue" method. With the stable version > Laz(2.0.2)+FPC(3.0.4) created with fpcupdeluxe it seems to run. > Can someone help? I just did some fixes in google api so it will work with latest trunk, but they have nothing to do with TApplication.ProcessAsyncCallQueue. The google components work independent of the ProcessAsyncCallQueue procedure. Michael.

Reply by email