// 自定义单元格格式化函数
function CustomCellFormat(format, cultureName) {
GC.Spread.Formatter.FormatterBase.apply(this, arguments);
this.typeName = "CustomCellFormat";
}
CustomCellFormat.prototype = new GC.Spread.Formatter.FormatterBase();
CustomCellFormat.format = function (obj, formattedData) {
console.log('CustomCellFormat format', obj, formattedData);
return obj;
}
CustomCellFormat.prototype.parse = function (str) {
console.log('CustomCellFormat parse', str);
return new GC.Spread.Formatter.GeneralFormatter().parse(str);
};let oldFun = GC.Spread.Sheets.getTypeFromString;
// Private types can not be accessed from window, so override getTypeFromString method.
GC.Spread.Sheets.getTypeFromString = function (typeString) {
switch (typeString) {
case "CustomCellFormat":
return CustomCellFormat;
default:
return oldFun.apply(this, arguments);
}
};// 使用 没有一种写法是响应的?//this.sheet.getRange(this.range.row, this.range.col, this.range.rowCount, this.range.colCount).formatter(new CustomCellFormat())
// this.sheet.getCell(3, 2).formatter(new CustomCellFormat())
// this.sheet.setFormatter(3, 2, new CustomCellFormat());
// this.sheet.addCustomFunction(new CustomCellFormat());
|
|