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

Free Support Forum - aspose.com

Add a bullet before each line in a cell in excel sheet

Hi,


We are using Aspose cell for JDK1.4 in our application.

We have a requirement to put “bullet” before each line in cell.

Attached here the screenshot.
I tried to find it out in Aspose documentation as well as over the internet but not able to.

Pls let us know how to achieve it.

Thanks,
Uttam K.

Hi,


Thanks for your posting and using Aspose.Cells.

Please share your excel file as you have shown in your image. We have looked into this issue and found this is not supported by Microsoft Excel. Please note, if it is not supported by Microsoft Excel, then Aspose.Cells will also not be able to support it. Thanks for your understanding and cooperation in this regard and have a good day.

Hi,


Thanks for the quick response.
Attached here excel sheet.

Regards,
Uttam K.

Hi,


Thanks for your sample excel file and using Aspose.Cells.

We have looked into your file and found, bullet characters are inside your text. So these are not bullets like MS-Word adds, these are actually bullet characters inside the text just like the following text contains “aaaa\n\naaaa” contains “\n” inside the text. Similarly, your text contains bullet characters. It means, your bullets are added manually not via Microsoft Excel.

Please check the following sample code and its output excel file for a reference. The code just copies your text into cell C5 and C5 shows the bullets just like A1 displays them.

Java
//Open workbook
Workbook wb = new Workbook(dirPath + “Bullet.xlsx”);

//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);

//Access cell A1
Cell a1 = ws.getCells().get(“A1”);

//Access A1 string value, actually it contains Bullet characters
String str = a1.getStringValue();

//Put the A1 string value in cell C5
Cell c5 = ws.getCells().get(“C5”);
c5.putValue(str);
//Set the text wrap of cell C5
Style s = c5.getStyle();
s.setTextWrapped(true);
c5.setStyle(s);

//Set C5 height and width
ws.getCells().setRowHeight(c5.getRow(), 70);
ws.getCells().setColumnWidth(c5.getColumn(), 20);
//Save the output excel file
wb.save(dirPath + “output.xlsx”);

Hi,


Thanks!!!
But I need to read the lines from some data source say database and put a bullet mark before every new line character.

This Bullet.xls I have created manually for your reference how the output should look like.

Regards,
Uttam K.

Hi,


Thanks for your posting and using Aspose.Cells.

I have added more detail in my previous post. Please check it. This is your text

"● Bullet\n● Bullet\n● Bullet\n● Bullet"

as you can see the bullet character ● is inside your text. This bullet character is Unicode character and its value is 9679. So you can print it with following code.

Java
System.out.println((char)9679);

Here is the console output of the above code

Console Output:


Hi,


Text from database I am getting as for e.g. “This is my bullet”. Now I need to put this sentence in cell with bullet mark before the sentence.

Regards,
Uttam K.

Hi,


Thanks for your posting and using Aspose.Cells.

The following sample code shows how to add a bullet text in cell A5 from scratch. It should help you fix your issue. I have also attached the output excel file generated by the code and the screenshot for a reference.

Java
//This is your text from database
String strText = “This is my bullet”;

//This is your bullet character with space
String strBullet = "● ";

//This is now a text with bullet character
String strBulText = strBullet + strText;

//Now put bullet text in cell A1
Workbook wb = new Workbook();
Worksheet ws = wb.getWorksheets().get(0);

Cell cell = ws.getCells().get(“A5”);
cell.putValue(strBulText);

//Save the workbook
wb.save(dirPath + “output.xlsx”);