googleapi google spreadsheet

classic Classic list List threaded Threaded
6 messages Options
lcy
Reply | Threaded
Open this post in threaded view
|

googleapi google spreadsheet

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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: googleapi google spreadsheet

Michael Van Canneyt


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  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: googleapi google spreadsheet

Free Pascal - General mailing list
Thanks for fixing the google API.

On Fri, 6 Dec 2019 at 11:32, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: googleapi google spreadsheet

Michael Van Canneyt

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...

Fixed also the lazarus drive example. Drive API was at V2, example only at V2.

Michael.

On Fri, 6 Dec 2019, Dave Connolly via fpc-pascal wrote:

> Thanks for fixing the google API.
>
> On Fri, 6 Dec 2019 at 11:32, Michael Van Canneyt <[hidden email]>
> 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  -  [hidden email]
>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>>
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lcy
Reply | Threaded
Open this post in threaded view
|

Re: googleapi google spreadsheet

lcy
In reply to this post by Michael Van Canneyt
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.
  FClient.OnUserConsent:=@DoUserConsent;
 
  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 [mailto:[hidden email]]
Sent: Freitag, 6. Dezember 2019 12:32
To: [hidden email]; 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: googleapi google spreadsheet

Michael Van Canneyt

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.

On Fri, 6 Dec 2019, lcy wrote:

> 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.
>  FClient.OnUserConsent:=@DoUserConsent;
>
>  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 [mailto:[hidden email]]
> Sent: Freitag, 6. Dezember 2019 12:32
> To: [hidden email]; 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.
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal