Webviewer not working for xlsx file

I am using “@pdftron/webviewer”: “^11.1.0”, with reactjs.

my code is like this

useEffect(() => {
webViewerInstance.UI.loadDocument(templateUrl, {
officeOptions: {
doTemplatePrep: true,
},
onError: (err) => {
console.log(err)
}
});
},[templateUrl, webViewerInstance, templateRendered])

useEffect(() => {
        WebViewer(
            {
                path: '/pdftron/webviewer',
                licenseKey: 'MYKEY',
                preloadWorker: 'office',
                isReadOnly: true,
                disabledElements: [
                    'default-top-header',
                    'tools-header'
                ]
            },
            viewer.current!,
        ).then((instance) => {
            setWebViewerInstance(instance)
            instance.Core.documentViewer.addEventListener('documentLoaded', async () => {
                const doc = instance.Core.documentViewer.getDocument();
                console.log("Document type:", doc.getType());
                try {
                    const templateKeys = await doc.getTemplateKeys('schema') as TemplateSchema;
                    console.log("Extracted Template Keys:", templateKeys);

                    const schema = buildSchema(templateKeys.keys);
                    onSchemaLoaded(schema as IntegrationSchema);
                } catch (err) {
                    console.error("Error extracting template keys:", err);
                    setRenderingError("Failed to extract template keys.");
                }
            });
        });
}, [onSchemaLoaded, uploadInProgress, uploadCompleted, webViewerInstance]);

It works file with docx and pptx file but not working with xlsx file.
Attached here my xlsx file
simple xls.xlsx (4.8 KB)

1 Like

There are no template keys for variable templateKeys. It is empty object.

1 Like

Hello Hetal,

Thank you for contacting WebViewer Forums.

After discussing the issue with my team, this was a known issue where the office workers were not recognizing Excel templates. This has since been fixed and scheduled for the next minor release of WebViewer 11.3 in the upcoming weeks. Please keep an eye out at our announcements page here: Announcements - Apryse Community

Regards,
Luke

1 Like