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