Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the cell range copy to excel #281

Open
YongcaiHuang opened this issue May 30, 2024 · 8 comments
Open

Support for the cell range copy to excel #281

YongcaiHuang opened this issue May 30, 2024 · 8 comments

Comments

@YongcaiHuang
Copy link

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!

@mwouts
Copy link
Owner

mwouts commented Jun 2, 2024

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.

@YongcaiHuang
Copy link
Author

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

Example.mp4

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
  1. click copy button
  2. paste into Excel

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

@mwouts
Copy link
Owner

mwouts commented Jun 3, 2024

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?

@YongcaiHuang
Copy link
Author

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

@mwouts
Copy link
Owner

mwouts commented Jun 8, 2024

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

@on46zohu
Copy link

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

@mwouts
Copy link
Owner

mwouts commented Jun 20, 2024

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"],
)

@on46zohu
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants