https://bz.apache.org/bugzilla/show_bug.cgi?id=69265

--- Comment #4 from nikknp.du...@gmail.com ---
I also tried with xlsx type. There if I try to set the hyperlink with type
email, it shows correctly in the hyperlink object as provided by
hyperlink.getType() method. However, if we save the file and try to see the
type of hyperlink, it is URL.

Code : 
private static void demonstrateHyperlinkFailure() {
                // Create a new XSSFWorkbook (for .xlsx files) and XSSFSheet
                XSSFWorkbook workbook = new XSSFWorkbook();
                XSSFSheet sheet = workbook.createSheet("Hyperlink Example");

                // Create a row and a cell
                XSSFRow row = sheet.createRow(0);
                XSSFCell cell = row.createCell(0);

                // Create a hyperlink
                XSSFCreationHelper createHelper = workbook.getCreationHelper();
                Hyperlink hyperlink =
createHelper.createHyperlink(HyperlinkType.EMAIL); // Changed to URL, as EMAIL
is not working as expected
                hyperlink.setLabel("mylabel");
                hyperlink.setAddress("ndu...@.example.com");

                // Set the label and the hyperlink
                cell.setCellValue("Click here");
                cell.setHyperlink(hyperlink);

                // Get the cell value and hyperlink address
                String cellValue = cell.getStringCellValue();
                Hyperlink cellHyperlink = cell.getHyperlink();
                String hyperlinkAddress = cellHyperlink.getAddress();
                HyperlinkType hyperlinkType = cellHyperlink.getType();

                System.out.println("Cell Value: " + cellValue);
                System.out.println("Hyperlink Address: " + hyperlinkAddress);
                System.out.println("Hyperlink Type: " +
hyperlinkType.toString());
                System.out.println("Hyperlink Label: " +
cellHyperlink.getLabel());
                try (FileOutputStream fileOut = new
FileOutputStream("/path/to/file.xlsx")) {
                    workbook.write(fileOut);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                // Close the workbook
                try {
                    workbook.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
        }
Result - File that is saved has the hyperlink type URL.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to