private void BulkMaterialFormatMultiple() { try { if (_cells == null) _cells = new ExcelStyleCells(_excelApp); var excelBook = _excelApp.Workbooks.Add(); Worksheet excelSheet = excelBook.ActiveSheet; excelSheet.Name = SheetName01; _cells = new ExcelStyleCells(_excelApp); _cells.GetRange(1, TittleRow + 1, ResultColumn, MaxRows).Style = _cells.GetStyle(StyleConstants.Normal); _cells.GetRange(1, TittleRow + 1, ResultColumn, MaxRows).ClearFormats(); _cells.GetRange(1, TittleRow + 1, ResultColumn, MaxRows).ClearComments(); _cells.GetRange(1, TittleRow + 1, ResultColumn, MaxRows).Clear(); _cells.GetRange(1, TittleRow + 1, ResultColumn, TittleRow + 1).NumberFormat = "@"; _cells.GetCell("A1").Value = "CERREJÓN"; _cells.GetCell("B1").Value = "Bulk Material Usage Sheet"; _cells.GetRange("A1", "B1").Style = _cells.GetStyle(StyleConstants.HeaderDefault); _cells.GetRange("B1", "D1").Merge(); _cells.GetCell(1, TittleRow).Value = "Usage Sheet Id"; _cells.GetCell(2, TittleRow).Value = "District"; _cells.GetCell(3, TittleRow).Value = "Warehouse"; _cells.GetCell(4, TittleRow).Value = "Usage Date"; _cells.GetCell(5, TittleRow).Value = "Usage Time"; _cells.GetCell(6, TittleRow).Value = "General Account Code"; _cells.GetCell(7, TittleRow).Value = "Usage Item Id"; _cells.GetCell(8, TittleRow).Value = "Equipment Reference"; _cells.GetCell(9, TittleRow).Value = "Component Code"; _cells.GetCell(10, TittleRow).Value = "Modifier Code"; _cells.GetCell(11, TittleRow).Value = "Bulk Material Type"; _cells.GetCell(12, TittleRow).Value = "Condition Monitoring Action"; _cells.GetCell(13, TittleRow).Value = "Quantity"; _cells.GetCell(14, TittleRow).Value = "Transaction Date"; _cells.GetCell(15, TittleRow).Value = "Statistic Time"; _cells.GetCell(16, TittleRow).Value = "Statistic Type"; _cells.GetCell(17, TittleRow).Value = "Statistic Meter"; _cells.GetCell(ResultColumn, TittleRow).Value = "Result"; #region Styles _cells.GetCell(1, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleInformation); _cells.GetCell(2, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(3, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(4, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(5, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(6, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(7, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleInformation); _cells.GetCell(8, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(9, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(10, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(11, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(12, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(13, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(14, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell(15, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(16, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(17, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell(ResultColumn, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleInformation); #endregion #region Instructions _cells.GetCell("E1").Value = "OBLIGATORIO"; _cells.GetCell("E1").Style = _cells.GetStyle(StyleConstants.TitleRequired); _cells.GetCell("E2").Value = "OPCIONAL"; _cells.GetCell("E2").Style = _cells.GetStyle(StyleConstants.TitleOptional); _cells.GetCell("E3").Value = "INFORMATIVO"; _cells.GetCell("E3").Style = _cells.GetStyle(StyleConstants.TitleInformation); _cells.GetCell("E4").Value = "ACCIÓN A REALIZAR"; _cells.GetCell("E4").Style = _cells.GetStyle(StyleConstants.TitleAction); _cells.GetCell("E5").Value = "REQUERIDO ADICIONAL"; _cells.GetCell("E5").Style = _cells.GetStyle(StyleConstants.TitleAdditional); #endregion _optionList = new List<string> { " Fuel/Diesel", "B - Condition Monitoring Fitment", "L - Condition Monitoring Rebuild in Situ", "O - Oil Changed", "C - Condition Monitoring Defitment", "A - Oil Added", "F - Filter Changed" }; _cells.SetValidationList(_cells.GetCell(12, TittleRow + 1), _optionList); _excelSheetItems = excelSheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, _cells.GetRange(1, TittleRow, ResultColumn, MaxRows), XlListObjectHasHeaders: XlYesNoGuess.xlYes); _excelSheetItems.Name = "ExcelSheetItems"; _cells.GetRange(1, TittleRow + 1, ResultColumn, MaxRows).NumberFormat = "@"; OrderAndSort(excelSheet); } catch (Exception error) { MessageBox.Show(error.Message); } }