[Help me] cell writing not work! #595

Closed
opened 2017-03-14 13:01:17 +00:00 by seunggabi · 20 comments
seunggabi commented 2017-03-14 13:01:17 +00:00 (Migrated from github.com)

Hello.
I have a issue
the issue is [enter key] not working cell

asdf[enter]asdf
==== cell update ===>
asdf
asdf

I don't understand. this was situation....
I need your help..

In fact, I am making Excel Merge Tool(EMT)
https://github.com/seunggabi/excel-merge-tool
If you help, you can make it successful.

I will wait for your help :)

Hello. I have a issue the issue is [enter key] not working cell asdf[enter]asdf ==== cell update ===> asdf asdf I don't understand. this was situation.... I need your help.. In fact, I am making Excel Merge Tool(EMT) https://github.com/seunggabi/excel-merge-tool If you help, you can make it successful. I will wait for your help :)
SheetJSDev commented 2017-03-14 18:13:40 +00:00 (Migrated from github.com)

@seunggabi What do you mean by "enter key"? are you trying to insert a newline "\n" in a cell?

@seunggabi What do you mean by "enter key"? are you trying to insert a newline `"\n"` in a cell?
seunggabi commented 2017-03-15 13:57:48 +00:00 (Migrated from github.com)

Yes, I am

[now..]
"asdf"+String.fromCharCode(13)+"asdf" => asdf asdf
====excel file open & cell update====> asdf\nasdf

@SheetJSDev
I will wait for your help :)

Yes, I am [now..] "asdf"+String.fromCharCode(13)+"asdf" => asdf asdf ====excel file open & cell update====> asdf\nasdf @SheetJSDev I will wait for your help :)
SheetJSDev commented 2017-03-16 01:55:43 +00:00 (Migrated from github.com)

@seunggabi we will have an answer soon. The different formats treat the character codes 0x0A and 0x0D in subtly different ways, mainly because Excel isn't entirely consistent.

(related https://github.com/SheetJS/js-xlsx/issues/108).

@seunggabi we will have an answer soon. The different formats treat the character codes `0x0A` and `0x0D` in subtly different ways, mainly because Excel isn't entirely consistent. (related https://github.com/SheetJS/js-xlsx/issues/108).
seunggabi commented 2017-03-16 04:08:33 +00:00 (Migrated from github.com)

@SheetJSDev Thanks you sir.

I understand your word.
You told me, it(\n update issue) is not working, however You will have an answer soon. isn't it?

@SheetJSDev Thanks you sir. I understand your word. You told me, it(\n update issue) is not working, however You will have an answer soon. isn't it?
SheetJSDev commented 2017-03-16 22:07:08 +00:00 (Migrated from github.com)

Ok I looked into this a bit. There are two parts.

  1. what character should be used?

ODS/FODS accept either \n or \r based on my tests, whereas Excel only accepts \r.

  1. how do you get excel to show multiple lines?

If you do that, the cell won't show up in 2 lines but you can select the cell and enable "Wrap Text" (right-click the cell, go to format cells, then "Alignment" tab then check "Wrap Text") and you will see it display as multiple lines.

This is written as part of the cellXfs block which is something we need to support.

Ok I looked into this a bit. There are two parts. 1) what character should be used? ODS/FODS accept either `\n` or `\r` based on my tests, whereas Excel only accepts `\r`. 2) how do you get excel to show multiple lines? If you do that, the cell won't show up in 2 lines but you can select the cell and enable "Wrap Text" (right-click the cell, go to format cells, then "Alignment" tab then check "Wrap Text") and you will see it display as multiple lines. This is written as part of the cellXfs block which is something we need to support.
seunggabi commented 2017-03-20 04:28:15 +00:00 (Migrated from github.com)

@SheetJSDev

Okay, I understand your word.
I appreciate your tips No.2

I learned 'Wrap Text' because of you.
If I need help, I'll ask you another question.

@SheetJSDev Okay, I understand your word. I appreciate your tips No.2 I learned 'Wrap Text' because of you. If I need help, I'll ask you another question.
seunggabi commented 2017-04-20 09:36:33 +00:00 (Migrated from github.com)

@SheetJSDev

Thank you!
I solved it.
cell.s = {wrapText: true}

it is cool!

@SheetJSDev Thank you! I solved it. cell.s = {wrapText: true} it is cool!
gdoteof commented 2017-08-15 16:35:35 +00:00 (Migrated from github.com)

In case anyone else comes here looking for wrapText, @seunggabi solution was not quite right.

cell.s = {alignment:{ wrapText: true }} works for me. as seen here:

935821423f/bits/47_styxml.js (L307)

In case anyone else comes here looking for wrapText, @seunggabi solution was not quite right. `cell.s = {alignment:{ wrapText: true }}` works for me. as seen here: https://github.com/SheetJS/js-xlsx/blob/935821423f2ff83412f39aac9ee201e975351978/bits/47_styxml.js#L307
superlbr commented 2018-04-24 03:38:18 +00:00 (Migrated from github.com)

@gdoteof would you please give an example, it just not work for me.
\r also not work, I have to click the cell so to split.
bookSST seems unrelated

@gdoteof would you please give an example, it just not work for me. `\r` also not work, I have to click the cell so to split. bookSST seems unrelated
kamthe commented 2018-05-02 10:41:36 +00:00 (Migrated from github.com)

