export function applyImportToVTableSheet(vtableSheetInstance, result, options) {
    const clearExisting = !1 !== (null == options ? void 0 : options.clearExisting);
    if (0 === result.sheets.length) return;
    if ("function" != typeof vtableSheetInstance.addSheet) throw new Error("VTableSheet 实例方法不完整");
    const existingSheetKeys = (clearExisting ? [ ...vtableSheetInstance.getAllSheets() ] : []).map((s => s.sheetKey)), importedSheetKeys = [];
    for (let i = 0; i < result.sheets.length; i++) {
        const sheetData = result.sheets[i];
        let sheetKey = sheetData.sheetKey, suffix = 1;
        for (;vtableSheetInstance.getSheet(sheetKey) || importedSheetKeys.includes(sheetKey); ) sheetKey = `${sheetData.sheetKey}_${suffix}`, 
        suffix++;
        const sheetDefine = {
            sheetKey: sheetKey,
            sheetTitle: sheetData.sheetTitle,
            data: sheetData.data,
            rowCount: Math.max(sheetData.rowCount, 100),
            columnCount: Math.max(sheetData.columnCount, 26),
            cellMerge: sheetData.cellMerge,
            active: !1
        };
        vtableSheetInstance.addSheet(sheetDefine), importedSheetKeys.push(sheetKey);
    }
    if (clearExisting && existingSheetKeys.length > 0) for (const oldSheetKey of existingSheetKeys) importedSheetKeys.includes(oldSheetKey) || vtableSheetInstance.getSheet(oldSheetKey) && vtableSheetInstance.getSheetCount() > 1 && vtableSheetInstance.removeSheet(oldSheetKey);
    importedSheetKeys.length > 0 && vtableSheetInstance.activateSheet(importedSheetKeys[0]);
}
//# sourceMappingURL=vtable-sheet.js.map