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.

@Anvesh_popuri,

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:
e.g
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;

            cell.SetStyle(style);

            sheet.Cells.SetColumnWidth(0, 22);
            sheet.AutoFitRow(0);

            wb.Save("e:\\test2\\out1.xlsx");

Hope, this helps a bit.

@Amjad_Sahi

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,
ABC
DEF
GHA
AFA
CPA
ABCD
DEFA
KLIO
MNOP

Can you please take a look.

@Anvesh_popuri,
We have tried to reproduce this issue using our sample code as follows but could not observe this issue.
cell.putValue("ABC\nDEF\nGHA\nAFA\nCPA\nABCD\nDEFA\nKLIO\nMNOP\nABC\nDEF\nGHA\nAFA\nCPA\nABCD\nDEFA\nKLIO\nMNOP");

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.