Reputation: 303
I need some help to pass multi line text that I stored in ArrayLists into Excel cells. I made a parser to get values from each tag and now i'm trying to build my excel but I faced a problem that text from tags like this
<ProgramName>Mirror \n 2017</ProgramName>
looks like this Mirror \\n 2017
if I manually copy it into setCellValue and I thinks this double slash is my problem but I have no idea why it's even here. and my code can't make it into a new line
//progName style
CellStyle cs = wb.createCellStyle();
cs.setWrapText(true);
cs.setVerticalAlignment(VerticalAlignment.CENTER);
cs.setAlignment(HorizontalAlignment.CENTER);
//progName text
Row row = sheet1.createRow((short) 1);
Cell cell = row.createCell((short) 1);
row.setHeightInPoints((2*sheet1.getDefaultRowHeightInPoints()));
String asd = String.valueOf(ProgramName.get(0));
cell.setCellValue(asd);
sheet1.addMergedRegion(new CellRangeAddress(1,1,1,8));
Upvotes: 2
Views: 83
Reputation: 303
thanks to Andreas
String asd = String.valueOf(ProgramName.get(0)).replaceAll("\\\\n", "\n");
Upvotes: 1