https://issues.apache.org/bugzilla/show_bug.cgi?id=53282

          Priority: P2
            Bug ID: 53282
          Assignee: [email protected]
           Summary: Hyperlink with a non-breaking space throws
                    java.lang.IllegalStateException: The hyperlink for
                    cell A2 references relation rId2, but that didn't
                    exist!
          Severity: normal
    Classification: Unclassified
          Reporter: [email protected]
          Hardware: PC
            Status: NEW
           Version: 3.8-dev
         Component: XSSF
           Product: POI

I sent this query to the POI mailing list couple of days back and was advised
to open a bug here.

I tested hyperlinks with Apache POI (3.8 version) and it throws
java.lang.IllegalStateException: The hyperlink for cell A2 references relation
rId2, but that didn't exist!
for hyperlinks with non-breaking spaces. The non-breaking space in an hyperlink
relation is not a valid java URI. These invalid characters should also be
encoded for valid URI. Looks like the issue with white space in target URI was
fixed in r1036215. 

When trying to convert such hyperlink to URI, a URISyntaxException is thrown.

Please find the attachment of the excel file including the hyperlink with a
non-breaking space. 

Below is the sample java code to demonstrate the issue.

import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

public class DemonstrateHyperlinkIssue {

    public static Workbook getCell(String fileName) throws Exception{

        FileInputStream input = null;
        Workbook excelDoc = null;

        try {
            input = new FileInputStream(fileName);
            excelDoc = WorkbookFactory.create(input);
            input.close();
        }
        catch(IOException e)
        {
            throw e;
        }
        finally
        {
            if (input != null) {
                input.close();
            }
        }

        return excelDoc;
    }

    public static void main(String [] args) {
        try {
            Workbook wb = getCell("C:\\pathToFile\\test.xlsx");
            System.out.println(wb);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to