dhatim / fastexcel

Generate and read big Excel files quickly
Other
643 stars 116 forks source link

Adding information about the author of the comment. #403

Open CamilYed opened 3 months ago

CamilYed commented 3 months ago

Hi, could you extend the fast-excel API with the ability to add, also, information about the author of the comment?

After generating the excel file, I unfortunately have a rather ugly comment.

image

The current implementation as you can see is quite flawed.

    void writeComments(Writer w) throws IOException {
        w.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        w.append("<comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">");
        w.append("<authors><author/></authors>");
        w.append("<commentList>");
        for (Map.Entry<Location, String> entry : cache.entrySet()) {
            Location location = entry.getKey();
            w.append("<comment ref=\"");
            w.append(location.toString());
            w.append("\" authorId=\"0\"><text><t>");
            w.appendEscaped(entry.getValue());
            w.append("</t></text></comment>");
        }
        w.append("</commentList></comments>");
    }

https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.comments?view=openxml-3.0.1

meiMingle commented 3 months ago

Can you upload an Excel file to show the style you want?

CamilYed commented 2 months ago

I would like to have an api e.g. by builder pattern to enable building a comment.

new CellComment.Builder()
    .withAuthor("Some author name")
    .withComment("Some text")
    .withDate(date, "MM-dd-yyyy HH:mm) // or  .withDate(date, "MM-dd-yyyy) // or 
    .withStyle(new CommentStyle.Builder()
        .withFontSize(19)
        .withFontName("Tahoma")
        .withColor("Green")
       // etc
    );

as allowed by the ooxml standard.

All options should be optionals. So in my case I need only:

new CellComment.Builder().withComment("Some text");

I use LibreOffice on a daily basis, but in Google Docs, I also see a similar comment. I would like to have only the text itself, and if the standard does not allow it, I would like to be able to set the author of the comment.

image