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

[Word 2007] file cannot be opened in Word 2007 #1113

Open
trevorHsu opened this issue Aug 25, 2021 · 7 comments
Open

[Word 2007] file cannot be opened in Word 2007 #1113

trevorHsu opened this issue Aug 25, 2021 · 7 comments

Comments

@trevorHsu
Copy link

Problem:
The docx file cannot be opened in Word 2007 with a tips said "Unspecified error".

After testing several files, I found that the error location is always on this code in /word/document.xml:
<w:tblW w:type="auto" w:w="100%"/>

What I expected:
open the generated docx file in Word 2007

@anti-the-social
Copy link
Contributor

anti-the-social commented Aug 25, 2021

Normally I'm using <w:tblW w:type="pct" w:w="100%"/>, but in order to test your problem I've disassembled .docx and changed "pct" to "auto" and it doesn't seem to be your problem since it opened just fine.

At the current state of docx js does not verify correctness of the file so there are lot of things you can do to have document that is not possible to open. In most cases it is connected to the structure of elements (paragraph into paragraph and such kind of things) The second popular reason for me is the numbering. (I don't remember exact cases now already, but I think it was anything like not correctly matched structure and style names)

UPD: I was using newer Word, not sure if that makes any difference for your problem. Not likely I think

@trevorHsu
Copy link
Author

I tried this code <w:tblW w:type="pct" w:w="100%"/>. It opened fine in Word 2013, but still cannot be opened in Word 2007. 😢

Actually, I have set the table width type as "percentage" in the beginning, but it didnt work. After checking my code I found that the WidthType object has the PERCENTAGE property instead of the PCT property.

widthType

@trevorHsu
Copy link
Author

This is a demo, it works in Word 2013, but cannot be opened in Word 2007 with a message "Unspecified error".
The error location is on this code <w:tblW w:type="pct" w:w="100%"/>

const table = new Table({
    width: {
      size: 100,
      type: WidthType.PERCENTAGE
    },
    rows: [
        new TableRow({
            children: [
                new TableCell({
                    children: [new Paragraph("hello")],
                }),
            ],
        }),
    ]
})

const section = {
  properties: {
    page: {
      size: {
        orientation: PageOrientation.PORTRAIT
      }
    }
  },
  children: [table]
}

const doc = new Document({
  sections: [section]
})

@anti-the-social
Copy link
Contributor

anti-the-social commented Aug 26, 2021

Interesting stuff, lets see what Dolan says, but this attribute is made exactly according to the standard http://officeopenxml.com/WPtableWidth.php

@trevorHsu
Copy link
Author

Another problem, docx file with image is unable to open in Word 2007.
imageDoc.docx

@dolanmiu
Copy link
Owner

I have corrected the documentation, now it correctly has PERCENTAGE, (which refers to pct when generating a document)

Maybe Word 2007 does not support the pct property?

IMO, if its in the official OOXML spec, then it should stay. Maybe have a disclaimer in the documentation explaining the limitations and caveats of pct

@trevorHsu
Copy link
Author

Yeah, it seems pct is not suported in Word 2007, i use dxa instead, it works.

The image problem is not solved yet. 😢

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