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

Writing bulk data to a range - Unnecessary Parameter #62

Open
flywire opened this issue Apr 21, 2018 · 5 comments
Open

Writing bulk data to a range - Unnecessary Parameter #62

flywire opened this issue Apr 21, 2018 · 5 comments

Comments

@flywire
Copy link

flywire commented Apr 21, 2018

ws.range("B2", "C3").value = [[1, 2], [3, 4]]

Desirable not to include "C3" unless it is intended to truncate the array range. Default should be paste entire xy array at initial cell.

@kevmo314
Copy link
Collaborator

range("B2") refers to a specific cell, so this would be ambiguous as to whether or not you want to write the array to the cell or to the range. Additionally, the motivation for the end param is to allow merges, since you can do range("B2", "C3").merge(). An implicit end parameter would not make much sense here, as range("B2").merge() would be inconsistent with the proposed API.

That being said, if you do want to use an implicit end parameter specifically for your use case, you could use range("B2", (float('inf'), float('inf'))), in other words, pass a tuple of coordinates as the end parameter. I believe assigning a smaller array to a larger range works, is that sufficient for your use case?

@flywire
Copy link
Author

flywire commented Apr 22, 2018

I would expect functionality to be the same as excel ie range pasted to active cell writes to a range of cells - clearly implicit. Same in VBA with copy-paste. I agree merge needs two parameters. Paste array to a cell would be unusual and reasonable to require special parameter.

@kevmo314
Copy link
Collaborator

PyExcelerate isn't a replacement for Excel and we don't aim to have the same API as it. Setting the value of a range is not identical to pasting, and it was an intentional decision to not allow ranges to exceed their specified bounds.

Ranges require an end parameter and I think it would be dangerous to allow the end parameter to be None.

@flywire
Copy link
Author

flywire commented Apr 29, 2018

Ranges require an end parameter and I think it would be dangerous to allow the end parameter to be None.

Certainly not the case in excel or VBA so why would it be with PyExcelerate?

@flywire flywire closed this as completed Apr 29, 2018
@flywire flywire reopened this Apr 29, 2018
@kevmo314
Copy link
Collaborator

Because they are fundamentally different. PyExcelerate is not Excel nor VBA, you can't shoot yourself in the foot and overwrite data in Excel because you can see the overwriting ocurring and undo it. PyExcelerate is completely opaque in comparison. I have proposed a solution above, if it does not work then we can investigate further, but "make PyExcelerate more like VBA" is not a reasonable feature request.

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

2 participants