public static int GetBorderIndex(SpreadsheetDocument document, Border b)
 {
     XElement border = b.GetXElement();
     XDocument styles = document.WorkbookPart.WorkbookStylesPart.GetXDocument();
     XElement borders = styles.Root.Element(S.borders);
     int index = Array.FindIndex(borders.Elements(S.border).ToArray(),
         z => XElement.DeepEquals(z, border));
     if (index != -1)
         return index;
     borders.Add(border);
     borders.Attribute(NoNamespace.count).Value = borders.Elements(S.border).Count().ToString();
     document.WorkbookPart.WorkbookStylesPart.PutXDocument();
     return borders.Elements(S.border).Count() - 1;
 }