Recent

Author Topic: FPSpreadsheet cut - paste cell  (Read 6662 times)

ffabio

  • New Member
  • *
  • Posts: 12
FPSpreadsheet cut - paste cell
« on: September 15, 2015, 01:45:40 pm »
Hello to all.
 I'm trying to use fpsreadsheet. I would then copy and paste of the selezonate maybe two fpsreadsheet different. does anyone know how to do.

 thanks fabio

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cut - paste cell
« Reply #1 on: September 15, 2015, 07:25:48 pm »
Copy/paste support is only very rudimentary: Currently it works only within the same worksheet loaded into a TsWorksheetGrid (use CTRL+C and CTRL+V).

ffabio

  • New Member
  • *
  • Posts: 12
Re: FPSpreadsheet cut - paste cell
« Reply #2 on: September 16, 2015, 02:57:31 pm »
I tried but ache with ctrl c and v is not working.
 c 'is any property to be set ????

i use 1.6.0 version 

 thank you

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cut - paste cell
« Reply #3 on: September 16, 2015, 03:30:01 pm »
Sorry, I should have been more precise: Copying and pasting are not built into the grid. You need to add a TsCopyAction and a TsPasteAction (for pasting) which you link to a WorkbookSource. See the tutorial wiki.lazarus.freepascal.org/FPSpreadsheet_tutorial:_Writing_a_mini_spreadsheet_application for getting the basic idea behind the visual fpspreadsheet controls. And see examples/visual/fpsctrls for a working example.

But be aware that these copy/paste operations do not use the system's clipboard, therefore they are not good for communication between applications. Due to a bug they are are not even working properly for pasting text from one worksheet to the other within the same workbook, only within the same worksheet.

In the long term, I'd like to implement a system-wide copy&paste, but I have to understand first how this works. Therefore I am not putting much effort in fixing the sheet-to-sheet copy/paste unless somebody requests it.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cut - paste cell
« Reply #4 on: September 29, 2015, 12:03:20 am »
In the meantime I looked into the file formats which Excel and LibreOffice write to the clipboard: They just stream standard files containing only the selected cells to the clipboard. The problem, however, is to find the correct names for registering the clipboard formats. As expected, there is some inconsitency between Windows and Linux, even with LibreOffice which runs in both operating systems.

The current trunk version of fpspreadsheet now supports clipboard operations in Windows rather well. Copying and pasting of data to cells in the same worksheet, a different worksheet, a subsequentyl loaded workbook, or even to an external application (Excel, LibreOffice) works fine. The project "fpsctrls" in the fpspreadsheet installation provides a worked-out example.

In Linux, however, there is still some kind of mystery to me. My observation with my "ClipboardExplorer" (https://sourceforge.net/p/wp-laz/code/HEAD/tree/ClipboardExplorer/) is that all the written streams, in fact, are found in the Linux clipboard, but the "Insert special" menu command of LibreOffice sometimes is grayed-out. Pressing Ctrl-V does insert data into LibreOffice, but only once, there is an error message "no valid clipboard data" (or similar) afterwards. Sometimes the "Insert special" is available, but it contains only the items "unformatted text", "html" and "*". The latter one probably should be the OpenDocument format written by fpspreadsheet which I gave the mime-type "application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)" (that's the name LibreOffice uses when it copies data to the clipboard). Selecting the "*" item results in above error message saying that LibreOffice does not understand this format.

Does anybody out there have some experience with the clipboard in Linux and with Libre/OpenOffice? Any idea what I am doing wrong?


heX

  • Newbie
  • Posts: 6
Re: FPSpreadsheet cut - paste cell
« Reply #5 on: August 02, 2016, 01:35:35 pm »
The current trunk version of fpspreadsheet now supports clipboard operations in Windows rather well. Copying and pasting of data to cells in the same worksheet, a different worksheet, a subsequentyl loaded workbook, or even to an external application (Excel, LibreOffice) works fine. The project "fpsctrls" in the fpspreadsheet installation provides a worked-out example.
With Excel work fine. But with LibreOffice Calc and notepad not work - 'This arrangement of source and destination cells in not supported for copy & paste'.  =(
PasteFromClipboardStream: AFormat=sfCSV, nselS=0.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: FPSpreadsheet cut - paste cell
« Reply #6 on: August 02, 2016, 02:49:28 pm »
I think, it will be better to ask about how clipboard  work on Libre Office official web site.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cut - paste cell
« Reply #7 on: August 02, 2016, 04:02:39 pm »
This description is a bit cryptic, and I am not sure if I could reproduce this correctly. At least there were two bugs when pasting from LibreOffice, fixed. Please try the new trunk version. If it does not solve your issue please describe exactly what you are doing: Copy or paste? From/to which application? Which cells are selected in source app, which cells are selected in destination app? Which OS?

heX

  • Newbie
  • Posts: 6
Re: FPSpreadsheet cut - paste cell
« Reply #8 on: August 26, 2016, 08:12:07 am »
This description is a bit cryptic, and I am not sure if I could reproduce this correctly. At least there were two bugs when pasting from LibreOffice, fixed. Please try the new trunk version. If it does not solve your issue please describe exactly what you are doing: Copy or paste? From/to which application? Which cells are selected in source app, which cells are selected in destination app? Which OS?
> Copy or paste? From/to which application?
From "LibreOffice Calc" (cells), or from "notepad.exe" (just text).
Paste to 'FPSpreadsheet.
OS - Windows 10.

> Which cells are selected in source app
The most common cells - contain text (without formul).

> which cells are selected in destination app
Default FPSpreadsheet on form (in empty project).

In debug i see in function 'PasteFromClipboardStream', param AFormat=sfCSV, variable nselS=0.


ps. sorry for my english.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: FPSpreadsheet cut - paste cell
« Reply #9 on: August 26, 2016, 11:25:15 am »
I still cannot reproduce this. Which fpspreadsheet version are you using? A related bug is fixed in trunk, but not in v1.6.2.

Here's what I am doing:
- Open LibreOffice Calc
- Enter some text in cells B3:C8.
- Select this range and press CTRL+C.
- Open demo_ctrls.exe in the fpspreadsheet/examples/visual/fpsctrls folder (or compile and run)
- Select cell D2
- Press CTRL-V
- The Calc cells are inserted, no error message.

- Open Notepad.exe
- Enter some text
- Select the text, press CTRL+C
- Go to demo_ctrls.exe
- Select cell B15
- Press CTR+V
- The notepad text is inserted, no error message.
« Last Edit: August 26, 2016, 06:40:13 pm by wp »

 

TinyPortal © 2005-2018