VintaSoft Imaging .NET SDK 15.1: Documentation for Web developer
In This Topic
XLSX: Work with comments on XLSX page
In This Topic
WebSpreadsheetEditorControlJS control allows to work (view, add, edit and delete) with comments to the cells of XLSX worksheet in web browser.
Cell comments can be changed manually using mouse/keyboard or programmatically.


Add a comment to the focused cell of XLSX worksheet

If you want to add a comment to the focused cell of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to add a comment to the focused cell of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();


// prepare parameters of comment

// comment author
var commentAuthor = "Persona";
// a value indicating whether author name must be shown in comment
var showAuthor = true;
// comment text
var commentText = "Test comment text";

// add comment to the focused cell
spreadsheetEditorControl.insertComment(commentAuthor, showAuthor, commentText);



Edit the comment of the focused cell of XLSX worksheet

If you want to edit a comment of the focused cell of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to change the comment of focused cell of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();

// if focused cell does not have comment
if (!spreadsheetEditorControl.get_IsCellHasComment()) {
    throw new Error("Focused cell does not have comment.");
}


// prepare parameters of comment

// get the author ("Persona") of focused comment
var author = spreadsheetEditorControl.get_CommentAuthor();
// change the author
author += "2";

// get a value indicating whether author name must be shown in comment
var showAuthor = spreadsheetEditorControl.get_CommentShowAuthor();

// get the text ("Test comment text") of focused comment
var text = spreadsheetEditorControl.get_CommentShowText();
// change the text
text = "Edited " + text;


// edit comment for focused cell
spreadsheetEditorControl.editComment(author, showAuthor, text);



Resize the comment of the focused cell of XLSX worksheet

If you want to resize the comment of the focused cell of XLSX worksheet using mouse, you should do the following steps:

Move the comment of the focused cell of XLSX worksheet

If you want to move (reposition) the comment of the focused cell of XLSX worksheet using mouse, you should do the following steps:

Change the font properties of focused comment of XLSX worksheet

If you want to change the font properties of the focused comment of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to change the font properties of focused comment of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get__spreadsheetDocumentEditorControl();

// if comment is not focused
if (!spreadsheetEditorControl.get_IsCommentFocused()) {
    // if focused cell has comment
    if (spreadsheetEditorControl.get_IsCellHasComment()) {
        // focus the comment of focused cell
        spreadsheetEditorControl.focusCommentFromFocusedCell();
    }
    else {
        throw new Error("Focused cell does not have comment.");
    }
}

// get the font name for focused comment
var fontName = _spreadsheetDocumentEditorControl.get_FontName();
// set new font name
_spreadsheetDocumentEditorControl.set_FontName("Impact");

// get the font size for focused comment
var fontSize = _spreadsheetDocumentEditorControl.get_FontSize();
// set new font size
_spreadsheetDocumentEditorControl.set_FontSize(16);


// get the bold text status for focused comment
var isBold = _spreadsheetDocumentEditorControl.get_IsFontBold();
// set new boldness status
_spreadsheetDocumentEditorControl.set_IsFontBold(true);

// get the italic text status for focused comment
var isItalic = _spreadsheetDocumentEditorControl.get_IsFontItalic();
// set new italic text status
_spreadsheetDocumentEditorControl.set_IsFontItalic(true);

// get the underline text status for focused comment
var isUnderline = _spreadsheetDocumentEditorControl.get_IsFontUnderline();
// set new underline text status
_spreadsheetDocumentEditorControl.set_IsFontUnderline(true);

// get the strikeout text status for focused comment
var isStrikeout = _spreadsheetDocumentEditorControl.get_IsFontStrikeout();
// set new strikeout text status
_spreadsheetDocumentEditorControl.set_IsFontStrikeout(true);


// get font color (for example, "rgba(0,0,0,1)") for focused comment
var fontColor = _spreadsheetDocumentEditorControl.get_FontColor();

// get a string that represents HTML color ("black", "red", "transparent", "rgb(255,255,255)", "rgba(255,255,255,0.5)")
var htmlColor = "teal";
// set new font color
_spreadsheetDocumentEditorControl.set_FontColor(htmlColor);



Change the text properties of focused comment of XLSX worksheet

If you want to change the text properties of the focused comment of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to change the text properties of focused comment of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get__spreadsheetDocumentEditorControl();

// if comment not focused
if (!spreadsheetEditorControl.get_IsCommentFocused()) {
    // if focused cell has comment
    if (spreadsheetEditorControl.get_IsCellHasComment()) {
        // focus the comment of focused cell
        spreadsheetEditorControl.focusCommentFromFocusedCell();
    }
    else {
        throw new Error("Focused cell does not have comment.");
    }
}

// get the text horizontal alignment for focused comment
var textHorizontalAlign = _spreadsheetDocumentEditorControl.get_TextHorizontalAlign();

// create value that defines horizontal alignment
var horizontalAlign = Vintasoft.Imaging.Office.WebTextHorizontalAlignEnumJS("Center");
// set new text horizontal alignment
_spreadsheetDocumentEditorControl.set_TextHorizontalAlign(horizontalAlign);


// get the text vertical alignment for focused comment
var textVerticalAlign = _spreadsheetDocumentEditorControl.get_TextVerticalAlign();

// create value that defines vertical alignment
var verticalAlign = Vintasoft.Imaging.Office.WebTextVerticalAlignEnumJS("Bottom");
// set new text vertical alignment
_spreadsheetDocumentEditorControl.set_TextVerticalAlign(verticalAlign);



Change the background color of focused comment of XLSX worksheet

If you want to change the background color of the focused comment of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to change the background color of focused comment of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();

// if comment is not focused
if (!spreadsheetEditorControl.get_IsCommentFocused()) {
    // if focused cell has comment
    if (spreadsheetEditorControl.get_IsCellHasComment()) {
        // focus the comment of focused cell
        spreadsheetEditorControl.focusCommentFromFocusedCell();
    }
    else {
        throw new Error("Focused cell does not have comment.");
    }
}

// get the background color (for example, "rgba(255,255,225,1)") of focused comment
var backgroundColor = _spreadsheetDocumentEditorControl.get_FillColor();

// create a string that represents HTML color ("black", "red", "transparent", "rgb(255,255,255)", "rgba(255,255,255,0.5)")
var htmlColor = "rgb(200,150,200)";
// set new background color for focused comment
_spreadsheetDocumentEditorControl.set_FillColor(htmlColor);



Delete the comment of focused cell of XLSX worksheet

If you want to delete the focused comment of XLSX worksheet using mouse, you should do the following steps:
Here is JavaScript code that demonstrates how to delete the comment of the focused cell of XLSX worksheet:
// _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class

// get spreadsheet editor
var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();

// if focused cell does not have comment
if (!spreadsheetEditorControl.get_IsCellHasComment()) {
    throw new Error("Focused cell does not have comment.");
}

// delete comment in focused cell
spreadsheetEditorControl.deleteComment();