Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help me use task pane on wps #84

Open
npzs opened this issue Dec 23, 2023 · 5 comments
Open

Please help me use task pane on wps #84

npzs opened this issue Dec 23, 2023 · 5 comments

Comments

@npzs
Copy link

npzs commented Dec 23, 2023

Hello, I am an xloil user from China and would like to ask a question:
I encountered the following error during the development and debugging of the plug-in, but I know that this is not actually a bug in the plug-in itself.

Since I'm trying to use this plugin for WPS, I don't know if you've heard of it, but it's from Kingsoft Software in China, and there's also an international version (WPS.com)

I have roughly tested most of the functions of xloil, including the operations of workbooks and worksheets, which can be used directly on wps. I also created the ribbon normally, and the xloil ribbon of the plug-in itself can also be displayed normally.

But I couldn't create this custom task pane no matter what. I tried running the testui routine provided here, and the error message that failed was exactly the same as what I wrote myself.
Because I didn’t make any changes in the official UI test and it still got the same error. I believe it’s not the way I used attach_pane/attach_pane_async that was wrong. I tried both methods and the error was the same.

I know that this error means that the correct parent window cannot be found to add the custom pane, because I am still in the novice stage of office development. After consulting some information, I learned that the class name of the parent window of the custom task pane in office excel should be Is this NUIPane correct?

If correct, then the logic of xloil should be to find the parent window based on this class name, right? The probably reason is that the task pane of wps is not this class name. Through some tools, I should have captured a possible class name, but then, I looked through the xloil documents and part of the xloil python code, but couldn't find it. How to modify this class name? I think it should be compiled in dll or xll.

I would like to ask dear developers, is there a way for me to use the specified class name? Or if there is a workaround to achieve it, please give me some ideas, thank you very much.
Finally, I also suggest that if xloil has a development plan, it is best to adapt to wps. Although its user base cannot be compared with office globally, it is actually the first choice for many small and medium-sized enterprises and individual users in China.


[20:18:56] [error] Error during ribbon callback: RuntimeError: RuntimeError: Failed to find parent window with class NUIPane
Traceback (most recent call last):
File "C:\Users\USERNAMEXX\path\file.py", line 37, in FUNCXX
ribbonUI.attach_pane(
File "C:\Users\USERNAMEXX\AppData\Local\python\Lib\site-packages\xloil\gui_init
.py", line 231, in _attach_task_pane
pane.attach_frame(frame_future)
File "C:\Users\USERNAMEXX\AppData\Local\python\Lib\site-packages\xloil\gui_init
.py", line 57, in _attach_frame
self._pane.attach(self, self.hwnd).result()
RuntimeError: Failed to find parent window with class NUIPane

@cunnane
Copy link
Owner

cunnane commented Jan 24, 2024

I installed WPS and had a look at this. The window structure in WPS for task panes seems different - I can't find a base window to attach to (I use Spy++ to check this). It would be good to see an example custom task pane in WPS, but there seems to be very little documentation (even translated!) I'll try a bit harder to get this to work.

Other xlOil things seem to work, which is impressive, they have done a good job matching the Excel API. Unfortunately the VBA support does not appear to be available in the free version so I can't check run the xlOil test sheets.

@npzs
Copy link
Author

npzs commented Jan 27, 2024

I installed WPS and had a look at this. The window structure in WPS for task panes seems different - I can't find a base window to attach to (I use Spy++ to check this). It would be good to see an example custom task pane in WPS, but there seems to be very little documentation (even translated!) I'll try a bit harder to get this to work.

Other xlOil things seem to work, which is impressive, they have done a good job matching the Excel API. Unfortunately the VBA support does not appear to be available in the free version so I can't check run the xlOil test sheets.

Yes, thank you very much for testing wps. I also tracked it myself and found that its task pane seems to be based on qt. It is indeed difficult to catch it. Moreover, I roughly read the source code logic of xloil and it seems that it is Search the NUIPane class name directly in the source code to locate the insertion position of the task pane, so it cannot be used in wps.
As for the VBA you mentioned, because I am from China, our domestic official website is wps.cn instead of com. The Chinese version provided in China did not have VBA in the free version in the early years and required additional plug-ins to be installed. However, recently they have developed jsa (It is a built-in module that uses JavaScript instead of vba to operate wps). From the beginning, his editor provided both js editor and vba editor environments, which means that the new version of vba comes with the free version.
As for the international version, I'm not sure, but judging from the consistent practice of Chinese software developers, the functions of domestic software are emasculated and even have a lot of advertisements, while the international version has full functions and no advertisements. This is the case for many manufacturers. , I wonder if kingsoft gave me an unexpected surprise this time?
Otherwise, the international version of wps should also inherit vba in the latest free version.

@npzs npzs closed this as completed Jan 27, 2024
@cunnane cunnane reopened this Jan 28, 2024
@cunnane
Copy link
Owner

cunnane commented Jan 28, 2024

Re-opening this as I don't think it's impossible yet! I could easily change 'NUIPane' to some other name (after detecting the presence of WPS office via the path or version). However because of the window structure in WPS it's not clear to me what window I should attach to.

It would be good to get confirmation that an addin designed for Excel with a custom task pane actually works in WPS.

xlOil doesn't do custom task panes "properly" in the way Microsoft expects: they expect you to create an ActiveX object which Office displays as task pane. xlOil instead creates an empty ActiveX object then tells the window manager (Qt, Wx, etc) to draw into this space. This might mean that if custom task panes in WPS only work via JavaScript, we can still do the same trick, but it will take me a while to figure out as I don't even have a working example of a JavaScript custom task pane in WPS (although I see some code snippets which suggest it works).

VBA support is not essential for xlOil as it's only used to support local workbook modules, but if you have access to a version of WPS with VBA support I'd be interested to know if you can run the xlOil test workbooks. I'm pretty sure VBA is not available in my version as clicking the "Visual Basic Editor" button in the toolbar does nothing (and it required some trickery to get this button to even appear).

@npzs
Copy link
Author

npzs commented Jan 30, 2024

Yes, I tested it on wps with VBA. After loading xloil, the VBA editor can use the functions exported by xloil normally, which is perfect.
I am really not sure whether the international version of wps does not provide VBA, or that downloading Microsoft's VBA plug-in is not possible. If it is very troublesome, you can consider downloading it at wps.cn. I am very sure that the version here is VBA+JavaScript. It is provided with the server, you only need to switch the environment, but it is very likely that it only has a Chinese version, and you may not be used to it in terms of language.
Another tip: If you want to load ribbon when using xloil in wps, you must add the ribbon plug-in name to the whitelist in the registry, otherwise it will not work properly.

@sskye123
Copy link

To add this, most of functions of xloil work in WPS including async RTD functions, VBA import and so on. I am using WPS with VBA support and it can correctly load UDF.

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

No branches or pull requests

3 participants