本文整理汇总了TypeScript中xlsx.utils.format_cell方法的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.format_cell方法的具体用法?TypeScript utils.format_cell怎么用?TypeScript utils.format_cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xlsx.utils
的用法示例。
在下文中一共展示了utils.format_cell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _get_data
_get_data(require_version = '') {
const row_indexes = this._row_indexes[require_version] = [] as number[];
const rows = [];
const version_column_index = this.version_column_index;
const require_version_range = `>= ${require_version}`;
for (let row_index = this.data_start_row; row_index <= this.max_row_index; ++row_index) {
if (version_column_index && require_version) { // version check
const address = XLSX.utils.encode_cell({c: version_column_index, r: row_index});
const cell = this.sheet[address];
const value = XLSX.utils.format_cell(cell);
try {
if (value && !semver.satisfies(value, require_version_range)) {
continue;
}
} catch (error) {
throw new Xlsx2SeedVersionError(row_index, version_column_index, error);
}
}
const row: Value[] = [];
rows.push(row);
row_indexes.push(row_index);
for (const column_index of this.column_indexes) {
const address = XLSX.utils.encode_cell({c: column_index, r: row_index});
const cell = this.sheet[address];
const value = XLSX.utils.format_cell(cell);
const use_value =
// tslint:disable-next-line no-null-keyword
value == null || !value.length ? null : // empty cell -> null
// tslint:disable-next-line max-line-length
cell.t === 'n' && value.match(/E\+\d+$/) && !isNaN(value as any) ? Number(cell.v) : // 1.00+E12 -> use raw value
cell.t === 'n' && value.match(/,/) && !isNaN(cell.v) ? Number(cell.v) : // 1,000 -> use raw value
isNaN(value as any) ? value.replace(/\\n/g, '\n').replace(/\r/g, '') : // "\\n" -> "\n" / delete "\r"
Number(value);
row.push(use_value);
}
}
this._data[require_version] = new Xlsx2SeedData(this.sheet_name, this.column_names, rows);
}
示例2: _set_column_info
_set_column_info() {
const column_names = [];
const column_indexes = [];
for (let column_index = 0; column_index <= this.max_column_index; ++column_index) {
const address = XLSX.utils.encode_cell({c: column_index, r: this.column_names_row});
const cell = this.sheet[address];
const value = XLSX.utils.format_cell(cell);
if (!value.length) break;
if (this.version_column && value === this.version_column) {
this._version_column_index = column_index;
} else if (this.ignore_columns.indexOf(value) === -1) {
column_names.push(value);
column_indexes.push(column_index);
}
}
this._column_names = column_names;
this._column_indexes = column_indexes;
}