Using Apache POI 3.2 to create hyperlinks in Excel

Hello,
I am new to Java.
I have written a program that accesses Excel with the Apache POI version 3.2.
All seems to work until I tried to insert a Hyperlink to a file on the local drive.
I followed the quick start guide from Apache POI.
It provides the following code but Java does not appear to find the "createHelper".
//link to a file in the current directory
cell = sheet.createRow(1).createCell((short)0);
cell.setCellValue("File Link");
link = createHelper.createHyperlink(Hyperlink.LINK_FILE);
link.setAddress("link1.xls");
cell.setHyperlink(link);
cell.setCellStyle(hlink_style);
Any ideas on how to insert a Hyperlink into Excel would be appreciated.
Thanks
Chris

This seems to be a class in 3.5 beta jar file. Try downloading and using the 3.5 beta

Similar Messages

  • Exception when using Apache POI in ADF

    Goodmorning;
    i'm using jdev 11g, i m trying to use Apache POI to import the content of Microsoft XL file into my database.
    i already do that succesfully on netbeans. but not on jdev.
    first i download the POI package from the apache web site, and i create a librarie and add the jar files to the jdev by using Tools --> Manage Libraries, this is the list of the jar file : poi-3.6-20091214.jar, poi-contrib-3.6-20091214.jar, poi-ooxml-3.6-3-20091214.jar and poi-scratchpad-3.6-20091214.jar.
    next, create a jsf page with a boutton, then i enable the binding of this page by using Design --> Page Properties --> component binding --> check Auto Bind
    in the action method of the buton i put the following code :
    public String cb1_action() throws FileNotFoundException, IOException {
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "test";
    String driver = "com.mysql.jdbc.Driver";
    String username = "root";
    String userPassword = "";
    try {
    InputStream fs = new FileInputStream("/home/Rachid/test1.xls");
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    HSSFSheet sheet = wb.getSheetAt(0);
    HSSFRow row = null;
    for (Iterator rowIt = sheet.rowIterator(); rowIt.hasNext();) {
    row = (HSSFRow) rowIt.next();
    HSSFCell code = row.getCell(0);
    HSSFCell nom = row.getCell(1);
    HSSFCell dt = row.getCell(2);
    java.util.Date date = dt.getDateCellValue();
    System.out.println("code "+code+" % nom "+nom +" % date " +date);
    try {
    Class.forName(driver).newInstance();
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    try {
    conn = DriverManager.getConnection(url+dbName,username,userPassword);
    } catch (SQLException e) {
    Statement stmt = null;
    try {
    stmt = conn.createStatement();
    } catch (SQLException e) {
    String strQuery = "insert into importxl values ("+code+",'"+nom+"','"+date.getDay()+"/"+date.getMonth()+"/"+date.getYear()+"')";
    System.out.println(strQuery);
    try {
    stmt.close();
    } catch (SQLException e) {
    try {
    conn.close();
    } catch (SQLException e) {
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    return null;
    and when i run my page and click on the button, this exception page appear :
    Error 500--Internal Server Error
    javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:94)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:698)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:285)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         ... 35 more
    Caused by: java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
         at Mybean.bean1.wrc(bean1.java:23)
         at Mybean.MybeanImport.cb1_action(MybeanImport.java:53)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 43 more
    Caused by: java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFWorkbook
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
         at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:37)
         ... 52 more

    Hi John,
    Ya ur right i too agree we can go for shared Libraries for reusable or massive apps but we still dont know whether OP is gng on the way and also i never said dont go for shared Libraries+
    May be he will be running the application locally for any testing purpose..... if it so i have suggested him not to keep the jar files in the folders outside the project....
    Why becoz incase the jar file kept in outside folder,
    if the folder gets deleted or some times if it kept in any shared folder and user loses the permission error will be thrown it cant be traced why the error gets throwned....
    if the jar is gng to be referred from local best way is to keep it in the project folder itself.............
    Regards,
    Suganth.G

  • Create Hyperlink in Excel

    Hi all,
    I looked through the excel examples that ship with labview. I found out how to get data into excel cells and read from them. But I still look out how to create a hyperlink that is connected to a text in an excel cell. I think this could be done without using the report generation toolkit, that I don't have.
    Best Regards,
    Toni

    Hi All,
    here is the solution for it.
    i am able to put a hyperlink into excel now.
    Hope this helps you. 
    Regards,
    Dev
    CLD Certified Engineer
    Attachments:
    Hyperlink.JPG ‏47 KB

  • Distinguish Excel Dates from Numbers - Using Apache POI

    EDIT: I know this is a common issue, I have read plenty of people reporting the problem, but I have not found a acceptable answer. -- Please help.
    O.K. so I have a little class that reads an excel table, and writes the cell values to XML.
    The program has always worked great, and even handles the different cell types; boolean, string, formula, numbers.
    Problem is dates. Date cells are treated equal to number cells, but I need to distinguish their format type. Right now I read them all as numbers, but I need to change this, because dates occur like 35356(days since jan 01 01).
    I tried some basic formating checks;
    System.out.println("Date Debug:");
                                            System.out.println(".isValidExcelDate: "+HSSFDateUtil.isValidExcelDate(currentRow.getCell((short) (useColumn)).getNumericCellValue()));
                                            System.out.println(".isCellDateFormatted: " +HSSFDateUtil.isCellDateFormatted(currentRow.getCell((short) (useColumn) )));
                                            System.out.println(".isInternalDateFormat: "+HSSFDateUtil.isInternalDateFormat((int) (currentRow.getCell((short) (useColumn)).getNumericCellValue() )));
    //                                   But they return true false false for any number..riddiculus!
    Anyway, as it will work now, I'll just read the columns header for a 'date' in the the title. I am anxiously seeking better ideas, please suggest.
    Thanks so much!
    Notes:
    *before and after are not acceptable, because i will have values above 39000 for numbers and dates as low as 1971.
    * some reason i can't just read the value as it is displayed in excel ('2007-08-28') which is what I'd prefer. (If you think i can, please let me know how)
    *please ask any questions to clarify my situation to resolve :-)
    Message was edited by:
    Masterkeedu
    Acknowledged commonality

    This seems to be a class in 3.5 beta jar file. Try downloading and using the 3.5 beta

  • Apache Poi Excel Question

    If I use Apacha Poi to create an xls on a machine that doesn't have excel, can I still read the values using Apache Poi HSSF of the create xls?

    yes, POI is independent of Excel being installed.

  • Excel File Management Apache POI HSSF vs. jxl jar

    I've been reviewing Java technologies for managing Excel files, and I'm a little confused about the differences between Apache's POI HSSF implementation and JExcelApi, and utimately what technology it makes sense to use.
    They are both open source, although POI is backed by Apache, where JExcelApi seems to be open source developed by Andy Khan. It seem Apache has a little more weight, therefore may be a better option.
    Can someone who has exposure to these technologies please provide me with some insight.
    Thanks.

    Hi
    Thanks for your reply,
    Now I hav used an alternate approach of using Apache POI.
    But.......
    I have created simple table in jsp and set content type to
    <%@ page contentType="application/vnd.ms-excel" %>
    when i navigate to this jsp it is getting displayed in excel format.
    I wish if user clicks on to navigate for this jsp, he must get an option to either open, save or cancel the jsp.
    Then on selecting save a dialogue gets appeared where he can select path and file name.
    Please comment.
    Thanks.

  • Excel Parsing -org.apache.poi.hssf.record.RecordFormatException

    Hi ,
    I am running into org.apache.poi.hssf.record.RecordFormatException,
    while creating excel work book.
    Few of the worksheets in the workbook are password protected.
    If i remove the password proted worksheets then i am able to load the
    workbook and can parse it.
    I am using apache poi 2.5.1.
    Is it possible to load workbook having few password proted sheets using apache POI?
    I appreaciate any help in this.
    Thanks in advance
    Mark
    code.
    POIFSFileSystem fs =new POIFSFileSystem(input);
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    Exception log:
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled Code))
    at java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
    at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java(Compiled Code))
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled Code))
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
    at com.cargill.aim.examples.ExcelParseTest.main(ExcelParseTest.java:43)
    Caused by: java.lang.ArrayIndexOutOfBoundsException
    at java.lang.System.arraycopy(Native Method)
    at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
    at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
    at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
    at org.apache.poi.hssf.record.Record.fillFields(Record.java(Compiled Code))
    at org.apache.poi.hssf.record.Record.<init>(Record.java(Compiled Code))
    at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
    ... 9 more
    Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance, the following exception occured: null
    at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java(Compiled Code))
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled Code))
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
    at com.cargill.aim.examples.ExcelParseTest.main(ExcelParseTest.java:43)

    Hi,
    I am dealing with the similer problem but the same error. I am using the latest version of POI 3.0.1 and trying to read the cells which have auto formating enabled for date. I am getting the same error. Please let me know if you come across any solution to read the formatted cells using POI.
    Thanks in advance!
    - Alok

  • Create Output to Excel from PL/SQL

    I've created a procedure that generates an excel output. The output is generated if the number of rows are less than 850. If more than 850, I received a "Page Not Found" error.
    I used Note:132262.1 "How to Create Output to Excel from PL/SQL".
    Does anybody know a fix or workaround for this issue?

    It might be worth your time to check out owa_sylk from asktom.oracle.com. It's a pl/sql package that generates SYLK files, which Excel can then open. By using a standard file format instead of a proprietary one you get away from most of the "which version of Excel" issues.
    Scott

  • Creating Hyperlink using POI Java API

    Hi
    I am using HSSF Cell and row for creation of my excel report. Now is it possible to create an external hyperlink to my data in the excel. If so can anyone tell me the process.
    Is it possi ble by any other process
    Regards
    Kalyan

    Ok, thanks for your quick answer. I saw you last blog posting regarding simple bar codes, I hope your next one turns up soon (read: today ;-) ).
    I did take a swing at writing my own class according to the user guide, using JDeveloper. One of my problems is that I am not that familiar with the whole java world, my experience lies almost entirely within .NET development. So when I read stuff like "make sure the class is available in the classpath for the JVM" and things like that, it is not a detailed enough description for me in order to make anything out of it. Do you think you can clarify that for me?
    I also wonder if you have any tips and tricks on how to trace/log information from the class when it executes? Because I think that I can actually get it to be called, it's just that something goes wrong and the generated PDF becomes badly formatted and has no content. I can see that some calls are made to a Logger class inside the example class. I guess that I need to set up some runtime configuration for that information to turn up in a file, but again me lacking experience from the java world prevents me from accomplishing that :-)
    Regarding tracing and logging from the java classes for the BI Publisher, can I get them to trace or log debug information in some clever way?
    The app I am developing is a .NET app that calls these classes using a product called juggerNET. I am developing a print direct application for JDEdwards EnterpriseOne since BI Publisher is not entirely integrated into it yet.
    I would greatly appreciate a quick reply this time as well if you can find the time!
    Best regards, Jörgen

  • How to read .XLSX files using org.apache.poi.ss.usermodel.* classes

    Hello,
    I want to read in excel files to a JTable. I was able to read in .xls files, but have problems reading .xlsx files. Maybe there is something i need to add to the following code:
    FileInputStream iStream = new FileInputStream(newFile);
    POIFSFileSystem fs = new POIFSFileSystem(iStream);
    Workbook wb1 = WorkbookFactory.create(fs);
    Sheet sheet = wb1.getSheetAt(0);       // get the first sheet data
    // Iterate over each row in the sheet
      Iterator rows = sheet.rowIterator();
       while(rows.hasNext()) {
          Row row = (Row) rows.next();
          .............The compiler is complaining about the 3rd line: Workbook wb1 = WorkbookFactory.create(fs);
    Thanks.

    @ejp:
    I quite agree with you. It's a runtime exception -
    org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)I've tried searching before coming here to ask. HSSF processes .xls files only, XSSF processes .xlsx files only while SS is supposed to read both .xls and .xlsx files. Maybe there's anyone that has used it before who can help out.
    Thanks

  • How to create hyperlink in Html page using Java

    Hello every one
    I want to know that how can I create a hyperlink in Html page using java ?
    Let for example
    I have code like this and i want to give hyperlink to it using java.
    rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
    <tr>
    <td ><span id="name"></span>
    </tr>

    but i m using this code to create node in html file
    HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
    Text txt = appHTML.createTextNode(name);
    li.appendChild(txt);
    appHTML.getElementById("name").appendChild(li);
    this will display all name value which is coming from database,
    and i want to assign a hyperlink to it,
    I have id with name also so I thought that using id i will
    create javascript like
    function popup(id)
         if(id==1)
              var n1 = window.open("../list/name1.html");
         if(id==2)
              var n1 = window.open("../list/name2.html");
    this way i want to popup particular file if i can pass id value in this function
    so want hyperlink like
    name

  • If I use my iPad2 to present presentations created in MS Powerpoint, will I retain the embedded videos and hyperlinks that were created in the original presentation

    I want to use my iPad2 to make presentations created in MS Powerpoint. These have embedded videos, animations and hyperlinks. Will these all work in the spreadsheet if I use Keynote on my iPad to display and present them.

    I have another problem.
    I have deleted all apps from my iPhone 4s and then I have changed my
    Apple ID's country information from Poland to United States.
    After that, I have downloaded all deleted apps.
    But only few are in 'Purchased' section on iPhone!
    I guess only these, I have downloaded using USA App Store, not Polish.
    I am getting frustrated, because I have got too many problems with iOS
    and it doesn't look it will get better... Please help me ASAP! Thanks!

  • It used to be that when I created a pdf from a word or publisher document, hyperlinks worked fine. Now I cannot get them to work unless the text displayed for the link is the complete address and it all appears on one line. Why?

    it used to be that when I created a pdf from a word or publisher document, hyperlinks worked fine. Now I cannot get them to work unless the text displayed for the link is the complete address and it all appears on one line. Why?

    You can print to the Adobe PDF printer, but that only creates links that Acrobat or Reader recognize as such. That is the reason for needing the entire URL on one line. It is not actually an embedded link, but one created by Acrobat on the fly. With OFFICE 2013 you have two choices: 1. create the PDF with the print to Adobe PDF and then add the links in Acrobat so that they are complete or 2. I think the WORD save as PDF or XPS will create the PDF with links, but not sure. If so, that would be the quickest solution for you, but be aware of potential problems with the MS plugin.
    Of course, the third option is to upgrade to XI which can be done with AA 9. You will probably not be eligible for a for an upgrade to whatever the next version will be.

  • Using Apache Commons HTTPClient to create a custom socket for Java mail

    Does anyone know how to use Apache Commons HTTPClient to create a custom socket for Java mail. This is necessary for me to use NTLM authentication

    JavaMail doesn't use HTTP.
    If you want to add support for NTLM authentication to one of the standard protocols,
    your best bet is to create a SASL provider, although note that only JavaMail's IMAP
    provider uses SASL currently. The other protocols should add SASL support, but that
    hasn't been done yet.

  • How to create hyperlink using form

    if a user click on button then
    oulook express open for sending mail but i want to create hyperlink on it automatically.
    actually when user click then a word file created on server i want to hyperlink this file the file name is my form serial_no

    when i click on button outlook express is opening know and i can send text on body through forms
    i need it to send hyperlink on outlook express so i can open document through this link which is on outlook express file

Maybe you are looking for