javascript - Ignite UI - (jQuery) - 无法使用 ig.excel.WorksheetCellComment 在单元格中添加注释

标签 javascript jquery excel infragistics ignite-ui

我正在尝试将注释添加到工作表的单元格中。该功能运行时没有错误,但在 Excel 中它添加了一个没有文本的空白注释部分。请帮忙。

$("#input").on("change", function () {
    var excelFile,
        fileReader = new FileReader();

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

    fileReader.onload = function (e) {
        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 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");
        }, function (error) {
            $("#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);
            });
        }
    }
});

根据此链接尝试http://www.igniteui.com/help/api/2016.1/ig.excel.WorksheetCellComment

最佳答案

....
var comment = new $.ig.excel.WorksheetCellComment();
var formatted = new $.ig.excel.FormattedString("This is a comment");
// The $.ig.excel.WorksheetCellComment does not have .Text as a property
// See http://www.igniteui.com/help/api/2016.1/ig.excel.WorksheetCellComment#methods:text
comment.text(formatted);

注释存在于 Excel 文件中。

http://www.igniteui.com/help/api/2016.1/ig.excel.WorksheetCellComment#methods:text

关于javascript - Ignite UI - (jQuery) - 无法使用 ig.excel.WorksheetCellComment 在单元格中添加注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38382330/

相关文章:

javascript - Jquery onchange 函数不会在隐藏文件控件上调用

jquery - 在动画中间而不是结束时运行回调函数

jquery - border-radius.htc 是否支持隐藏/显示 div?

excel - 通过vba计算包裹单元格中的行数

ruby-on-rails - Rails 4/5 发送动态 ActionMailer::Base.mail 电子邮件,附件标记为 Noname

vb.net - 我应该选择 vb.net 还是 VBA?大多数情况下使用 Excel 文件

javascript - Angular 2 中出现 404 错误,即使后端 Nodejs url 在浏览器中输入时有效并显示来自 Oracle 的数据

javascript - 从更新中排除 NPM 包

javascript - typescript:具有带返回值的嵌套方法的辅助类

jquery - 如何使用 jQuery 根据 CSV 列表中的 id 对 div 元素进行排序?