forked from baskbuddy/zhangshun
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.8 KiB
46 lines
1.8 KiB
import { FileBlob, SpreadsheetFile } from '@oai/artifact-tool';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const inputPath = path.join(projectRoot, 'product-docs', '职来产品功能设计.xlsx');
|
|
const input = await FileBlob.load(inputPath);
|
|
const workbook = await SpreadsheetFile.importXlsx(input);
|
|
|
|
const summary = await workbook.inspect({
|
|
kind: 'workbook,sheet,table',
|
|
maxChars: 12000,
|
|
tableMaxRows: 8,
|
|
tableMaxCols: 16,
|
|
tableMaxCellChars: 120,
|
|
});
|
|
console.log('SUMMARY');
|
|
console.log(summary.ndjson);
|
|
|
|
const sheets = await workbook.inspect({ kind: 'sheet', include: 'id,name', maxChars: 4000 });
|
|
console.log('SHEETS');
|
|
console.log(sheets.ndjson);
|
|
|
|
for (const s of workbook.worksheets.items) {
|
|
const used = s.getUsedRange();
|
|
if (!used) continue;
|
|
console.log(`SHEET_RANGE ${s.name} ${used.address}`);
|
|
const region = await workbook.inspect({
|
|
kind: 'region',
|
|
sheetId: s.name,
|
|
range: used.address,
|
|
maxChars: 30000,
|
|
tableMaxRows: 250,
|
|
tableMaxCols: 40,
|
|
tableMaxCellChars: 200,
|
|
});
|
|
console.log(region.ndjson);
|
|
}
|
|
|
|
const detail = workbook.worksheets.getItem('功能详细清单').getRange('A1:I96').values;
|
|
const rows = detail.slice(1).filter(r => r.some(v => v !== null && v !== ''));
|
|
const count = (keyFn) => rows.reduce((m, r) => { const k = keyFn(r); m[k] = (m[k] || 0) + 1; return m; }, {});
|
|
console.log('COUNTS_PRIORITY', JSON.stringify(count(r => r[7])));
|
|
console.log('COUNTS_PHASE', JSON.stringify(count(r => r[8])));
|
|
console.log('COUNTS端模块', JSON.stringify(count(r => `${r[1]}|${r[2]}|${r[3]}`)));
|
|
console.log('一期_P0', JSON.stringify(rows.filter(r => r[7] === 'P0' && r[8] === 'Y').map(r => ({id:r[0],端:r[1],tab:r[2],module:r[3],name:r[4]}))));
|
|
|