Skip to content

Comments

feat: add support to WPS office#22

Open
younero wants to merge 2 commits intoglexey:masterfrom
younero:master
Open

feat: add support to WPS office#22
younero wants to merge 2 commits intoglexey:masterfrom
younero:master

Conversation

@younero
Copy link

@younero younero commented Nov 1, 2024

Excel does not yet support inserting images into cells, which may not meet usage requirements in some cases. Therefore, we hope to add more types of spreadsheet software support, such as WPS Office.

@glexey
Copy link
Owner

glexey commented May 16, 2025

@CodiumAI-Agent /review

@QodoAI-Agent
Copy link

QodoAI-Agent commented May 16, 2025

PR Reviewer Guide 🔍

(Review updated until commit b15cf14)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

COM ProgID Check

Validate that the WPS Office ProgID (ket.Application) is correct for spreadsheet support; an incorrect ProgID will fail to launch the target application.

from enum import Enum

class Application(Enum):
    Excel = 'Excel.Application'  # Microsoft Office
    KET = 'ket.Application'  # WPS Office
Broad exception handling

The except: blocks around DispatchEx and workbook opening are too broad and hide original error details. Catch specific exceptions (e.g., com_error) and preserve the original message for debugging.

    self.app = win32com.client.DispatchEx(application.value)
    self.app.Visible = 0
except:
    raise OSError(f'Failed to start {application.name}')

try:
    self.workbook = self.app.Workbooks.Open(excel_pathname, ReadOnly=True)
except:
CLI option missing

The new application parameter isn’t exposed via the CLI OptionParser. Add a command-line flag to let users select between Excel and WPS Office at runtime.

from optparse import OptionParser
from pywintypes import com_error
from PIL import ImageGrab # Note: PIL >= 3.3.1 required to work well with Excel screenshots
from enum import Enum

…n 参数添加 Application 类型注解

- 这个改动提高了代码的可读性和类型安全性,便于理解 application 参数的预期类型
@younero
Copy link
Author

younero commented May 19, 2025

The code has been revised according to the review comments. (By the way, AI is really good at reviewing.)

@QodoAI-Agent
Copy link

Persistent review updated to latest commit b15cf14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants