import * as fs from 'fs';
|
import xlsx from "node-xlsx";
|
|
async function main() {
|
const dir = '';
|
const files = fs.readdirSync(dir);
|
const books = [];
|
const bookMap = {};
|
const workSheets = xlsx.parse("【第二批二次处理后】交付清单.xlsx");
|
const sheet = workSheets[0];
|
const data = sheet.data;
|
data[0][12] = '文件名';
|
data[0][13] = '状态';
|
|
for (const file of files) {
|
const ext = file.substring(file.lastIndexOf('.') + 1);
|
const name = file.substring(0, file.lastIndexOf('.'));
|
const [id, title] = name.split(' ');
|
bookMap[name] = { id, title, file };
|
}
|
for (const book of data.slice(1)) {
|
const _id = book[0] + ' ' + book[1];
|
const bookInfo = bookMap[_id];
|
if (bookInfo) {
|
book[12] = bookInfo.file;
|
book[13] = '以提供';
|
}
|
}
|
}
|