save
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const XLSX = require('xlsx');
|
||||
const path = require('path');
|
||||
|
||||
// 读取 Excel 文件(项目根目录)
|
||||
const filePath = path.join(__dirname, '新建 XLSX 工作表.xlsx');
|
||||
const workbook = XLSX.readFile(filePath);
|
||||
|
||||
// 目标 sheet
|
||||
const sheetName = '2026';
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
|
||||
if (!sheet) {
|
||||
console.error(`Sheet "${sheetName}" 不存在`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 将 sheet 转为 JSON 数组(以第一行为表头)
|
||||
const rows = XLSX.utils.sheet_to_json(sheet, { defval: null });
|
||||
|
||||
// 查找"团号"列(兼容表头可能的空格差异)
|
||||
const headerRow = XLSX.utils.sheet_to_json(sheet, { header: 1, defval: null })[0];
|
||||
const tuanHaoIndex = headerRow.findIndex(h => h && String(h).trim() === '团号');
|
||||
|
||||
if (tuanHaoIndex === -1) {
|
||||
console.error('未找到"团号"列');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 提取所有 TEAM-xxxx 格式的 ID
|
||||
const teamIds = [];
|
||||
for (const row of rows) {
|
||||
const val = row['团号'];
|
||||
if (val && /^TEAM-\d+$/.test(String(val).trim())) {
|
||||
teamIds.push(String(val).trim());
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`找到 ${teamIds.length} 个 TEAM ID:`);
|
||||
teamIds.forEach(id => console.log(id));
|
||||
Reference in New Issue
Block a user