jspreadsheet / jspreadsheet/ce

Excel and quotation mark handling

Open
#1,139 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.2k
Forks
890
PR merge metrics
No merged PRs in 30d

Description

This is kind of a follow up on #176

When pasting data from excel with quotation marks, this isn't handled properly by jExcel. After some testing, I found that excel has surprisingly complicated quote handling icw copy/paste.
Consider this excel table:
image

Copying it to a text file results in this (see image for whitespace characters):
image

copy pastable:

"single quote	1
ends with quote"	2
"surrounded by quotes"	3
no quote	4
"has a 	tab"	5
"a "" and a 	tab"	6
"""starts with quote, and has a 	tab"	7

If a cell has a tab, then it gets surrounding quotes. If there is also a quote in the cell, then that is escaped by doubling it. So how can excel know the difference between a cell that has quotes in the content or that is surrounded by quotes? Well, apparently it doesn't. When the text is copied back to excel, the surrounded by quotes cell loses the quotes. Also the first two cells are merged:
image
Copying it back to text results in
image

"single quote	1
ends with quote"	2
surrounded by quotes	3
no quote	4
"has a 	tab"	5
"a "" and a 	tab"	6
"""starts with quote, and has a 	tab"	7

All this is to say that there is probably no way to do it completely right, but as jExcel just interprets all quotes as cell delimiters (as far as I can tell) it can surely be improved

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Excel copy/paste examples in the issue and compare how jExcel parses tabs, surrounding quotes, and doubled quotes. Trace the paste-handling entry point responsible for converting clipboard text into cells. Done means the examples are parsed more accurately, with behavior documented for cases Excel cannot distinguish.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.