/// <summary> /// Apply shading to the section /// </summary> /// <param name="worksheet">The worksheet.</param> /// <param name="startSectionRow">The start section row</param> /// <param name="endSectionRow">The end section row</param> private void ApplyFormattingToSection(ref IXLWorksheet worksheet, int startSectionRow, int endSectionRow) { string rangeBegin = XLHelper.GetColumnLetterFromNumber(1) + startSectionRow; string rangeEnd = XLHelper.GetColumnLetterFromNumber(_NUMBER_OF_COLUMNS_WIDE) + endSectionRow; IXLRange range = worksheet.Range(rangeBegin, rangeEnd); range.Style.Fill.SetBackgroundColor(XLColor.LightGray); }
/// <summary> /// Apply shading to every other data row /// </summary> /// <param name="worksheet">The worksheet</param> /// <param name="startTableDataRow">The table start row</param> /// <param name="endTableDataRow">The table end row</param> /// <param name="lastColumn">The last column</param> private void ApplyShadingEveryOtherRow(ref IXLWorksheet worksheet, int startTableDataRow, int endTableDataRow, int lastColumn) { string rangeBegin = XLHelper.GetColumnLetterFromNumber(1) + startTableDataRow; string rangeEnd = XLHelper.GetColumnLetterFromNumber(lastColumn) + endTableDataRow; IXLRange range = worksheet.Range(rangeBegin, rangeEnd); range.AddConditionalFormat().WhenIsTrue("=mod(row(),2)=0").Fill.SetBackgroundColor(XLColor.LightGray); }
/// <summary> /// Create a row /// </summary> /// <param name="sheet">The sheet</param> /// <param name="currentRow">The current row</param> /// <returns>A IXLRange</returns> private IXLRange CreateRow(ref IXLWorksheet sheet, ref int currentRow) { string rangeBegin = XLHelper.GetColumnLetterFromNumber(1) + currentRow; string rangeEnd = XLHelper.GetColumnLetterFromNumber(_NUMBER_OF_COLUMNS_WIDE) + currentRow; IXLRange range = sheet.Range(rangeBegin, rangeEnd); currentRow++; return(range); }
/// <summary> /// Create a new row /// </summary> /// <param name="worksheet">The worksheet to create the </param> /// <param name="currentRow"></param> /// <param name="lastColumn"></param> /// <returns></returns> private IXLRange CreateRow(ref IXLWorksheet worksheet, ref int currentRow, int lastColumn) { string rangeBegin = XLHelper.GetColumnLetterFromNumber(1) + currentRow; string rangeEnd = XLHelper.GetColumnLetterFromNumber(lastColumn) + currentRow; IXLRange range = worksheet.Range(rangeBegin, rangeEnd); currentRow++; return(range); }
public void TestColumnLetterLookup() { var columnLetters = new List <String>(); for (int c = 1; c <= XLHelper.MaxColumnNumber; c++) { var columnLetter = NaiveGetColumnLetterFromNumber(c); columnLetters.Add(columnLetter); Assert.AreEqual(columnLetter, XLHelper.GetColumnLetterFromNumber(c)); } foreach (var cl in columnLetters) { var columnNumber = NaiveGetColumnNumberFromLetter(cl); Assert.AreEqual(columnNumber, XLHelper.GetColumnNumberFromLetter(cl)); } }
private static void CheckColumnNumber(int column) { Assert.AreEqual(column, XLHelper.GetColumnNumberFromLetter(XLHelper.GetColumnLetterFromNumber(column))); }