Save old formatting when inserting hyperlink to cell

Hi,

I am using aspose.cells for Java. When I try to set hyperlink to cell using HyperlinkCollection add() method, link text appears in cell with blue color and underline font (which is typical for any link). Is there any way to avoid having that typical hyperlink formatting in cell when inserting hyperlink, and to save old formatting, which was in cell before inserting hyperlink to that cell?

Regards,
Milorad

@Milorad,
I have tried this scenario using Excel but could not achieve it. The cell in the sample file has some formatting like larger font, bold and red. If I set the hyperlink in the cell using Excel, it automatically changes the formatting like colour to blue and text is underlined. It shows that its default behaviour of Excel and as Aspose.Cells mimics the behaviour of Excel, so it is not an issue with Aspose.Cells. However, if you can perform your required task using Excel, please share the steps with us. We will try to provide the same feature using Aspose.Cells.

You may achieve this functionality using following simple code if required. It saves the original formatting of the cell and then sets it back after setting the hyperlink.

Workbook workbook = new Workbook(); // Creating a Workbook object
Worksheet sheet = workbook.getWorksheets().add("Hyperlinks");
HyperlinkCollection hyperlinks = sheet.getHyperlinks();

/*
//Use following code if you want to set formatting of your own choice
Style style = new CellsFactory().createStyle();
style.getFont().setUnderline(FontUnderlineType.SINGLE);
style.getFont().setColor(Color.getRed());
sheet.getCells().get(0, 0).setStyle(style2);
workbook.save("test2.xlsx");
*/

Style style2 = sheet.getCells().get(0, 0).getStyle();

sheet.getCells().get(0, 0).setValue("URL Link");
hyperlinks.add(0, 0, 1, 1, "http://www.aspose.com");
sheet.getCells().get(0, 0).setStyle(style2);
workbook.save("test2.xlsx");