Lack of focus

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
hugvis
Posts: 7
Joined: Mon Nov 22, 2021 6:23 pm

Lack of focus

Post by hugvis »

Hello Lars

I'm having a lot of trouble using your XLS package in Delphi 10.3.3 Probably most of all because there are no instructions or a lack of examples.
There is also a lot of outdated problems and solutions on web that are not relevant today and outdated solution.
I now have an Excel document that is about 890 lines and about 42 columns. I want to move the sheet around the visible screen area so the user can see the relevant cell i want to show user each time without user having to scroll himself.
These two lines as a example do nothing for me
XLSGridDkUsers.XLS [0] .SelectedAreas.CursorCell (2, 150);
XLSGridDkUsers.Invalidate;
I need to get a solution to this and various other problems that are perhaps no problem other than reinventing the wheel
Lars, I want to see support from you before I give up on this package of yours and turn to other solutions
I can't advise no one to purchase from you in the fact of lack of support or instruction of both.

Rg., Hjalmar.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Lack of focus

Post by larsa »

Hello

TXLSGrid is a very simple viewer based on Delphi's TDrawGrid component. It can only can handle the most basic cell formatting. If you want to implement any interaction with the component, please study the documentation for TDrawGrid.

Do not confuse TXLSGrid with our TXLSSpreadSheet component. It's much more advanced and capable of things you can't do with TXLSGrid.
Lars Arvidsson, Axolot Data
hugvis
Posts: 7
Joined: Mon Nov 22, 2021 6:23 pm

Re: Lack of focus

Post by hugvis »

Hi
Let me explain this little better. Suppose I look for a specific value found in a cell, say column 63 and line 234.
The table does not move on the screen even though the value is found and i'm ok with that, but how can I program to move the table on the screen so the cell with founded value is in the middle of the screen ?
Please provide an example.!!

Below is an example that shows how I search for a value in one column and when a value is found in a cell, I want to move the table so that the user can see the cell in which the value was found


Finst := 0;
FormMain.LabelCountFind.Caption := '';
for i := 1 to FormMain.XLSGridDkUsers.XLS[0].LastRow do
begin

if Length( Trim( FormMain.XLSGridDkUsers.XLS[0].AsString[ 40, i ])) > 0 then
begin
FormMain.XLSGridDkUsers.XLS[0].Range.Items[ StrToInt( FormMain.XLSGridDkUsers.XLS[0].AsString[ 40, i ]), i, StrToInt( FormMain.XLSGridDkUsers.XLS[0].AsString[ 40, i ]) , i ].FillPatternForeColor := clWhite;
FormMain.XLSGridDkUsers.XLS[0].AsString[ 40, i ] := '';
end;

if AnsiContainsText( FormMain.XLSGridDkUsers.XLS[0].AsString[ ChCol-1, i ], ScValue ) then
begin
FormMain.XLSGridDkUsers.XLS[0].Range.Items[ ChCol-1, i, ChCol-1, i ].FillPatternForeColor := clMoneyGreen;
FormMain.XLSGridDkUsers.XLS[0].AsString[ 40, i ] := IntToStr( ChCol-1);
Finst := Finst + 1;
FormMain.LabelCountFind.Caption := 'Fann: ' + IntToStr( Finst);
end;

end;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Lack of focus

Post by larsa »

Hello

Try this:

Code: Select all

procedure FocusCell(AGrid: TDrawGrid; ACol, ARow: integer);
begin
  AGrid.LeftCol := Max(0,ACol - (AGrid.VisibleColCount div 2));
  AGrid.TopRow := Max(0,ARow - (AGrid.VisibleRowCount div 2));
end;
Lars Arvidsson, Axolot Data
Post Reply