VintaSoft Imaging .NET SDK 12.4: Documentation for Web developer
In This Topic
    XLSX: Work with cells on XLSX page
    In This Topic
    WebSpreadsheetEditorControlJS control allows to work (view, add, edit and delete) with cells of XLSX worksheet in web browser.

    Cells can be changed manually using mouse/keyboard or programmatically.


    Add a cell to the XLSX worksheet

    If you want to add a cell to the focused XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to add a cell to the focused XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    // insert empty cells in range of selected cells and shift columns to the right
    spreadsheetEditorControl.insertCellsAndShiftRight();
    
    // insert empty cells in range of selected cells and shift rows to down
    spreadsheetEditorControl.insertCellsAndShiftDown();
    
    


    Copy and paste cells of XLSX worksheet

    If you want to copy and paste the selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to copy and paste cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    // copy content (selected cells, cell text, etc) to the clipboard
    spreadsheetEditorControl.doCopy();
    
    // paste content (selected cells, cell text, etc) from the clipboard
    spreadsheetEditorControl.doPaste();
    
    


    Cut and paste cells of XLSX worksheet

    If you want to cut and paste the selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to cut and paste the cell of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    // cut content(selected cells, cell text, etc) to the clipboard
    spreadsheetEditorControl.doCut();
    
    // paste content (selected cells, cell text, etc) from the clipboard
    spreadsheetEditorControl.doPaste();
    
    


    Change value of focused cell programmatically

    Here is JavaScript code that demonstrates how to change the value of focused cell of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get the spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    
    // get value or formula of focused cell
    var cellValue = spreadsheetEditorControl.get_FocusedCellValue();
    
    // set value or formula of focused cell
    spreadsheetEditorControl.set_FocusedCellValue("0");
    
    


    Change the value of focused cell using textbox in cell region (internal editor)

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


    Change the value of focused cell using textbox in formula bar (external editor)

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


    Change the text number format of selected cells of XLSX worksheet

    If you want to change the number format of selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to change the text number format of focused cell of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get the number format of focused cell
    var cellValue = _spreadsheetDocumentEditorControl.get_NumberingFormat();
    
    // set the number format of selected cells
    _spreadsheetDocumentEditorControl.set_NumberingFormat("0");
    
    


    Change the font properties of selected cells of XLSX worksheet

    If you want to change the font properties of selected cells 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 cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    
    // get the font name for focused cell
    var fontName = _spreadsheetDocumentEditorControl.get_FontName();
    // set new font name for selected cells
    _spreadsheetDocumentEditorControl.set_FontName("Impact");
    
    // get the font size for focused cell
    var fontSize = _spreadsheetDocumentEditorControl.get_FontSize();
    // set new font size for selected cells
    _spreadsheetDocumentEditorControl.set_FontSize(16);
    
    
    // get the bold status of text of focused cell
    var isBold = _spreadsheetDocumentEditorControl.get_IsFontBold();
    // set new bold status for text in selected cells
    _spreadsheetDocumentEditorControl.set_IsFontBold(true);
    
    // get the italic status of text of focused cell
    var isItalic = _spreadsheetDocumentEditorControl.get_IsFontItalic();
    // set new italic status for text in selected cells
    _spreadsheetDocumentEditorControl.set_IsFontItalic(true);
    
    // get the underline status of text of focused cell
    var isUnderline = _spreadsheetDocumentEditorControl.get_IsFontUnderline();
    // set new underline status for text in selected cells
    _spreadsheetDocumentEditorControl.set_IsFontUnderline(true);
    
    // get the strikeout status of text of focused cell
    var isStrikeout = _spreadsheetDocumentEditorControl.get_IsFontStrikeout();
    // set new strikeout status for text in selected cells
    _spreadsheetDocumentEditorControl.set_IsFontStrikeout(true);
    
    
    // get font color (for example, "rgba(0,0,0,1)") for focused cell
    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 for selected cells
    _spreadsheetDocumentEditorControl.set_FontColor(htmlColor);
    
    


    Change the text properties of selected cells of XLSX worksheet

    If you want to change the text properties of selected cells 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 cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    
    // get the text horizontal alignment for focused cell
    var textHorizontalAlign = _spreadsheetDocumentEditorControl.get_TextHorizontalAlign();
    
    // create value that defines horizontal alignment
    var horizontalAlign = Vintasoft.Imaging.Office.WebTextHorizontalAlignEnumJS("Center");
    // set new text horizontal alignment for selected cells
    _spreadsheetDocumentEditorControl.set_TextHorizontalAlign(horizontalAlign);
    
    
    // get the text vertical alignment for focused cell
    var textVerticalAlign = _spreadsheetDocumentEditorControl.get_TextVerticalAlign();
    
    // create value that defines vertical alignment
    var verticalAlign = Vintasoft.Imaging.Office.WebTextVerticalAlignEnumJS("Bottom");
    // set new text vertical alignment for selected cells
    _spreadsheetDocumentEditorControl.set_TextVerticalAlign(verticalAlign);
    
    


    Change the background color of selected cells of XLSX worksheet

    If you want to change the background color of selected cells 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 cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get the background color (for example, "rgba(255,255,225,1)") of focused cell
    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 selected cells
    _spreadsheetDocumentEditorControl.set_FillColor(htmlColor);
    
    


    Change the border of selected cells of XLSX worksheet

    If you want to change the border of selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to change the border of focused cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get the border color (for example, "rgba(255,255,225,1)") of focused cell
    var borderColor = _spreadsheetDocumentEditorControl.get_BordersColor();
    
    // 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 border color for selected cells
    _spreadsheetDocumentEditorControl.set_BordersColor(htmlColor);
    
    


    Clear contents of selected cells of XLSX worksheet

    If you want to clear contents of the selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to clear contents of cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    // clear contents (value and formula) of selected cells
    spreadsheetEditorControl.clearCellsContent();
    
    


    Merge and unmerge cells of XLSX worksheet

    If you want to merge and unmerge of selected cells of XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to merge and unmerge cells of XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var _spreadsheetDocumentEditorControl = _spreadsheetDocumentEditorControl.get__spreadsheetDocumentEditorControl();
    
    
    // merges the selected cells
    _spreadsheetDocumentEditorControl.mergeCells();
    
    // unmerges the selected cells
    _spreadsheetDocumentEditorControl.unmergeCells();
    


    Delete a cell from XLSX worksheet

    If you want to delete a cell from the focused XLSX worksheet using mouse, you should do the following steps:

    Here is JavaScript code that demonstrates how to delete a cell from XLSX worksheet:
    // _spreadsheetDocumentEditorControl is an instance of WebSpreadsheetDocumentEditorControlJS class
    
    // get spreadsheet editor
    var spreadsheetEditorControl = _spreadsheetDocumentEditorControl.get_SpreadsheetEditorControl();
    
    // remove selected cells and shift columns to the left
    spreadsheetEditorControl.removeCellsAndShiftLeft();
    
    // remove selected cells and shift rows to up
    spreadsheetEditorControl.removeCellsAndShiftUp();