Forum > FPSpreadsheet

from spreadsheet get range selected

(1/1)

eldonfsr:
Hello how i can get from fspreadsheet range of rows selected , i tried some but i don't get it..


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFormmain.MIRangeLabsClick(Sender: TObject);var  ws: TsWorksheet;  allSelRange: TsCellRangeArray;  SeleRange: TsCellRange;  activeCellRow,activeCellCol: Cardinal; egin   ws := sWorkbookSource1.Workbook.ActiveWorksheet;   activeCellRow := ws.ActiveCellRow;   activeCellCol := ws.ActiveCellCol;//   SeleRange :=  ws.GetSelection;  SeleRange := ws.GetCurrentRange(ws, activeCellRow, activeCellCol);  what i need is a list of rows selected..

thanks any help great..

wp:
I am a bit confused: Your code is mainly about a worksheet (ws), but there is also a WorkbookSource which indicates that you might be working with a WorksheetGrid. My point is: How and where do you select the rows? In the worksheet by calling SetSelection? Or in the WorksheetGrid by dragging the mouse? Do you really select entire rows or just blocks of cells? In Excel you would select a row by clicking on the row header, but IIRC, the WorksheetGrid does not provide this method. And related question: Is your selection a contiguous block (1 rectangle) or does it consist of several blocks?

eldonfsr:
Ok i understand well for my don't problem i need to do selection in wsgrid or ws just for me i get range of selections of rows ..

you can see what i doing..
 
just on procedure TFormmain.MIRangeLabsClick(Sender: TObject);

   for Rp:= allSelRange[0].Row1 to  allSelrange[0].Row2 do begin
      PrintQrLabel(RP, RP); here calling to print label is all what i need send the information of row
   end;

wp:
I still don't fully understand what this is about, but from your experiments in TFormMain.MIRangeLabsClick I guess that you want to determine the row indices of the cells that you had selected in the grid earlier.

Here is a modified version of this procedure:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFormmain.MIRangeLabsClick(Sender: TObject);var  ws: TsWorksheet;  allSelRange: TsCellRangeArray;  log: TStringList;  Rp, j:Integer;begin   log:= TStringList.Create;   ws := sWorkbookSource1.Workbook.ActiveWorksheet;   allSelRange := ws.GetSelection;   for j := 0 to High(allSelRange) do     for Rp:= allSelRange[j].Row1 to  allSelRange[j].Row2 do begin        PrintQrLabel(RP, RP);        log.Add(inttostr(Rp));        log.savetofile('log.txt');     end;   log.Free;end;
Note that it also considers the case that the user has selected multiple blocks (overlapping blocks are not handled and thus might be contained in the result set multiple times).

eldonfsr:
Yes i using the worksheetgrid to show to user information and from let him  select area of row nd columns also i don't have problem is select a rows only for send to the printer information only need row to extract the values from sheet , why i doing that they have a sheer with hole information for inventory but some of them need to print qr barcode...

thanks for your help....
 

Navigation

[0] Message Index

Go to full version