/// <summary> /// 取出列名及列号 /// </summary> /// <param name="columnNameRow"></param> public void Caculate_Columns(int columnNameRow) { try { Cells cells = _workSheet.Cells; //int row = 0; int row2 = cells.MaxDataRow; int column = 0; int num = cells.MaxDataColumn; if (num < 4) { num = 4; } this.ExcelColumns = new Dictionary <string, int>(); for (int i = column; i <= num; i++) { try { string a = (cells[columnNameRow, i].Value == null) ? "" : cells[columnNameRow, i].Value.ToString(); ExcelColumns.Add(a, i); } catch { } } } catch { //Commons.ShowMessage_Info(DialogType.Warring, ex.Message); } }
private void ColumnSetUp() { ExcelColumns.Add(1, "A"); ExcelColumns.Add(2, "B"); ExcelColumns.Add(3, "C"); ExcelColumns.Add(4, "D"); ExcelColumns.Add(5, "E"); ExcelColumns.Add(6, "F"); ExcelColumns.Add(7, "G"); ExcelColumns.Add(8, "H"); ExcelColumns.Add(9, "I"); ExcelColumns.Add(10, "J"); ExcelColumns.Add(11, "K"); ExcelColumns.Add(12, "L"); ExcelColumns.Add(13, "M"); ExcelColumns.Add(14, "N"); ExcelColumns.Add(15, "O"); ExcelColumns.Add(16, "P"); ExcelColumns.Add(17, "Q"); ExcelColumns.Add(18, "R"); ExcelColumns.Add(19, "S"); ExcelColumns.Add(20, "T"); ExcelColumns.Add(21, "U"); ExcelColumns.Add(22, "V"); ExcelColumns.Add(23, "W"); ExcelColumns.Add(24, "X"); ExcelColumns.Add(25, "Y"); ExcelColumns.Add(26, "Z"); }
public void ShoudGetAllColumns() { ExcelColumns columns = new ExcelColumns(); ExcelColumn column = new ExcelColumn { ColumnName = "Test", ErrorMessage = "not" }; columns.Add(column); Assert.IsType <List <ExcelColumn> >(columns.GetColumns()); }
public void ShouldAddOneColumn() { ExcelColumns columns = new ExcelColumns(); ExcelColumn column = new ExcelColumn { ColumnName = "Test", ErrorMessage = "not" }; columns.Add(column); Assert.True(columns.Count() == 1); }
public void ShouldGetExcelDataPopulater() { ExcelColumns columns = new ExcelColumns(); ExcelColumn column = new ExcelColumn { ColumnName = "Test", ErrorMessage = "not" }; columns.Add(column); IExcelDataPopulater excelDataPopulater = excelGenerator.GetExcelDataPopulater(columns); Assert.NotNull(excelDataPopulater); }
public void ShoudPopulateData() { ExcelColumns columns = new ExcelColumns(); ExcelColumn column = new ExcelColumn { ColumnName = "Test", ErrorMessage = "not" }; columns.Add(column); IExcelDataPopulater excelDataPopulater = new ExcelDataPopulater(excelGenerator.NativeExcelPackageObject, excelGenerator.UiSheetName, excelGenerator.DataSheetName) { ExcelColumns = columns }; excelDataPopulater.PopulateData(); byte[] data = excelGenerator.GetAsByteArray(); Assert.NotNull(data); }