42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import { FileBlob, SpreadsheetFile } from "@oai/artifact-tool";
|
|
|
|
const inputPath =
|
|
"/Users/lingniu/project/ai-coding/lingniu-vehicle-ingest/outputs/g7-mileage-history-20260724/merged/G7车辆每日里程及里程统计_20220101-20260720.xlsx";
|
|
const workbook = await SpreadsheetFile.importXlsx(await FileBlob.load(inputPath));
|
|
const sheets = await workbook.inspect({
|
|
kind: "sheet",
|
|
include: "id,name",
|
|
maxChars: 4000,
|
|
});
|
|
const summary = await workbook.inspect({
|
|
kind: "table",
|
|
sheetId: "汇总",
|
|
range: "A1:H25",
|
|
include: "values,formulas",
|
|
maxChars: 12000,
|
|
tableMaxRows: 25,
|
|
tableMaxCols: 8,
|
|
});
|
|
const daily = await workbook.inspect({
|
|
kind: "table",
|
|
sheetId: "每日里程非零",
|
|
range: "A1:D12",
|
|
include: "values,formulas",
|
|
maxChars: 6000,
|
|
tableMaxRows: 12,
|
|
tableMaxCols: 4,
|
|
});
|
|
const errors = await workbook.inspect({
|
|
kind: "match",
|
|
searchTerm: "#REF!|#DIV/0!|#VALUE!|#NAME\\?|#N/A",
|
|
options: { useRegex: true, maxResults: 300 },
|
|
summary: "post-export formula error scan",
|
|
});
|
|
console.log(JSON.stringify({
|
|
inputPath,
|
|
sheets: sheets.ndjson,
|
|
summary: summary.ndjson,
|
|
daily: daily.ndjson,
|
|
errors: errors.ndjson,
|
|
}, null, 2));
|