New line character in word

Hi Alexey Noskow,

This is regarding XLS to word converter, am getting some junk character (small box), when ever a new line character (alt +Enter) with in the cell is given. In the excel sheet, with in the cell its clear, but when i convert it to word, this new line char is not recognised.

Pl find the attached of both excel and converted word document.

Can u help me solving this problem.

Warm Regards
Lokesh K

Hi Lokesh,

Thanks for your inquiry. As I can see line break in Excel workbook is considered as LineFeed in Word document. So to resolve the problem you should just replace LineFeed with LineBreak character. See the following modified method:

///
/// Get text with formating from Excel cell
///
/// Input Excel cell
/// Parent document
/// Run that contains text with formating
private Run GetTextFromCell(com.aspose.cells.Cell cell, Document doc) throws Exception
{
    Run run = new Run(doc);
    run.setText(cell.getStringValue().replace(ControlChar.LINE_FEED_CHAR, ControlChar.LINE_BREAK_CHAR));
    // Convert Excel Font to Words Font
    ImportFont(run.getFont(), cell.getStyle().getFont());
    return run;
}

Hope this helps.
Best regards.

Thanks a lot… its working…