Skip to content

Can't write a valid file with hyperlinks containing '&' symbol. #528

@vmakieienko

Description

@vmakieienko

The following code produces spreadsheet with 2 links.
In Libreoffice(24.8.4.1) Calc the first link will work, the secon one will be shown as a text only.
In MS Excel (2504) the app offers to repear the corrupt file and removes all the links as a result.

import org.dhatim.fastexcel.*;
import java.io.*;

public class FastXcelHyperlinkExample {
    public static void main(String[] args) throws IOException {
        OutputStream os = new FileOutputStream("hyperlinks.xlsx");// Create a new workbook and worksheet

        Workbook workbook = new Workbook(os, "HyperlinkExample", "1.0");
        Worksheet worksheet = workbook.newWorksheet("Hyperlinks");

        // This works
        worksheet.hyperlink(0, 1, new HyperLink("https://example.com/products?id=12345"));

        // This does not
        worksheet.hyperlink(3, 1, new HyperLink("https://example.com/products?id=12345&category=software"));

        workbook.finish();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions