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);
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').");
function saveWorkbook(workbook, name) {
workbook.save({ type: 'blob' }, function (data) {
saveAs(data, name);
alert('Error exporting: : ' + error);
})
Hello BalaKumar,
I am working on in and will provide you an update by EOD.
ig.excel.WorksheetCellComment Creates a new instance of the WorksheetCellComment class. ig.excel.worksheetCellComment has the dependencies with jquery-1.4.4.js and infragistis.util.js files.i would like to check if you have included that dependent js files.
Cells with comments have a red triangle in the upper right corner. To see the comment, place the pointer in the cell. The comment disappears when you move the pointer off the cell.
The example code below shows you how to add a comment to a cell.
In BLOCKED SCRIPT
worksheet4.rows(10).cells(2).comment(comment);
You can refer the following API doc for more information and methods of ig.excel.worksheetCellComment:
http://www.igniteui.com/help/javascript-excel-library-comments-in-a-worksheet-cell
http://www.igniteui.com/help/api/2016.1/ig.excel.WorksheetCellComment
please let me know if I may be further assistance.
Sincerely,Divya JainAssociate Software Developerhttp://friendshipdayscraps.com/