/// <summary> /// Creates a differential format in the target based on the source using the sourceIndex /// </summary> /// <param name="sourceIndex">Index of the source.</param> /// <param name="source">The source.</param> /// <param name="target">The target.</param> /// <returns></returns> /// <exception cref="OpenXmlException"></exception> public static uint CreateDifferentialFormatIndex(uint sourceIndex, Stylesheet source, Stylesheet target) { var df = SafeIndex <DifferentialFormats, DifferentialFormat>(source.DifferentialFormats, (int)sourceIndex); if (df == null) { // this really ought to be an exception // return 0; throw new OpenXmlException(string.Format("Unable to find CellFormat with index <{0}>", sourceIndex)); } var cloned = (DifferentialFormat)df.CloneNode(true); return(target.AddDifferentialFormat(cloned)); }