Results 1 to 3 of 3

Thread: Adding Image into a excel cell and adding a hyperlink to the image

  1. #1

    Adding Image into a excel cell and adding a hyperlink to the image



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I have a requirement to create an excel and add an image into a cell and add hyperlink (url ) to the image. I am trying with Apache POI HSSF to achieve the functionality.

    The image to be placed in the cell will be a thumbnail image (small one). Hyperlink to the image will be an url that take you to the full size image.

    When I add an image into the cell with anchor option, the image is floating and didnít reside within the cell. The suggestion was to have an idea of the image dimension and provide the row and cell width accordingly. But could not add a hyperlink to the image though.

    Please provide your inputs on whether this is feasible with Apache POI HSSF.


    Thanks
    Saravanan

  2. #2
    Administrator Simon Lloyd's Avatar
    Join Date
    Apr 2011
    Location
    Manchester, England
    Posts
    297
    Articles
    0
    I guess the really simply way is this
    Code:
    'select a cell to locate picture at
    Range("G1").Select
    'get the picture
    ActiveSheet.Pictures.Insert("C:\Users\YOUR NAME\Pictures\mypic.jpg").Select
    'select the action with the cell
    Selection.Placement = xlMoveAndSize
    'optional "Alt Text" you don't need this line
    Selection.ShapeRange.Title = Range("A1").Value
    'add the hyperlink to the currently selected cell
    ActiveSheet.Hyperlinks.Add Anchor:=Selection.ShapeRange.Item(1), Address:= _
    http://www.yoursite.com/google.jpg
    Kind regards,
    Simon Lloyd
    Microsoft Office Discussion

  3. #3


    Register for a FREE account, and/
    or Log in to avoid these ads!

    Thanks Simon Lloyd. I am creating excel file using java and require the functionality using any Java API. I am using Apache POI HSSF, but could not add hyperlink to the image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •