/// <summary> /// Apply a named cell style to a range of columns. Existing styles are kept, unless the chosen named cell style overrides those styles. /// </summary> /// <param name="StartColumnIndex">The column index of the starting column.</param> /// <param name="EndColumnIndex">The column index of the ending column.</param> /// <param name="NamedCellStyle">The named cell style to be applied.</param> /// <returns>True if the column indices are valid. False otherwise.</returns> public bool ApplyNamedCellStyleToColumn(int StartColumnIndex, int EndColumnIndex, SLNamedCellStyleValues NamedCellStyle) { int iStartColumnIndex = 1, iEndColumnIndex = 1; bool result = false; if (StartColumnIndex < EndColumnIndex) { iStartColumnIndex = StartColumnIndex; iEndColumnIndex = EndColumnIndex; } else { iStartColumnIndex = EndColumnIndex; iEndColumnIndex = StartColumnIndex; } SLStyle style = new SLStyle(SimpleTheme.MajorLatinFont, SimpleTheme.MinorLatinFont, SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors); if (iStartColumnIndex >= 1 && iStartColumnIndex <= SLConstants.ColumnLimit && iEndColumnIndex >= 1 && iEndColumnIndex <= SLConstants.ColumnLimit) { result = true; int i = 0; for (i = iStartColumnIndex; i <= iEndColumnIndex; ++i) { style = this.GetColumnStyle(i); style.ApplyNamedCellStyle(NamedCellStyle); this.SetColumnStyle(i, style); slws.RowColumnStyleHistory.Add(new SLRowColumnStyleHistory(false, i)); } } return result; }
/// <summary> /// Apply a named cell style to a range of cells. Existing styles are kept, unless the chosen named cell style overrides those styles. /// </summary> /// <param name="StartRowIndex">The row index of the starting row.</param> /// <param name="StartColumnIndex">The column index of the starting column.</param> /// <param name="EndRowIndex">The row index of the ending row.</param> /// <param name="EndColumnIndex">The column index of the ending column.</param> /// <param name="NamedCellStyle">The named cell style to be applied.</param> /// <returns>True if successful. False otherwise.</returns> public bool ApplyNamedCellStyle(int StartRowIndex, int StartColumnIndex, int EndRowIndex, int EndColumnIndex, SLNamedCellStyleValues NamedCellStyle) { int iStartRowIndex = 1, iEndRowIndex = 1, iStartColumnIndex = 1, iEndColumnIndex = 1; bool result = false; if (StartRowIndex < EndRowIndex) { iStartRowIndex = StartRowIndex; iEndRowIndex = EndRowIndex; } else { iStartRowIndex = EndRowIndex; iEndRowIndex = StartRowIndex; } if (StartColumnIndex < EndColumnIndex) { iStartColumnIndex = StartColumnIndex; iEndColumnIndex = EndColumnIndex; } else { iStartColumnIndex = EndColumnIndex; iEndColumnIndex = StartColumnIndex; } SLStyle style = new SLStyle(SimpleTheme.MajorLatinFont, SimpleTheme.MinorLatinFont, SimpleTheme.listThemeColors, SimpleTheme.listIndexedColors); if (SLTool.CheckRowColumnIndexLimit(iStartRowIndex, iStartColumnIndex) && SLTool.CheckRowColumnIndexLimit(iEndRowIndex, iEndColumnIndex)) { result = true; int i = 0, j = 0; for (i = iStartRowIndex; i <= iEndRowIndex; ++i) { for (j = iStartColumnIndex; j <= iEndColumnIndex; ++j) { style = this.GetCellStyle(i, j); style.ApplyNamedCellStyle(NamedCellStyle); this.SetCellStyle(i, j, style); } } } return result; }