• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Add zero width space to excel cell value

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am generating an excel sheet using apache poi HSSFWorkbook. One of the excel column is showing error message about "Number stored as text". This column is not a numeric column,and want to keep that column as character column.

So while adding value to cell , I add a zero width Unicode character also as follows cell.setCellValue(cellData + "\\U+200B");

The issue is, cell value just print "U+200B" in excel sheet, instead of using the Unicode zero width space.

I would like to know, is there any way I can add a zero width space to poi cell value in java.

I want to keep the column as character column, but want to get rid of the message"Number stored as text" in excel.

Thanks
 
Sheriff
Posts: 28333
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does that because you added the 7-character string "\U+200B" to the cell, rather than the character U+200B. The way to express that character as a Unicode escape in Java is like this:

 
Mathew Antony
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul
 
Paul Clapham
Sheriff
Posts: 28333
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully that did what you wanted. But wouldn't you get the same effect from just changing the cell's type to Cell.CELL_TYPE_STRING? Or did you try that already?

(I'm not sure that would make Excel believe the cell was a string cell, but it seems to me like it should. On the other hand I haven't tried it myself so maybe it doesn't.)
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic