Merged cell handling #41
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#41
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First, thank you for this library. Second, if I'm in the wrong place to be asking questions, I apologize.
I'm working with documents that contain merged cells. I'd like to iterate over rows and for a particular cell grab the value in a column header above it. The column headers are in merged cells.
Based on the demo, the
sheet.xml
files, and relevant sections of the spec (29500-1 SS 18.3.1.55 and A.2 ln. 2293 through ln. 2298), it seems the merge cell value is always in the top left cell and subsequent cells in the merge range areundefined
.Are there any helper attributes on the JS object of a merged cell (
obj.mergeValue
orobj.isMergeCell
) or is that something I'll have to handle myself?Cheers and thank you for your time! 🍻
There's never a wrong place to ask questions :) It really helps (clearly, given that you stumbled upon an interesting case), and it's really cool to see that others are using this library.
This is consistent with what excel does when saving to CSV. But that's clearly not the right approach.
Right now there is nothing, but it is easy to add. What would make the most sense for the API? My thought at the moment is to make A1, B1, A2, B2 all resolve to the same object (where the merge range is clearly noted in a field like
obj.range
).The CSV writer would act like Excel, and I imagine the row object array would work the same way.
If only other repo owners shared your sentiments 😀
I also think that would be ideal!
So the output would still show
undefined
right? As it currently does? I think that is the way to go, can't be breaking things. Duplicating the cell values would just look weird anyway.I'm working on a PR. Should have it done tomorrow.
@clayzermk1 sweet :)
https://github.com/SheetJS/test_files/blob/master/merge_cells.xls and https://github.com/SheetJS/test_files/blob/master/merge_cells.xlsx have vertical, horizontal, and rectangular merges.
Got thrown off by the holiday, meant Monday ;-)
Awesome, I'll definitely have some questions about the tests.
On Jan 3, 2014 8:39 PM, "SheetJSDev" notifications@github.com wrote:
clayzermk1/js-xlsx@f0a05daa96
Here's my first cut. I'm concerned with what I've written so far. The parsed output lists the merge cell values in the row (exactly how we don't want it). While this works for my use case, I don't like it for the library in general. Thoughts?
My editor removed some trailing whitespace and I removed a pair of extra curly braces that didn't seem to fit with your style. Otherwise, I tried to stick as closely as possible to your code style.
clayzermk1/js-xlsx@37753d8230
There was a bug with multiple merged cells in a sheet when I tested against the test file you provided.
@clayzermk1 clearly I produced a good test file :)
In that file, I see the following (output passed through
xmllint --format
:To get the ranges, the code would be:
For the aforementioned XML the output would be
[ 'A1:B2', 'C1:C2', 'A3:B3', 'D1:D2', 'A4:B4' ]
As for style: good catch. What editor do you use? I used to use a vim extension that removed blank spaces, but it clashed with other extensions and I ended up getting rid of it (now it is biting me in the rear end)
clayzermk1/jx-xlsx@37753d8230
Fixed a bug in the logic for actual empty cells.
I went ahead and converted them to range objects. See https://github.com/clayzermk1/js-xlsx/blob/mergeCells/bits/70_xlsx.js#L113 I think we may be on a slightly different page. I was referring to the CSVesque output containing the duplicated values - I don't like how that works/looks.
How would you implement this feature?
SublimeText 3 beta. I love it ❤️
https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L84 at first blush, the fix would be something like
if(C === val.c && R === val.r) row.push(...
As for the JSON object, there is no standard, but it makes sense to parallel the CSV behavior+1 It would be great to have
isMergeCell
andmergeValue
.@vjpr I think you should probably turn that into its own issue so it gets the appropriate attention.
@SheetJSDev since it looks like you added this functionality, I think this issue can be safely closed. Thank you for the work!
Example for write:
can you tell me how to set the alignment property of merge cell?
can someone tell me how to write in the merged cell?
https://github.com/Krishnakanth94/Xlsx-styles-working-code
the above code shows merge cells
alignment should be given to starting cell to merge it will we done!