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

Office Web Word API has different list ids than the resulting ooxml #5000

Open
timbicker opened this issue Oct 23, 2024 · 2 comments
Open

Office Web Word API has different list ids than the resulting ooxml #5000

timbicker opened this issue Oct 23, 2024 · 2 comments
Assignees
Labels
Area: Word Issue related to Word add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown

Comments

@timbicker
Copy link

Provide required information needed to triage your issue

When you use the Word Addin API to get list IDs, they can be different from the list IDs in ooxml.

Expected behavior

The IDs should be the same.

Steps to reproduce

  1. Open a new Word document in the browser.
  2. To make sure you can reproduce the bug, create 4 seperated lists and delete the first two. Make sure they are not linked to each other by inserting an extra paragraph / text between them.
  3. Copy the code from below in the script lab and run it
  4. In the console you will see word list ids and the xml
  5. Copy the xml to your editor go in the /word/document.xml package and check the paragraphs

Script Lab Code

$("#run").on("click", () => tryCatch(run));

async function run() {
  await Word.run(async (context) => {
    const body = context.document.body;

    context.document.body.lists.load("items")
    await context.sync()
    const lists = context.document.body.lists.items
    console.log(
      "lists ids from Word API: ",
      lists.map(list => list.id).sort((a, b) => a - b),
    )

    const docXml = context.document.body.getOoxml()
    await context.sync()
    console.log(`doc ooxml:`, docXml.value)

    await context.sync();
  });
}

// Default helper for invoking an action and handling errors.
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
    console.error(error);
  }
}

Output:

lists ids from Word API: 
[4, 5]

The respective entries for the paragraphs in the ooxml:

[...]
            <w:pPr>
              <w:pStyle w:val="ListParagraph" />
              <w:numPr>
                <w:ilvl w:val="0" />
                <w:numId w:val="2" />
              </w:numPr>
            </w:pPr>

[...]
            <w:pPr>
              <w:pStyle w:val="ListParagraph" />
              <w:numPr>
                <w:ilvl w:val="0" />
                <w:numId w:val="1" />
              </w:numPr>
            </w:pPr>

Why do I need this?

Right now it's not possible to determine the w:numFmt of list styles through the Word Api. So my workaround was to use the list Id from the API and look up the field in ooxml. But this does not work on the web client.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Area: Word Issue related to Word add-ins label Oct 23, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Oct 23, 2024
Copy link
Contributor

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

@qinliuMSFT
Copy link
Member

Thank you for reporting this issue, I can repro it. It has been put on our backlog #9476061 , the team will investigate and we will reply to you as soon as there is any progress. Thank you for your patience.

@qinliuMSFT qinliuMSFT added Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Word Issue related to Word add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown
Projects
None yet
Development

No branches or pull requests

2 participants