lyg
2024-08-01 ce8cb9c851fa66c7c2902ceb57e369d3cecf1a28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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] = '以提供';
    }
  }
}