Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
Unable to insert comment using WorksheetCellComment
posted

Hello

I am trying to add a comment into a cell in an existing excel . The functionality works without error but I see only a blank comment . Please help.



$("#input").on("change", function () {

var excelFile,

fileReader = new FileReader();

$("#result").hide();

fileReader.onload = function (e) {

extendedVm.gettingDataimageSave(true);

var buffer = new Uint8Array(fileReader.result);

$.ig.excel.Workbook.load(buffer, function (workbook) {

var column, row, newRow, cellValue, columnIndex, i,

worksheet = workbook.worksheets(0),

columnsNumber = 0,

gridColumns = [],

data = [],

worksheetRowsCount; 

 

//var workbook = new $.ig.excel.Workbook($.ig.excel.WorkbookFormat.excel2007);

//workbook.worksheets().add(worksheet);

var comment = new $.ig.excel.WorksheetCellComment();

var formatted = new $.ig.excel.FormattedString("This is a comment");

comment.Text = formatted;

worksheet.rows(2).cells(4).comment(comment);

//var workbook = new $.ig.excel.Workbook($.ig.excel.WorkbookFormat.excel2007);

//workbook.worksheets().add(worksheet);

saveWorkbook(workbook, "Formatting.xlsx");

// we can also skip passing the gridColumns use autoGenerateColumns = true, or modify the gridColumns array

//createGrid(data, gridColumns);

}, function (error) {

//Need to be changed

$("#result").text("The excel file is corrupted.");

$("#result").show(1000);

});

 }

if (this.files.length > 0) {

excelFile = this.files[0];

if (excelFile.type === "application/vnd.ms-excel" || excelFile.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || (excelFile.type === "" && (excelFile.name.endsWith("xls") || excelFile.name.endsWith("xlsx")))) {

fileReader.readAsArrayBuffer(excelFile);

} else {

$("#result").text("The format of the file you have selected is not supported. Please select a valid Excel file ('.xls, *.xlsx').");

$("#result").show(1000);

}

function saveWorkbook(workbook, name) {

workbook.save({ type: 'blob' }, function (data) {

saveAs(data, name);

}, function (error) {

alert('Error exporting: : ' + error);

});

}

}

})

Parents Reply Children