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