register-dynamics / data-import

Components and patterns for building spreadsheet uploaders in digital services
https://register-dynamics.github.io/data-import/
1 stars 0 forks source link

Merged cells are unhandled #36

Open simonwo opened 1 week ago

simonwo commented 1 week ago

The top row of this sheet is actually a merged cell spanning all of the columns.

image

We should show merged cells as they appear in the original sheet with appropriate colspans (or rowspans?)

alaric-rd commented 1 week ago

Upsettingly, the data from the XLSX parser doesn't seem to contain any colspan information. It looks like this:

[
  [ 'Tribble cohort 2023/24' ],
  [
    'Name',
    'Date of birth',
    'Time of birth',
    'Weight',
    'Colour',
    'Markings',
    'Notes'
  ],
  [ 'Kris', 45292, 45538.041666666664, 5.5, 'Pink', 'Splotches' ],
  [ 'Alex', 45384, 45538.19027777778, 6, 'Beige', 'N/A', 'My fave <3' ],
  [ 'Drew', 45415, 45538.62847222222, 6.5, 'Brown', 'Blob on top' ],
  [
    'Jamie',
    45353,
    45538.25069444445,
    8.4,
    'Pink',
    <1 empty item>,
    'Evil!!'
  ],
  [ 'Emm', 45413, 45538.413194444445, 4.9, 'Maroon', 'Yes' ],
  [ 'Elm', 45416, 45538.44652777778, 5.6, 'Black', 'Stripese' ],
  [],
  []
]

Therefore, I'm digging into the internals of the library we use to see if it keeps that information anywhere we can get at!

alaric-rd commented 5 days ago

I still need to do the range selection work before this is done!

simonwo commented 5 days ago

So what is the status? Is it that we can now extract cell merges but don't display them? E.g. I'm seeing merged cells being represented with extra empty cells in the tribbles sheet.

alaric-rd commented 4 days ago

That's right. Until I get the range selection JS working with it, I've disabled it in the code (see https://github.com/register-dynamics/data-import/blob/main/lib/importer/sheets.js#L24 for where) so I can get the extensive refactorings required to make it work merged (it was starting to collide with stuff Ross was doing). Feel free to turn that flag back on to see the cells, but then don't be shocked if range selections go all screwy on rows with merged cells in!