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

quick question - strike-through font detection #19

Closed
pdapel opened this issue Jun 3, 2015 · 3 comments
Closed

quick question - strike-through font detection #19

pdapel opened this issue Jun 3, 2015 · 3 comments

Comments

@pdapel
Copy link

pdapel commented Jun 3, 2015

I have been looking around for an xlsx parser that can detect strikethrough and other font properties. Your module looks quite excellent, but I have not had a chance to clone your repo and mock up a test case, so I've decided to ask a question here instead... I'm looking at your examples and seeing the .font property being used as a setter for getCell()... Can I read an existing XLSX and access the existing cell font properties by doing something like the following?

// Iterate over all cells in a row (including empty cells)
row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
    console.log("Cell " + colNumber + " = " + cell.value);

    // is .font valid in the context of reading cell content?
    console.log("... and .font.strike= " + cell.font.strike); 
});

Many thanks in advance for taking the time to answer a question!

@guyonroche
Copy link
Collaborator

Sorry for taking so long to answer.
Yes - your code will work as expected. The cell.font.strike will be true for cells with strike-through. Though you might want to test for cell.font && cell.font.strike as not all cells will have a font object.

Also - the {includeEmpty:true} may not necessary as it will cause the eachCell to include empty cells as well as ones with values.

@pdapel
Copy link
Author

pdapel commented Jun 9, 2015

Awesome. Thanks for the reply and for the suggestions -- I had already forgotten about this, so you just gave me a nice incentive to go build my test harness. Much appreciated!

@pdapel
Copy link
Author

pdapel commented Jul 2, 2015

@guyonroche , thanks again for your module, it is working well for me detecting (and ignoring) strike-through text in cells. I found your module very easy to work with too, great documentation. I have a lot of refactoring in my future to consolidate some of my existing row/col/cell brute-force operations to take advantage of some methods in your module, which were not available in the module I was using previously.

However, I found out that there are 4 use cases I need to handle, where the cell contains a mixture of strike-thru and non-strike-thru text, and currently I'm only catching 2 of those use cases (up to the first occurrence of strike in the cell). Any thoughts on how to handle this?

  1. cell contains just strike-through text: good, I can detect and ignore the text
  2. cell contains plain text followed by strike-through text: good, I can keep the plain text and ignore the strike-through text
  3. cell contains strike-through text followed by plain text: bad, I want to keep the plain text, but I end up ignoring everything after the first strike.
  4. cell contains plain text followed by strike-through text followed by plain text: bad, I am only keeping the text up-to the first strike-through char, and I need the plain text after the strike-throughs too.

@pdapel pdapel changed the title quick question quick question - strike-through font detection Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants