After I share a public folder, the office documents in the folder only have the download option and can’t be previewed directly. How to set the settings so that the shared office documents can be previewed directly？
I think it is a problem with your Nextcloud instance.
I have tested shared files (read vs. modify) and directory (read vs. modify) with https://nextcloud.com/instant-trial . All works fine for me. There is no download option. Read-only-files are shown with Collabora Online. Modified files can be edited with Collabora Online.
Can you create a test user account at https://nextcloud.com/instant-trial and test it there? Maybe post some screenshots.
I have tested it with ONLYOFFICE and get the same problem. If i share the directory i can not access the file with ONLYOFFICE. Only if i share the file directly the file is opened with ONLYOFFICE.
But i find this discussion and it is maybe a solution for you if you have access to the source code.