javaapache-poihssfworkbook

hyphen is converted into diamond black question mark, while setting Excel column header using apache POI


work book creation

HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet dashboardData = workbook.createSheet("name of the excel sheet");

this is where I am creating the header

cell = row.createCell(3);
cell.setCellValue("Subscriber Count - Active");
cell.setCellStyle(style);

Solution

  • The black diamond with a question mark is a missing-character symbol: The "hyphen" in your header is a non-ascii character (probably inserted by your text editor in place of a typed "-"), which is not available in the font you are using for display. There is also an ascii hyphen character, but clearly you are not using it.

    Usually this happens when a text editor (e.g., Word) replaces a typed hyphen, quote, or other character with a typographically nicer but less widely available symbol. This is a well-known source of problems with online text. Sounds like you copy-pasted the offending text from elsewhere, so to fix the problem, simply edit your code in your programming editor or API and manually type in an ascii hyphen.