Generated Excel documents starts with SheetId:2 and r:Id 2
See original GitHub issueDo 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:
- Created a year ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.
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.