fix: Excel_RenameSheet 兼容目录键名 newSheet
处理器此前只读 newName/name/sheetName,而 Excel_RenameSheet 目录定义 与属性面板使用 newSheet,导致已填写新表名仍报「新 Sheet 名称为空」; 补充别名回归测试
This commit is contained in:
parent
ac20d59283
commit
54571eff8d
@ -50,6 +50,14 @@ describe("common Excel aliases", () => {
|
||||
await expect(run("Excel_OpenExcel", { filePath: created.path })).resolves.toMatchObject({ path: created.path });
|
||||
});
|
||||
|
||||
it("renames a sheet through the Excel_RenameSheet newSheet key", async () => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "rpa-excel-rename-")); dirs.push(directory);
|
||||
const created = await run("Excel_NewExcel", { filePath: directory, name: "rename-me.xlsx" }) as { path: string };
|
||||
await expect(run("Excel_RenameSheet", { objExcel: created, sheet: "Sheet1", newSheet: "库存表", isSave: "True" })).resolves.toBeTruthy();
|
||||
const reopened = await run("Excel_OpenExcel", { filePath: created.path }) as { id: string };
|
||||
await expect(run("Excel_GetSheetsName", { objExcel: reopened })).resolves.toEqual(["库存表"]);
|
||||
});
|
||||
|
||||
it("writes a range through the Excel_WriteRange catalog keys (objExcel/cellPos/data/isSave)", async () => {
|
||||
const directory = await mkdtemp(path.join(os.tmpdir(), "rpa-excel-range-")); dirs.push(directory);
|
||||
const created = await run("Excel_NewExcel", { filePath: directory, name: "range.xlsx" }) as { path: string };
|
||||
|
||||
@ -197,7 +197,7 @@ register(["Excel_GetSheetsName", "Excel_GetSheetNames"], async (_ctx, node, args
|
||||
register(["Excel_Cs_Rename", "Excel_RenameSheet"], async (_ctx, node, args) => {
|
||||
const { handle, workbook } = await resolveWorkbook(args, node.id, node.componentId);
|
||||
const oldName = required(value(args, ["sheet", "oldName"]), "原 Sheet 名称", node.id, node.componentId);
|
||||
const newName = required(value(args, ["newName", "name", "sheetName"]), "新 Sheet 名称", node.id, node.componentId);
|
||||
const newName = required(value(args, ["newSheet", "newName", "name", "sheetName"]), "新 Sheet 名称", node.id, node.componentId);
|
||||
const sheet = sheetOf(workbook, oldName);
|
||||
sheet.name = newName;
|
||||
await workbook.xlsx.writeFile(handle.path);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user