How to set last column when hitting Ctrl-End

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
NickS
Posts: 5
Joined: Fri Apr 25, 2008 6:32 pm

How to set last column when hitting Ctrl-End

Post by NickS »

Hello,
I've converted an old XLSv2 report to XLS4 and one big difference that our users need back is the ability that once they first open the Excel report and hit Ctrl-End, it takes them to the last row/column of data.
The old XLSv2 did no problem, but XLSv4 does not. It does take the user to the last row with no extra code needed, but the column is at 'IU', which is 255.

There is a private variable 'FCol2' in the Rows4 unit that I cannot get to in order to override with code to define the last column. Assigning XLS[0].LastColumn does nothing and neither does XLS[0].Column.LastColumn. I notice that when a new row is written (AddIfNone), there is a call inside that source code function to Result := TXLSRow.Create(FFormats,DEFAULT_FORMAT,FFormatChangeEvent). As soon as this happens, it triggers 'FCol2' to 255 as the default and cannot be overridden.

Please help! :) I've searched the forum here and found nothing.

Thanks,
Nick
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: How to set last column when hitting Ctrl-End

Post by larsa »

Hello

You can't define where the Ctrl+End command will take you. It will always jump to the next cell with a value, or the last cell of the worksheet if there are no more cells.
This is built in into Excel and nothing you can save in the files.
Lars Arvidsson, Axolot Data
NickS
Posts: 5
Joined: Fri Apr 25, 2008 6:32 pm

Re: How to set last column when hitting Ctrl-End

Post by NickS »

Hi Lars, thanks for replying..

Well, all I'm doing is taking an existing XLSv2 report and converting to the latest XLSv4 component/code. And there were a lot of code/syntax differences and one thing in the old version that worked fine was just writing a simple string/number cell with a value. But in XLSv4 you have to preface the cell write with AddIfNone, and this is where the source code creates a new "blank" row before the data is written and it creates the row with the last column as 255.
The current/old XLSv2 report we have works perfectly if you open it and immediately press Ctrl-End. Brings you to exactly the last row and last column of data. Same exact report converted to XLSv4 does not. It brings you to the last row but column 255, not the last column of data. This is definitely behavior difference between the two XLSReadWrite versions.

I can change the Row4 unit source code to override the default 255 value with a new passed in column parameter, but I do not want to do this as changing the source code is not the solution.

If I can't via code change this new behavior, I guess we will have to live with it, but I feel new software versions shouldn't be taking any pre-existing functionality away, only adding/enhancing it! :)

Thanks...
Post Reply