We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Values Repeating in Cell when using new line character in middle of String

Hi ,

I am using Aspose.cells to generate excel file in java and my requirement is to write the data into a cell. Into each cell i have to write the string which is converted from a list of string. I have to use a new line character to join each list entry when converting to string. But when i tried to do this and write into excel cell the data is being repeated in the same cell.

But when I tried using some other special character when converting to the string the output is correct. But this doubling issue i am facing only when i use new line character(\n).

The version of Aspose.cells which i am using is 17.12. I tried with the latest release versions also but the data is still getting repeated in other versions also. I had checked on the code which i wrote and found no issues.

Can someone please help me out in this.


Thanks for the details.

In MS Excel, when you use new line character (e.g "\n" ), it will work only when you set wrapping text on for the cell, see the sample code for your reference. You may refer to the sample code and write/update your code by yourself accordingly:
Sample code:

 Workbook wb = new Workbook();

            Worksheet sheet = wb.Worksheets[0];

            Cell cell = sheet.Cells["A1"];

            cell.PutValue("(1)this is first line\n (2)This is second line\n  (3)This is third line");
            Style style = cell.GetStyle();
            style.IsTextWrapped = true;


            sheet.Cells.SetColumnWidth(0, 22);


Hope, this helps a bit.


Thanks for the reply.

I have tried using set wrapping text , but still the issue exists.

I am attaching the screenshot of a cell where i am having the issue.Capture.JPG (8.4 KB)

But when i tried to get the value of cell using cell.getValue() after and before saving the file the value is,

Can you please take a look.

We have tried to reproduce this issue using our sample code as follows but could not observe this issue.

Could you please share your runnable console application along with template file (if any)? Share your expected output file also created by using MS Excel for our reference.