Currently this line:

```ruby
@sheet_doc[n].xpath("/xmlns:worksheet/xmlns:hyperlinks/xmlns:hyperlink").each do |h|
```

Is iterating over each of the elements that match a certain xpath selector, then you're skipping over the ones of those that don't have the id attribute. You can simplify things by only selecting the ones that have id attributes in the first place, with code like this:

```ruby
@sheet_doc[n].xpath("/xmlns:worksheet/xmlns:hyperlinks/xmlns:hyperlink[id]").each do |h|
```

Does that make sense?