@gdoteof, Can you please tell me which file do i need to refer for wrapping the text in cell? i am using xlsx.full.min.js. but it is not applying any style for the generated excel file.

@gdoteof, Can you please tell me which file do i need to refer for wrapping the text in cell? i am using xlsx.full.min.js. but it is not applying any style for the generated excel file.
gdoteof commented 2018-05-02 17:16:47 +00:00 (Migrated from github.com)

@superlbr and @kamthe

Sorry for the messy thoughts here; I am just waking up and haven't really touched any of this in about a year. AND -- it's all very, very messy.

That being said I believe both of your issues are related to the fact that you are using the wrong js-xlsx. There are two (this repo) and and js-xlsx-style which actually has styling semi-well implemented.

Could you please retry either using my fork here: https://github.com/gdoteof/js-xlsx

or the (original?) js-xlsx-style fork here: https://github.com/protobi/js-xlsx

@superlbr the example you are looking for here is here:

https://github.com/protobi/js-xlsx/issues/16

specifically you would be looking to do something like

      "A1": {
        "v": "CELL TEXT HERE ",
        "s": {
          "alignment": {
            "wrapText": 1,
          }
        },
        "t": "s"
      },
@superlbr and @kamthe Sorry for the messy thoughts here; I am just waking up and haven't really touched any of this in about a year. AND -- it's all very, very messy. That being said I believe both of your issues are related to the fact that you are using the wrong js-xlsx. There are two (this repo) and and js-xlsx-style which actually has styling semi-well implemented. Could you please retry either using my fork here: https://github.com/gdoteof/js-xlsx or the (original?) js-xlsx-style fork here: https://github.com/protobi/js-xlsx @superlbr the example you are looking for here is here: https://github.com/protobi/js-xlsx/issues/16 specifically you would be looking to do something like ```javascript "A1": { "v": "CELL TEXT HERE ", "s": { "alignment": { "wrapText": 1, } }, "t": "s" }, ```
superlbr commented 2018-05-03 02:28:33 +00:00 (Migrated from github.com)

@ gdoteof not work yet.

  1. use '\r', then x000d will show in my mobile browser
  2. write as protobi#16, not work though. should I use protobi/js-xlsx?
@ gdoteof not work yet. 1. use '\r', then x000d will show in my mobile browser 2. write as protobi#16, not work though. should I use protobi/js-xlsx?
superlbr commented 2018-05-03 02:59:05 +00:00 (Migrated from github.com)

I find an example https://codepen.io/superlbr/pen/bMEXGE?editors=0111, but don't know how it work...

I find an example https://codepen.io/superlbr/pen/bMEXGE?editors=0111, but don't know how it work...
gdoteof commented 2018-05-03 03:15:26 +00:00 (Migrated from github.com)

@superlbr if you are just trying to do lines, \n should work fine.

Only use the protobi version if you need styling (colors and borders and stuff)

@superlbr if you are just trying to do lines, \n should work fine. Only use the protobi version if you need styling (colors and borders and stuff)
superlbr commented 2018-05-03 03:32:24 +00:00 (Migrated from github.com)

@ gdoteof use \n , I need to click the cell to edit, then it wrap...

@ gdoteof use \n , I need to click the cell to edit, then it wrap...
gdoteof commented 2018-05-03 03:46:31 +00:00 (Migrated from github.com)

@superlbr sorry I didn't understand. The answer is yes, this will not work for you (this word wrapping is considered styling which is not supported in this. Use the protobi version if you want styling.

Does this one do wwhat you want? https://codepen.io/gdoteof/pen/aGwBrL?editors=1111

@superlbr sorry I didn't understand. The answer is yes, this will not work for you (this word wrapping is considered styling which is not supported in this. Use the protobi version if you want styling. Does this one do wwhat you want? https://codepen.io/gdoteof/pen/aGwBrL?editors=1111
superlbr commented 2018-05-03 06:16:46 +00:00 (Migrated from github.com)

yes, it works. Seems little difference between web side and server side.

yes, it works. Seems little difference between web side and server side.
seunggabi commented 2018-08-17 03:04:21 +00:00 (Migrated from github.com)

@gdoteof thanks~
I agree your comment.

@gdoteof thanks~ I agree your comment.
sky172839465 commented 2019-03-24 05:24:50 +00:00 (Migrated from github.com)

Thanks @gdoteof 's demo !
However it seems broken, after fix broken code it work for me !
Using xlsx-style instead of xlsx, and wrap line (A4) work perfect !

螢幕快照 2019-03-24 下午1 23 47
Thanks @gdoteof 's demo ! However it seems broken, after fix broken [code][] it work for me ! Using xlsx-style instead of xlsx, and wrap line (A4) work perfect ! <img width="214" alt="螢幕快照 2019-03-24 下午1 23 47" src="https://user-images.githubusercontent.com/9082423/54875331-1b9e3900-4e38-11e9-85a9-0fab5414a45b.png"> [code]: https://codepen.io/Hsunight/pen/qvgVOW?editors=0011
gdoteof commented 2019-03-26 13:45:41 +00:00 (Migrated from github.com)

thanks @sky172839465 i am not sure why i had that type hinting thing in there that was broken. i updated the gist in case anyone else comes to it

thanks @sky172839465 i am not sure why i had that type hinting thing in there that was broken. i updated the gist in case anyone else comes to it
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#595
No description provided.