Пример #1
0
 /// <summary>
 /// Appends the specified style parts to the current one. The parts can be instances of sub-classes like Border or CellXf or a Style instance. Only the altered properties of the specified style or style part that differs from a new / untouched style instance will be appended. This enables method chaining
 /// </summary>
 /// <param name="styleToAppend">The style to append or a sub-class of Style</param>
 /// <returns>Current style with appended style parts</returns>
 public Style Append(AbstractStyle styleToAppend)
 {
     if (styleToAppend.GetType() == typeof(Border))
     {
         CurrentBorder.CopyProperties<Border>((Border)styleToAppend, new Border());
     }
     else if (styleToAppend.GetType() == typeof(CellXf))
     {
         CurrentCellXf.CopyProperties<CellXf>((CellXf)styleToAppend, new CellXf());
     }
     else if (styleToAppend.GetType() == typeof(Fill))
     {
         CurrentFill.CopyProperties<Fill>((Fill)styleToAppend, new Fill());
     }
     else if (styleToAppend.GetType() == typeof(Font))
     {
         CurrentFont.CopyProperties<Font>((Font)styleToAppend, new Font());
     }
     else if (styleToAppend.GetType() == typeof(NumberFormat))
     {
         CurrentNumberFormat.CopyProperties<NumberFormat>((NumberFormat)styleToAppend, new NumberFormat());
     }
     else if (styleToAppend.GetType() == typeof(Style))
     {
         CurrentBorder.CopyProperties<Border>(((Style)styleToAppend).CurrentBorder, new Border());
         CurrentCellXf.CopyProperties<CellXf>(((Style)styleToAppend).CurrentCellXf, new CellXf());
         CurrentFill.CopyProperties<Fill>(((Style)styleToAppend).CurrentFill, new Fill());
         CurrentFont.CopyProperties<Font>(((Style)styleToAppend).CurrentFont, new Font());
         CurrentNumberFormat.CopyProperties<NumberFormat>(((Style)styleToAppend).CurrentNumberFormat, new NumberFormat());
     }
     return this;
 }