gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 19:11:42 25 4
gpt4 key购买 nike

我正在尝试将注释添加到工作表的单元格中。该功能正常运行但在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com