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

Free Support Forum - aspose.com

How to put multiple hyperlinks in one cell in excel sheet

Hi,


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

We have a requirement to put multiple hyperlinks in one cell in excel sheet.

I tried to find it out in Aspose documentation but not able to.

Pls let us know how to achieve it.

Thanks,
Uttam K.

Hi,


Thanks for your query.

How could you do this in MS Excel manually? I am not sure if this is possible in MS Excel. Aspose.Cells follows MS Excel standards and specifications, so if something is not possible in MS Excel, it is also not possible by Aspose.Cells APIs.

If you still think you can add multiple hyperlinks in a single cell in the worksheet, do create a sample Excel file in MS Excel manually and provide us here with all the details on how to do that, we will check it soon.

Thank you.

Hi,

Thanks for the prompt reply!!!

We are not able to put multiple text with hyperlinks in one cell.

We did another workaround and can put manually 2 images in one cell and link it to different hyperlinks. PFA attached sheet.

Single image I put by giving row and column number(cell position):-

Picture pic = sheet.getShapes().addPicture ( row, col, inStream);
String hyperlinkURL =
pic.addHyperlink( hyperlinkURL );

Pls let us know how to add more than one images in one cell and put a hyperlink to it using Aspose API.

Regards,
Uttam K.

Hi,

Thanks for the template file.

Please see the following sample code that shows how to add multiple images (hyperlinked to a cell and reposition them a bit in the cell. I have also attached the output file for your reference.

e.g

Sample code:

//Instantiating an Workbook object

Workbook workbook = new Workbook(“VideoLinks.xls”);

//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet = workbook.getWorksheets().get(0);

//Adding a picture to B3 cell.

int pictureIndex = worksheet.getPictures().add(2, 1, “e:\test\school.jpg”, 40, 40);

//Accessing the newly added picture

Picture picture = worksheet.getPictures().get(pictureIndex);

//Positioning the picture accordingly

picture.setUpperDeltaX(200);

picture.setUpperDeltaY(10);

//Adding an hyperlink.

picture.addHyperlink(“http://www.google.com/”);

//Adding another picture at the location of the cell 

pictureIndex = worksheet.getPictures().add(2, 1, “e:\test\school.jpg”, 40, 40);

//Accessing the newly added picture

Picture picture1 = worksheet.getPictures().get(pictureIndex);

//Positioning the picture accordingly

picture1.setUpperDeltaX(200);

picture1.setUpperDeltaY(120);

//Adding an hyperlink.

picture1.addHyperlink(“http://www.yahoo.com/”);

//Extend the column width a bit.

worksheet.getCells().setColumnWidth(1,14);

//Saving the Excel file

workbook.save(“out1.xlsx”);

Hope, this helps a bit.

Thank you.