当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript utils.encode_cell方法代码示例

本文整理汇总了TypeScript中xlsx.utils.encode_cell方法的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.encode_cell方法的具体用法?TypeScript utils.encode_cell怎么用?TypeScript utils.encode_cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xlsx.utils的用法示例。


在下文中一共展示了utils.encode_cell方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(row_index: number, column_index: number, reason: Error) {
   const address = XLSX.utils.encode_cell({c: column_index, r: row_index});
   super(`Version Compare Error at ${address} cell.\nreason:\n---\n${reason.stack}---\n`);
   this.row_index = row_index;
   this.column_index = column_index;
   this.reason = reason;
   this.address = address;
 }
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:8,代码来源:xlsx2seed.ts

示例2: _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);
 }
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:38,代码来源:xlsx2seed.ts

示例3: while

        this.stream._read = () => {

            if (this.workbooks.length === 0) {
                this.stream.push(null);
            } else {
                let workbook = this.workbooks.pop();
                while (workbook != null) {
                    let requirements = new Array<IRequirement>();
                    let tests = new Array<ITestCase>();
                    // get requirements
                    let sheet = workbook.Sheets['Requirement'];
                    let range = xlsx.utils.decode_range(sheet['!ref']);
                    for (let row = range.s.r+1; row <= range.e.r; ++row) {
                        requirements.push({
                            id: sheet[xlsx.utils.encode_cell({c: 0, r: row})] ? sheet[xlsx.utils.encode_cell({c: 0, r: row})].v : null,
                            name: sheet[xlsx.utils.encode_cell({c: 1, r: row})] ? sheet[xlsx.utils.encode_cell({c: 1, r: row})].v : null,
                            info: sheet[xlsx.utils.encode_cell({c: 2, r: row})] ? sheet[xlsx.utils.encode_cell({c: 2, r: row})].v : null,
                            description: sheet[xlsx.utils.encode_cell({c: 3, r: row})] ? sheet[xlsx.utils.encode_cell({c: 3, r: row})].v : null
                        });
                    }
                    // get tests
                    sheet = workbook.Sheets['TestCases'];
                    range = xlsx.utils.decode_range(sheet['!ref']);
                    for (let row = range.s.r+1; row <= range.e.r; ++row) {
                        tests.push({
                            id: sheet[xlsx.utils.encode_cell({c: 0, r: row})].v,
                            description: sheet[xlsx.utils.encode_cell({c: 1, r: row})].v,
                        });
                    }
                    this.stream.push({"requirements": requirements, "test-cases": tests});
                    // next workbook
                    workbook = this.workbooks.pop()
                }
            }

        };
开发者ID:littlesnake,项目名称:syncpipes-server,代码行数:36,代码来源:service.ts

示例4: _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;
 }
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:18,代码来源:xlsx2seed.ts

示例5: getSheetFromData

	getSheetFromData(COLUMNS: any[], data: any[], opts: any = {}) {
	const ws = {};
		
	const range = {s: {c: COLUMNS.length, r: 10000000}, e: {c: 0, r: 0 }};
	for (let R = 0; R !== (data.length + 1); ++R) {
		const dataRow = R > 0 ? (R - 1) : R;
		const dataToPrint = data[dataRow];
		for (let C = 0; C !== COLUMNS.length; ++C) {
			if (range.s.r > R) {
				range.s.r = R;
			}
			if (range.s.c > C) {
				range.s.c = C;
			}
			if (range.e.r < R) {
				range.e.r = R;
			}
			if (range.e.c < C) {
				range.e.c = C;
			}

			let currentValue: any;
			
			if (R === 0) {
				currentValue = COLUMNS[C].title;
			} else {
				currentValue = ObjectUtil.clone(dataToPrint);
				for (let value in COLUMNS[C].att) {
					const prop = COLUMNS[C].att[value];
					if (ObjectUtil.isPresent(prop)) {
						if (ObjectUtil.isPresent(currentValue[prop])) {
							currentValue = ObjectUtil.clone(currentValue[prop]);	
						} else {
							currentValue = null;
						}
					} else {
						break;
					}
				}
			}
			
			if (ObjectUtil.isBlank(currentValue)) {
				continue;
			}
			
			const cell = {};
			//To Do, fix date recognition in excel
			if (ObjectUtil.isPresent(COLUMNS[C]['date']) && R !== 0) {
				const thisDate = new Date(currentValue.toString());
				cell['v'] = thisDate;
			} else {
				cell['v'] = currentValue;
			}
			
			const cell_ref = XLSX.utils.encode_cell( {c: C, r: R});
			
			if (typeof cell['v'] === 'number') { 
				cell['t'] = 'n';
			} else if (typeof cell['v'] === 'boolean') {
				cell['t'] = 'b';
			} else if (cell['v'] instanceof Date) {
				cell['t'] = 'n';
				cell['z'] = XLSX.SSF._table[14];
				cell['s'] = { numFmt: 'm/dd/yy'};
				cell['v'] = this.datenum(cell['v']);
			} else {
				cell['t'] = 's';
			}
			
			ws[cell_ref] = cell;
			}
		}
		if (range.s.c < 10000000) {
			ws['!ref'] = XLSX.utils.encode_range(range);
		}
		return ws;
	}
开发者ID:australdev,项目名称:app,代码行数:77,代码来源:xlsx_service.ts


注:本文中的xlsx.utils.encode_cell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。