itables icon indicating copy to clipboard operation
itables copied to clipboard

Support for the cell range copy to excel

Open YongcaiHuang opened this issue 1 year ago • 8 comments

Great project!!

I am wondering is there any plan to support the cell range copy to excel! I believe this might be a compelling function!

YongcaiHuang avatar May 30 '24 16:05 YongcaiHuang

Hi @YongcaiHuang , thanks for the suggestion.

Can you elaborate what you mean by the cell range selection?

Note that right now you can select a subset of the rows using either the search box or the SearchPanes or SearchBuilder extensions and then if you download you'll get only the selected rows.

You can also pass select="multi" or "os" in the show function like, and then Ctrl+Click to select certain rows, and download only those:

show(
    df,
    buttons = ["copyHtml5", "csvHtml5", "excelHtml5"],
    select="os"
)

NB: with select="os" you get, in addition, the option to select ranges with Shift+Click.

mwouts avatar Jun 02 '24 21:06 mwouts

Hi @mwouts,

thank you for the suggection of using buttons and select argument. I have tried (see below video, also I am not sure why when I click copy button, there is a whole blank pop-up. Is this display error?), but cannot achieve what I mean

https://github.com/mwouts/itables/assets/97007177/4871e303-4f1f-4bba-a576-8b6d7c4d69f7

sorry for the vague description. for example, the expected results would be:

  1. command/shift/option/control + select cell A (like df.iloc[2, 2]) and cell B (like df.iloc[4, 4])

  2. a cell range is selected (like df.iloc[2:4, 2:4]) image

  3. click copy button

  4. paste into Excel

I also tried keys argument, but a single cell can be selected.

YongcaiHuang avatar Jun 03 '24 16:06 YongcaiHuang

I see what you mean!

Well you can activate cell selection with e.g.

select={
        "style": "os",
        "items": "cell"
    }

but then, unlike for row selection, that's not taken into account by the export buttons. You can ask on the datatable forum if there is any way to export only the selected cells, as opposed to rows (assuming that the selection is a rectangle...)

Re the blank pop-up, on my end (firefox) I get a brief message with the number of rows copied. Can you try with a different browser?

mwouts avatar Jun 03 '24 18:06 mwouts

Thank you for the suggestion. I'll check in the datatable forum.

for the blank pop-up. I tried Jupyter lab desktop (4.2.1-1), Jupyter lab in Safari with version 17.5(19618.2.12.11.6) and Jupyter lab in edge (125.0.2535.79). Blank pop-up shows in all tries. However, when I change back to the Jupyter light theme, everything is back to normal image

Then I tried the search builder, same issue happened as I mentioned here

image

Also, FYI, Jupyter Lab 4.2.0 has introduced the Dark High Contrast Theme, where display issue shows under this theme as well. image

System: macOS Sonoma 14.5 Jupyter Lab: 4.2.1 itables: 2.1.0

YongcaiHuang avatar Jun 04 '24 15:06 YongcaiHuang

Thanks for reporting the issues with the Jupyter themes - I will have a look when times permit.

mwouts avatar Jun 08 '24 16:06 mwouts

Hi @mwouts, is there any update on this? or any time planned?

on46zohu avatar Jun 20 '24 08:06 on46zohu

For the themes, could you try this?

from IPython.display import display, HTML

display(HTML("<script>document.documentElement.classList.add('dark');</script>"))

For the columns x row selection, you can use the column visibility button, combined with the export options like in the example below. You will be able to chose the columns that you want to see and export, and the rows:

show(
    df.reset_index(),
    select=True,
    buttons=[{"extend": "csv", "exportOptions": {"columns": ":visible"}}, "colvis"],
)

mwouts avatar Jun 20 '24 21:06 mwouts

For the themes, could you try this?

from IPython.display import display, HTML

display(HTML("<script>document.documentElement.classList.add('dark');</script>"))

This one works great, thanks!

on46zohu avatar Jun 21 '24 07:06 on46zohu