question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated Excel documents starts with SheetId:2 and r:Id 2

See original GitHub issue

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • Yes
  • No

What is the current behavior?

SheetId and r:id starts at 2 instead of 1.

What is the expected behavior or new feature?

SheetId and r:id should start at 1.

Reproducibility

Code to reproduce problem:

public void Main()
{
   var workBook = new XLWorkbook();

    workBook.AddWorksheet("Sheet1");
    workBook.AddWorksheet("Sheet2");
    workBook.SaveAs("Testxml.xlsx");
}
  • I attached a sample spreadsheet. (You can drag files on to this issue) Testxml.xlsx

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jahavcommented, Jun 9, 2022

Hi, the r:id is a relationship id between individual parts of xlsx (actually [Open Packaging Conventions or ECMA-376 part 2])https://en.wikipedia.org/wiki/Open_Packaging_Conventions)).

The identifier is an implementation detail and could be anything, like guid (see example value from spect below) or something like that. You shouldn’t expect values to be of any specific format. ClosedXml is using a sequential generator for ids and the rId1 is used for relationship to app.xml part. While uniqueness necessary only locally per part, it’s just more convenient to have them unique globally.

ECMA-376 part 2 - 6.5.3.4 Attributes Id This attribute specifies the identifier of a relationship. The value of the Id attribute shall be unique within the Relationships part. This attribute is required. EXAMPLE 2 Id=“A5FFC797514BC”

SheetId is pretty much same, an implementation detail (in ClosedXml case, number is same as relationship id) that is generated by an algorithm that can change at any time.

@thommelutten Why do you need to look at the individual values? In any case, don’t rely on the ids to be generated sequentially or anything outside of spec requirements for id.

0reactions
thommeluttencommented, Jun 13, 2022

As a novice I’d assume the SheetId was 1, since ws1 is deleted before adding Sheet2? I’m guessing workBook does not contain a history of previously added sheets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert a new worksheet into a spreadsheet document ...
To open and work with an Excel document, you create an instance of the SpreadsheetDocument class from the document. After you create the ......
Read more >
Open a spreadsheet document for read-only access ...
To create an Excel document, you create an instance of the SpreadsheetDocument class and populate it with parts. At a minimum, the document...
Read more >
Excel FIles beginning with tilde followed by a dollar sign
I see that when I open a file in Excel 2007, say My_File.xlsx, Excel also creates a file with the same name but...
Read more >
Why has excel started creating multiple PDF files instead of ...
Excel Print to PDF has started creating 2 files for 1 print job when "print active sheets" is chosen and more than 1...
Read more >
Fix Excel file name Start with ~$ sign
Need your help to get rid of the ~$ signs in the excel file. i am using ms office 2007. i googled it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found